Adding an interpreter path seems to have no effect

I am using PyCharm community edition 2018.3.1 under Windows 10. 

Essential is also that Python is not installed, so there are no default paths pointing to Python or Python/Scripts in my system path. So I am relying on PyCharm's search path.

After adding  a directory to the interpreters search path via:

File -> settings -> Project Interpreter  then selecting "show all" and then selecting the icon   and adding  "Python3.6.6\Scritps"  in order to extend the PATH variable so that the executables under Scripts can be found, like pip  and sphinx-build. 

I see added to the list:

however, pip and other executables are not found when using os.system("pip") 

When I add that path to my general search path before calling PyCharm,  os.system("pip") is found,

When I don't add that path to my general search path before launching PyCharm,  os.system("pip") can't find pip.

In both cases above, I see  Python3.6.6/Scripts in sys.path. 

So the path used in "os.system" is not described by sys.path

 

 

What I also notice is that when using venv, this problem doesn't exsit because pip, sphinx-build are all in the Scripts directory together with Python. So when not using venv,  Scripts is not a part of the "standard search" paths. 

I suspect that this problem is not often seen, because most people are using a single Python install. But because I need to use several different Python runtimes, Like version 3.6 and 3.7 and even 64 and 32 bit releases in different projects, I can't have single global python install. So when using PyCharm, I have to rely on its search paths. When I call those same python modules in my  own batch files, they work, because I set the correct enviromental varaibles before calling them. But if I launch PyCharm "globally" and not with a batch file, PyCharm only sees my default enviromental variables, which does not include any reference to any python runtime, so I must rely on the paths configured in the Pycharm tool. 

So I hope that you can reproduce this issue point out what I may be seeing or doing incorrectly. 

 

 

 

 

 

 

 

 

 

5 comments
Hi bronlib, Thank you for contacting JetBrains support. Please be advised that installing multiple Python versions using different executable installers is supported in Windows, so you can use that. PyCharm will recognize all interpreters and will allow you to choose between them when creating new interpreter. Otherwise, when you select a path where your interpreter is located, you should be able to install packages from "File | Settings | Project: | Project Interpreter", including pip and sphinx. You can do this for each interpreter separately. Let me know if that doesn't work for you.
0

Hi Jiri,

Thanks for the answer. It still didn't work. It can't find any executables under the "\Scripts" directory, even if I add that path to the interpreters path in PyCharm.

To illustrate this, I created the small program:


import shutil
print(shutil.which("pip"))
will result in:
None

But if I launch Pycharm, for the same project and project settings, in a dos batch file in which the path to Scripts is defined,
set PATH=..\..\Python367;..\..\Python367\Scripts;%PATH%

then, that same program prints:
..\..\Python367\Scripts\pip.EXE

This seems to show that PyCharm is not looking at the \Scripts path which was added to the interpreter paths.

the interpreter paths are:

I hope the problem that I'm trying to point out is clear. Otherwise, please let me know, thanks for your support

0

Please note that when you run `os.system` or `shutil.which` from python, they invoke system commands, so the system environment will apply. You need to have the path to your "pip" executable in your PATH env variable for them to find it. But even if you don't, you can use PyCharm's inbuilt package manager to install sphinx and other libraries.

And as Jiri mentioned, if you just need different Python versions to test your applications, you can just install any number of versions using windows installers from python.org, and PyCharm should detect them and let you choose.

0

Hi Andrey & Jiri,

Thanks for you support. I guess my problem is that I incorrectly interpreted the effect of adding a path to the "project interpreter path.

Below is a complete screen shot.

I expected  "....\Scripts" to be added to my path. 

But what I found out is that if your environmental variables do not include

file://D:/ProjectsWithNoSpecialLibraries/Python_runtime/Scripts,  it is not added to your "environment" by adding it to the Project Interpreter path.

Hence, 'os.system' or 'shutil.which" does not find "pip", which is under "Scripts" even if "Scripts" is added to the Project Interpreter path.

0

The short answer is:

The paths from Interpreter Paths dialogue window are added to PYTHONPATH, which is used by the interpreter to find modules to import.

The executables, however, need to be included in PATH.

0

Please sign in to leave a comment.