- How do I reroute a project to another Python version in PyCharm? (Error: No Python at ‘C:\Users\. \python.exe’)
- 1 Answer 1
- Disclaimer
- How to select Python version in PyCharm?
- 6 Answers 6
- Enable status bar
- How to Change Python Version in Pycharm? : Only 4 Steps
- Steps to change python version in pycharm-
- Step 1 :
- Step 2:
- Step 3 :
- Step 4 :
- How to downgrade python version in pycharm
- Conclusion –
- Join our list
How do I reroute a project to another Python version in PyCharm? (Error: No Python at ‘C:\Users\. \python.exe’)
I wanted to replace Python 3.8 32-bit with the 64-bit version to install the face_recognition module, so I deleted the previous version and tried to re-route the project to the new Python version by going to File > Settings > Project Interpreter > Show all > Show Paths for Selected Interpreter, and adding all the Python files from the new folder and getting rid of the old ones. However, it’s still showing me this error when I try to install the module:
(Will2.0) C:\Users\solei\PycharmProjects\Will>pip install face_recognition No Python at 'C:\Users\solei\AppData\Local\Programs\Python\Python38-32\python.exe'
I’ve also tried going to the Windows System Properties and changing everything that says «Python38-32» there, but it’s still not working. It does work when I make a new environment, though, so at least I know that Python installed properly. It’s just this one environment that is tripping me up (I’d prefer not to make a new project for this, btw. I’ve already installed a lot of modules in it.).
When you try to install a module with PIP in the terminal you have to activate the venv otherwise you are installing to the interpreter (which may resolve to different site-package locations). Consider this thread. The full explanation is somewhat complicated, see PEP 250 and PEP 370.
1 Answer 1
Your selected interpreter is not the system interpreter you’ve replaced with the 64-bit version, but your project’s virtual environment interpreter. The virtual environment’s files weren’t changed in that process and need to be updated before you can use that environment again.
- The system interpreter is your Python interpreter installed using the installation executable. In your case it is located in C:\Users\solei\AppData\Local\Programs\Python\Python38\ . You can have multiple system interpreters installed, such as having Python 2.7, Python 3.7 and Python 3.8 side-by-side.
- The virtual environment interpreter is a copy of another interpreter created using the venv package from the Python standard library. You can have many virtual environments interpreters in the system (one or more for every project, for example)
- The base interpreter is the interpreter that was used as a template for the venv package. Every virtual environment interpreter has its base interpreter (usually a system interpreter) that it requires to run. Changing or upgrading the base interpreter requires updating the virtual environment.
If we take a quick look at the documentation, a virtual environment is described as
a self-contained directory tree that contains a Python installation for a particular version of Python, plus a number of additional packages.
That means you can setup an individual environment for every project, which will contain its own packages. The environment is a very efficient way of managing project packages, that’s why PyCharm suggests a creation of such environment over the system interpreter by default. In short, it allows you to have two different versions of the same package used by two different projects, without the packages conflicting with each other.
This also explains why your virtual environment files weren’t affected by your upgrade.
Now, I am unfortunately no Python expert. I had to spend some time examining how Python handles virtual environments on Windows and Ubuntu. It seems the environment always requires the base system interpreter present in the system. If you remove or change the location of the base interpreter, the environment will fail to function.
As I mentioned before editing this answer, you can in theory simply edit the pyenv.cfg file located in the root folder of the virtual environment. In practice, that will only work in simple cases and it is not the intended way of updating virtual environments.
You need to upgrade your virtual environment’s files to work with your new system interpreter. That can mean the 64-bit version over the 32-bit version, or even a newer version of Python — such us upgrading from 3.7 to 3.8.
- Close PyCharm
- Check if the system interpreter you want to upgrade to is on the system Path You can quickly check by running
python -c "import platform; print(platform.architecture())"
cd C:\Users\solei\PycharmProjects\Will2.0\
C:\Users\solei\AppData\Local\Programs\Python\Python38\python.exe -m venv --upgrade .
If the above-mentioned method doesn’t work, you might have to create a new virtual environment. You can create one easily without making a new PyCharm project. See this PyCharm documentation for reference. However, you’ll still need to redownload all the required packages again.
For the simplicity, I recommend creating the new virtual environment in a .venv folder located in the project’s root.
Disclaimer
I tested only the Python’s behavior alone on a fresh Windows installation inside the Windows Sandbox. I was able to install the 32-bit Python, create a virtual environment, replace Python with the 64-bit version and upgrade the virtual environment to have it launch correctly again.
How to select Python version in PyCharm?
I have PyCharm 1.5.4 and have used the «Open Directory» option to open the contents of a folder in the IDE. I have Python version 3.2 selected (it shows up under the «External Libraries» node). How can I select another version of Python (that I already have installed on my machine) so that PyCharm uses that version instead?
6 Answers 6
Preferences->Project Interpreter->Python Interpreters
Why does this have upvotes as it doesn’t even answer the question. He says he has installed multiple versions of Python (version 2 and version 3). He wants to run some scripts with python 3 and some with python 2. How do you change the version of python that is used?
I think you are saying that you have python2 and python3 installed and have added a reference to each version under Pycharm > Settings > Project Interpreter
What I think you are asking is how do you have some projects run with Python 2 and some projects running with Python 3.
If so, you can look under Run > Edit Configurations