Bizarre python ImportError

Here's my setup: Mac, running OS X Tiger. Windows XP runs on a virtual machine (Parallels). Windows XP has a Mac home directory that appears as a network drive.

I have two files in the directory of my Mac home directory:

foo.py

pass

test.py

import foo

If I run test.py from my virtual machine by typing "python test.py", I get the following:

Traceback (most recent call last):
  File "test.py", line 1, in <module>
    import foo
ImportError: No module named foo

If I try to import foo from the console (running python on Windows from the same directory), all is well:

Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import foo
>>>

If I run test.py with Mac python, everything will be fine.

If I copy test.py and foo.py to another directory, I can run test.py on Windows without any problems.

init.py, . , .

, python.

?

+3
2

import sys; print sys.path test.py. , . "." , .

+2

: foo.py Windows? (, ).

, :

python -v -v test.py

(, PYTHONVERBOSE = 2). , foo. .

+1

Source: https://habr.com/ru/post/1698947/


All Articles