5

I use windows 7 without admin rights and i would like to use python3. Even if i set PYTHONPATH, environment variable is ignored. However PYTHONPATH is valid when printed.

>>> print(sys.path)
['c:\\Python365\\python36.zip', 'c:\\Python365']
>>> print(os.environ["PYTHONPATH"])
d:\libs

any idea ?

thank you very much

Gil

4
  • How did you install? It looks like you may be using the embedded distribution, with the standard library in a zip file. Make sure Python is installed correctly using the executable installer, e.g. python-3.6.5-amd64.exe. Commented May 2, 2018 at 6:11
  • yes you right, but why this version does not care for PYTHONPATH ? I'll try to use executable installer. Commented May 3, 2018 at 6:40
  • The embedded distribution is meant for Python applications or applications that include scripting support via Python. PYTHONPATH is meant for a system Python or development installations, but it should not affect applications that embed Python, which need independent control of Python's search path. Commented May 3, 2018 at 11:27
  • Ok that works with executable installer. Thank you eryksun Commented May 11, 2018 at 7:07

2 Answers 2

2

When using the embedded distribution (.zip file), then the PYTHONPATH environment variable is not respected. If this behavior is needed, then one needs to add some Python code that load the setting it from os.environ.get('PYTHONPATH', '') split the directories and add them to sys.path.

Also note that pip is not supported with the embedded distribution, but can be made to work.

Alternatively one uses the installers instead of the embedded distribution.

Sign up to request clarification or add additional context in comments.

Comments

0

Add the contents of PYTHONPATH to python._pth in the root folder one entry per line.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.