Pycharm смена версии python

How do I reroute a project to another Python version in PyCharm? (Error: No Python at ‘C:\Users\. \python.exe’)

dumb ffuckin picture smh

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.

Читайте также:  Column property in css

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.

Читайте также:  Javascript write to html div

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.

  1. Close PyCharm
  2. 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

enter image description here

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

PyCharm Run data-lazy-src=

In case you cannot see the status bar, you can easily activate it by running the Find Action command ( Ctrl + Shift + A or ⌘ + ⇧ + A on mac). Then type status bar and choose View: Status Bar to see it.

enter image description here

Thank you! It’s hard to believe this is so hidden. Seems like there should be able to right-click on the project and change its settings (including interpreter.)

This can also happen in Intellij Ultimate, which has PyCharm integrated. The issue is as diagnosed above, you have the wrong interpreter selected.

The exact method to fix this for any given project is to go to Project Settings. Project and adjust the Project SDK. You can add a New Project SDK if you don’t have Python 3 added by navigating to the python3 binary. This will fix the errors listed above. A shortcut to Project Settings is the blue checkerboard-type icon.

You can also add Python 3 as the default interpreter for Python projects. On OSX this is in File..Other Settings. Default Project Structure. There you can set the Project SDK which will now apply on each new project. It can be different on other platforms, but still similar.

Источник

How to Change Python Version in Pycharm? : Only 4 Steps

Importerror no module named setuptools Fix

I guess most of us are aware of the fact that syntax in Python 2.x series are a little different than the Python 3.x series. Obviously, there can be a situation where you have to change the interpreter version for the program run. Especially when your IDE is Pycharm everything is quite easy. If you are looking for how to change the python version in PyCharm? I think this article is just for you.

Steps to change python version in pycharm-

Step 1 :

  1. Check if you already have that version interpreter of Python pre-installed. Suppose if you have Python 3.7 but you need a virtual env in pycharm for 2.7 base interpreter. In order to check it, Go to –

File -> Settings -> Project ->Project Interpreter

How to change python version in pycharm step 1

how to change python version in pycharm step 1

Refer to the above diagram, Here click on the drop-down of the Project Interpreter row ( Where the No Interpreter is mention). It will show you the name and path of the Interpreter which are already configured. All you need to select one of them if they are available at Run time Configuration in Pycharm ( Hint Run -> Edit Configurations).

Step 2:

In case the desire interpreter is not available. Go and install the required from https://www.python.org/downloads/
There is a dedicated tutorial on how to install python in you Opearting System. Follow the steps to install it.

Python version download.

Step 3 :

Set the path in the system variable. Especially while installing from Python.org window installer, It will show you the option to set the path automatically with the installation. In case you do not opt for it. Go and manually add it.

Step 4 :

how to change python version in pycharm step 4.

Now once you have done to step 3, Restart the Pycharm and select the desired interpreter in Run -> Edit Configurations inside Pycharm IDE. Now you may use this global python interpreter for the project. But in case you want to create the virtual env based on this interpreter. You may go to File -> Settings -> Project ->Project Interpreter and click on the setting icon and choose to add.

Refer to the above image and change the base Interpreter here. Here you may choose the one which is the newest you installed. Here you may choose the conda env as the Interpreter also. It is just to make sure that pycharm is fully configurable with a variety of Interpreters.

How to downgrade python version in pycharm

In the above steps you have understood how to the edit configuration for the python interpreter. You can easily select the version of the python you want to to use or downgrade using it. This way you can easily downgrade python version in pycharm.

You can download the pycharm IDE from here.

Conclusion –

This is a generic way to deal with python versioning with pycharm. It will remain same in most of the platform or operating system like mac, Linux or Windows etc. Now next to it is pycharm exploration. Just like, there are some other important configurations with pycharm like increasing memory in Pycharm and Installing packages in pycharm which we understand as next step.

Join our list

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

We respect your privacy and take protecting it seriously

Thank you for signup. A Confirmation Email has been sent to your Email Address.

Источник

Оцените статью