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']
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to