Incomplete sys.path with embeddable python (Windows)!?
jak
nospam at please.ty
Sun Apr 23 02:38:36 EDT 2023
Ralf M. ha scritto:
> Am 22.04.2023 um 03:27 schrieb Greg Ewing via Python-list:
>> How are you invoking your script? Presumably you have some code
>> in your embedding application that takes a script path and runs
>> it. Instead of putting the code to update sys.path into every
>> script, the embedding application could do it before running
>> the script.
>>
> In principle a good idea, but I don't know how to do that:
> The script is currently invoked by a .cmd file, but that may change to a
> shortcut (.lnk). This is what the embeddable package documentation calls
> "Python Application - simple approach".
> To update sys.path on start up I would need to do something like
> C:\path\to\python.exe --add-path C:\s-path C:\s-path\script.py
> but I couldn't find an option like --add-path.
what about:
foo.py:
from sys import path
print('path:', path)
#end foo.py
from prompt:
$ python -c "import sys;sys.path=['/user/foopath']+sys.path;import foo;foo"
output:
path: ['/user/foopath', '', '/usr/lib/python39.zip',
'/usr/lib/python3.9', '/usr/lib/python3.9/lib-dynload',
'/usr/lib/python3.9/site-packages']
More information about the Python-list
mailing list