Python import error on Windows: no __path__ -


ok, trying track down issue of running python package.

running on windows.

only 1 version of python installed on computer: 3.4.3

package has been installed (package name: willie) (details of installation more convoluted usual; can provide steps if necessary)

package installed at: c:\python34\lib\site-packages\willie

startup script is: c:\python34\scripts\willie.py

error 1 of first lines of script:

from willie.tools import stderr 

if run willie.py command line, error:

traceback (most recent call last):   file "<frozen importlib._bootstrap>", line 2218, in _find_and_load_unlocked attributeerror: 'module' object has no attribute '__path__'  during handling of above exception, exception occurred:  traceback (most recent call last):   file "c:\python34\scripts\willie.py", line 15, in <module>     willie.tools import stderr   file "c:\python34\scripts\willie.py", line 15, in <module>     willie.tools import stderr importerror: no module named 'willie.tools'; 'willie' not package 

the __path__ attribute supposed set automatically when import function used, doesn't exist, leads program being unable execute.

c:\python34\scripts; in path environment variable.

pythonpath has been set c:\python34; c:\python34;c:\python34\lib;c:\python34\lib\site-packages;c:\python34\lib\site-packages;c:\python34\lib\site-packages\willie;c:\python34\lib\site-packages\willie\tools;.

in cases these directories, if try execute above import command interactive python prompt, runs correctly. can use stderr function, , examine __file__ , __path__ fields.

if add c:\python34\scripts; pythonpath, however, same error using command line: __path__ doesn't exist, 'willie' not package.

i know willie.py being called recursively, somehow, because can add print() @ top of file runs twice.

looking in figuring out how make run. configuration issue on end, have no idea fix it.

first, absolutely not want c:\python34\scripts in pythonpath. files under \scripts not meant importable.

second, willie screwing around make sure willie.py gets installed c:\python34\scripts\willie (note there no .py suffix). decidedly nonstandard. reason works because on unix machines, first line of file special "shebang" tells unix program launcher execute file using python. there no equivalent feature on windows - naming file willie no .py means can't execute it.

so looks module willie not prepared installed on windows systems. (#811 , #822 both refer weirdness on windows caused nonstandard package setup.)

a standard package setup have willie.py inside willie package willie/main.py and, in package's setup.py, register willie.main "entry point" named willie. incantation create c:\python34\scripts\willie.exe on windows systems when package installed using pip.

i believe reason recursive import because second entry in sys.path name of script run command line. so, it's finding c:\python34\scripts\willie.py when looks module willie not 1 needs.

as workaround, try renaming c:\python34\scripts\willie.py c:\python34\scripts\run-willie.py


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -