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.