How to change python version pycharm
How to change python version pycharm
Configure a Python interpreter
Python interpreters in PyCharm
Python interpreters can be configured for a new project or for the current project (you can create a new interpreter or use one of the existing interpreters).
Setting an existing Python interpreter
Change the Python interpreter using the Python Interpreter selector
The Python Interpreter selector is located on the status bar. It is the most convenient and quickest way to switch the Python interpreter. Just click it and select the target interpreter:
Change the Python interpreter in the project settings
Press Ctrl+Alt+S to open the IDE settings and select Project
Expand the list of the available interpreters and click the Show All link.
Select the target interpreter.
When PyCharm stops supporting any of the outdated Python versions, the corresponding Python interpreter is marked as unsupported.
When you change an SSH interpreter, you might need to synchronize local content with the target server. Mind a notification balloon in the lower-right corner. You can click one of the links to perform the following actions:
Auto-upload files to the server
Synchronize files and then enable auto-uploading
Modify a Python interpreter
Press Ctrl+Alt+S to open the IDE settings and select Project
Expand the list of the available interpreters and click the Show All link.
You can specify an alternative interpreter name for the selected interpreter. The Python interpreter name specified in the Name field, becomes visible in the list of available interpreters. Click OK to apply the changes.
For remote interpreters (that are available in PyCharm Professional ) you can modify configuration parameters.
Creating a new Python interpreter
To add a new interpreter to the current project:
Do one of the following:
Press Ctrl+Alt+S to open the project Settings/Preferences and go to Project
Note that SSH, WSL, Vagrant, Docker, and Docker Compose are available only for the commercial version of PyCharm. WSL is Windows specific.
Select Add Local Interpreter from the list of the available interpreter types.
If New Virtualenv is selected:
If PyCharm detects no Python on your machine, it provides two options: to download the latest Python versions from python.org or to specify a path to the Python executable (in case of non-standard installation).
If you select any of the existing virtual environments from the Interpreter list, it will be reused for the current project.
Click OK to complete the task.
If you have added the user base’s binary directory to your PATH environmental variable, you don’t need to set any additional options: the path to the pipenv executable will be autodetected.
Click OK to complete the task.
Click OK to save the changes and complete the task.
Select Add Local Interpreter from the list of the available interpreter types.
If Poetry Environment is selected:
Select the base Python interpreter from the list, or click and find its location in your file system.
If PyCharm has not discovered the Poetry path, click near Poetry executable and navigate to its location. Then click OK in the explorer window to add it to the field.
If Existing environment is selected:
Expand the Interpreter list and select any of the existing Poetry environments. Alternatively, click and specify a path to it.
Click OK to complete the task.
If New Virtualenv is selected:
Select the Python version from the list.
Select the Make available to all projects checkbox if you want to reuse this environment when creating Python interpreters in PyCharm.
If you select any of the existing virtual environments from the Interpreter list, it will be reused for the current project.
Click OK to complete the task.
Select Add Local Interpreter from the list of the available interpreter types.
Specify a path to the Python executable (in case of non-standard installation)
Download and install the latest Python versions from python.org
Install Python using the Command-Line Developer Tools (macOS only).
You will need admin privileges to install, remove, and upgrade packages for the system interpreter. When attempting to install an interpreter package through an intention action, you might receive the following error message: As prompted, consider using a virtual environment for your project.
Click OK to complete the task.
Select On SSH from the list of the available interpreter types.
Select an option to create a new SSH configuration, then specify server information (host, port, and username).
In the next dialog window, provide the authentication details to connect to the target server.
Select Password or Key pair (OpenSSL or PuTTY) and enter your password or passphrase. If Key pair (OpenSSL or PuTTY) is selected, specify:
Private key file : location of the file with a private key
Passphrase : similar to a password, it serves to encrypt the private key.
The RFC 4716 format for OpenSSH keys is not supported by PyCharm. See the workaround.
Click Next to proceed with the final configuration step.
Wait until PyCharm completes the introspection of the SSH server.
In the next dialog, you can select a type of Python environment to configure on the SSH server.
You can select a new or existing venv or use a System interpreter.
You have to configure the path mappings between your local project and the server. To do that, click next to the Sync folders field and enter the path to the local project folder and the path to the folder on the remote server.
Click Create to complete adding an interpreter.
Select On Vagrant :
In the New Target: Vagrant dialog, click the browse icon next to the Vagrant Instance Folder field, and specify the desired Vagrant instance folder.
In the next field, PyCharm will display the path to the Python executable. Press «Next» to proceed.
You can create a virtual environment (venv or Conda) or use a system Python interpreter for the target Vagrant instance. Note that virtual environment must be configured and available in the specified Vagrant instance folder. Otherwise, the corresponding lists will be empty.
Press Create to complete the task.
Select On WSL from the list of available interpreter types:
Wait until PyCharm detects Linux on your machine and completes introspection. Press Next to proceed:
For a system interpreter, just provide the path to the Python executable in the selected Linux distribution.
For virtual environments, you can provide a path to existing environments in the selected Linux distribution or create a new environment based on the specified Python.
Select On Docker from the list of the available interpreter types.
In the New Target: Docker dialog, specify the docker server and define the way PyCharm will manage the docker image: build images locally from a Dockerfile or pull pre-built images from a Docker registry.
Optionally, specify the docker build options. You can also define the docker run command with the following syntax:
Use code completion when typing the command options ( Ctrl+Space ).
Wait for PyCharm to connect to the Docker daemon and complete the container introspection.
Next, select an interpreter to use in the Docker container. You can select any virtual environment that is already configured in the container or select a system interpreter.
Click OK to complete the task.
Select On Docker Compose from the list of the available interpreter types.
In the New Target: Docker dialog, specify the docker server and the docker-compose.yml file. Also select the service.
Wait until PyCharm creates and configures a new target:
Next, select an interpreter to use in the container. You can select any virtual environment that is already configured in the container or select a system interpreter.
Click OK to complete the task.
When a remote Python interpreter is added, at first the PyCharm helpers are copied to the remote host. PyCharm helpers are needed to run remotely the packaging tasks, debugger, tests and other PyCharm features. Next, the skeletons for binary libraries are generated and copied locally. Also all the Python library sources are collected from the Python paths on a remote host and copied locally along with the generated skeletons. Storing skeletons and all Python library sources locally is required for resolve and completion to work correctly. PyCharm checks remote helpers version on every remote run, so if you update your PyCharm version, the new helpers will be uploaded automatically and you don’t need to recreate remote interpreter. SFTP support is required for copying helpers to the server.
Setting the default interpreter
In PyCharm, you can specify an interpreter that will be automatically set for all newly created projects.
From the main menu, select File | New Projects Setup | Settings for New Projects (on Window and Linux) or File | New Projects Setup | Preferences for New Projects (on macOS).
Select Python Interpreter settings. Then either choose an existing interpreter from the Python interpreter list of click to add a new interpreter. Click OK to save the changes.
The change will become effective for all newly created projects in PyCharm.
Managing interpreter packages
For each interpreter, you can install, upgrade, and delete Python packages. By default, PyCharm uses pip to manage project packages. For Conda environments you can use the Conda package manager.
PyCharm smartly tracks the status of packages and recognizes outdated versions by showing the number of the currently installed package version (column Version ), and the latest available version (column Latest version ). When a newer version of a package is detected, PyCharm marks it with the arrow sign and suggests to upgrade it.
See the detailed instructions:
See the following video tutorial for additional information:
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
Trending sort
Trending sort is based off of the default sorting method — by highest score — but it boosts votes that have happened recently, helping to surface more up-to-date answers.
It falls back to sorting by highest score if no posts are trending.
Switch to Trending sort
Preferences->Project Interpreter->Python Interpreters
If it’s not listed add it.
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
Edit Configurations»>
PyCharm 2019.1+
There is a new feature called Interpreter in status bar (scroll down a little bit). This makes switching between python interpreters and seeing which version you’re using easier.
Enable status bar
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.
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 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:
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.).
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 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.
Close PyCharm
Check if the system interpreter you want to upgrade to is on the system Path
You can quickly check by running
For you, the output should look like this
If your output is different, you’ll need to prefix the absolute path to the Python executable in step 4).
Navigate to the virtual environment’s directory
Upgrade the virtual environment
. or if Python is not on your path
Open PyCharm and verify your environment is working correctly
. or simply try to run pip directly from the command line. Note you need to first activate the virtual environment by running the Scripts\activate.bat batch file.
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.
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 Change Python Version in Pycharm? : Only 4 Steps
Numpy cov() method Implementation in Python : 3 Steps Only
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 :
how to change python version in pycharm step 1
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.
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 :
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. pycharm
Thanks
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.
Install, uninstall, and upgrade packages
PyCharm provides methods for installing, uninstalling, and upgrading Python packages for a particular Python interpreter. By default, PyCharm uses pip to manage project packages. For Conda environments you can use the conda package manager.
Manage packages in the Python Packages tool window
This tool window is available in PyCharm 2021.1 and later
The Python Packages tool window shows installed packages and the packages available in the PyPI repository. Use the Search field to filter out the list of the available packages.
You can preview package documentation in the documentation area, or you can click the Documentation link and open the corresponding resource in a browser.
To delete an installed package, click in the upper-right corner of the Python Package tool window.
Install packages from repositories
Start typing the package name in the Search field of the Python Package tool window. You should be able to see the number of the matching packages.
Expand the list of the available versions in the upper-right corner of the tool window. Select the required version or keep it the latest.
Click the Install button next to the version list. Once PyCharm notifies you about successful installation, you should see the package in the list of the installed packages.
If needed, click and provide a path to any custom repository you want to install from.
Manage package repositories
To specify a custom repository, including devpi or PyPi, click on the Python Packages toolbar.
If you want to install Python packages from a repository that requires HTTP authorization, click Basic HTTP and type the repository URL and the login credentials. Click OK to complete the task.
Once the repository is added, it appears in the list of the repositories in the Python Packages tool window.
Install packages from Version Control System
Specify a path to the target git repository. Refer to pip documentation for more information about supported path formats.
Select Install as editable (-e) if you want to install a project in editable mode (for example, setuptools develop mode ).
Install packages from a local machine
Specify a path to the package directory or an archive ( zip or whl ).
Manage packages in the Python interpreter settings
If you select a Python interpreter with the configured Conda environment, the Use Conda Package Manager toggle appears in the packages area toolbar.
Use this toggle to manage packages from the Conda environment repository. This toggle is enabled by default for Conda environments.
Install a package
Click the button on the package toolbar.
In the Available Packages dialog that opens, preview the list of the available packages and type the name of the package to install in the Search field.
If required, select the following checkboxes:
Specify version : if this checkbox is selected, you can select the desired version from the list of available versions. By default, the latest version is taken.
Options : If this checkbox is selected, you can type the pip install command-line options in the text field.
Install to user’s site packages directory
: If this checkbox is left cleared (by default), then the packages will be installed into the current interpreter package directory. If the checkbox is selected, the packages will be installed into the specified directory. This option is not available for Conda environments.
If you’ve got any or error messages, consult the Troubleshooting guide for a solution.
Uninstall a package
In the list of the packages, select the packages to be removed.
Click Uninstall ( ). The selected packages are removed from disk.
PyCharm smartly tracks the status of packages and recognizes outdated versions by showing the number of the currently installed package version (column Version ), and the latest available version (column Latest version ). When a newer version of a package is detected, PyCharm marks it with the arrow sign and suggests to upgrade it.
Upgrade a package
In the list of the packages, select the package to be upgraded.
The selected packages are upgraded to the latest available versions.
Click OK to complete upgrading.
If you’re accustomed to installing packages from the commands line, you can proceed with your workflow using the Terminal.
Reuse installed packages
Create a new virtual environment and install packages that you want to be used in other projects. Then you can specify this virtual environment as a Python interpreter for the target project and all the needed packages will be available.
In the Terminal window execute the following command:
Источники информации:
- http://stackoverflow.com/questions/10322424/how-to-select-python-version-in-pycharm
- http://stackoverflow.com/questions/62492713/how-do-i-reroute-a-project-to-another-python-version-in-pycharm-error-no-pyth
- http://www.datasciencelearner.com/how-to-change-python-version-in-pycharm/
- http://www.jetbrains.com/help/pycharm/installing-uninstalling-and-upgrading-packages.html