Reputation: 3621
I have developed a project with PyCharm using Python 3.7. Now I want to upgrade the project to Python 3.10. I managed to install Python 3.10 and select it as the project interpreter but the terminal in PyCharm is still using 3.7. Why is that? How to use 3.10 in all cases?
*Additional question is whether it is possible to transfer the virtual environment of the project in Python 3.7 to the new interpreter Python 3.10 somehow.
Upvotes: 3
Views: 1668
Reputation: 12870
Case 1. Starting with a single fresh project
The interpreter that gets activated when you open the terminal (or a new terminal tab) is the one chosen in File
>
Settings
>
Project
>
Python Interpreter
provided you've chosen File
>
Settings
>
Tools
>
Terminal
>
Activate virtualenv
.
If you start with a fresh project the value is controlled by the value THE_INTERPRETER_NAME
in your project.iml
file:
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="THE_INTERPRETER_NAME" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
Case 2. One project having other projects attached in the same window
The problem is if you have a complex project with several projects open in the same window and one primary project. In that case you can configure different interpreters for each project, I tried it out and the terminal activates the interpreter set for the last project in the list, the controlling variable is set in misc.xml
in the .idea
folder of the primary project.
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9 (delete_this_venv)" project-jdk-type="Python SDK" />
<component name="PyCharmProfessionalAdvertiser">
<option name="shown" value="true" />
</component>
<component name="PythonCompatibilityInspectionAdvertiser">
<option name="version" value="3" />
</component>
</project>
I went through the settings but there's no other option to configure this behavior beyond what I explained.
Upvotes: 2