You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Attempting to change the working directory and then import based on that change has no effect. Import seems impossible. Attached is tarball example. As seen below, bar1.py can import foo from src, however bar2.py bar3.py and bar4.py cannot, despite their respective scripts changing their cwd. Below is results of a terminal session. Thanks in advance.
print(os.getcwd())
fromsrcimportfooprint('this is bar2.py')
james@hostname:~$ python import_bug/bar1.py
/home/james
this is foo.py
this is bar1.py
james@hostname:~$ python import_bug/test/bar2.py
/home/james/import_bug
Traceback (most recent call last):
File "import_bug/test/bar2.py", line 7, in <module>from src import foo
ImportError: No module named src
james@hostname:~$
Try printing sys.path in your scripts. It is what's in sys.path that matters, not the cwd. (The cwd is put in the path as "" in the specific case of running the python interactive shell...and in certain applications that embed Python because of a bug in those applications.)
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: