Why doesn't my installed (on Windows in a virtual environment) python script work without a full path? -
i wrote little python bundle , installed in python 2.7 virtual environment using pip. bundle includes command-line utility script, let's phone call my_script.py
uses functionality bundle via import mypkg
call. script installed virtualenv scripts folder, after activating virtualenv, if call
(my_env) > python my_script.py --help
i error:
python: can't open file 'my_script.py': [errno 2] no such file or directory
and if call
(my_env) > my_script.py --help
i error
traceback (most recent phone call last): file "c:\pyenvs\my_env\scripts\my_script.py", line 1, in <module> import mypkg importerror: no module named mypkg
(even though mypkg
shows in pip list
). if call
python c:\pyenvs\my_env\scripts\my_script.py --help
does script work expected. doing wrong, or deficiency of virtualenv on windows?
(further note c:\pyenvs\my_env\scripts
in %path%, , same behavior if c:\pyenvs\my_env\scripts
in %pythonpath%.)
> python my_script.py
will work if current directory in path environment variable. if not, must specify directory un, either completely, or relative working directory.
so do:
> python .\myscript.py
or update path , add together "." current directory. http://en.wikipedia.org/wiki/path_(variable)
python windows python-2.7 package virtualenv
No comments:
Post a Comment