Reputation: 37461
I have a python project like this:
project/
project/code
project/code/requirements.txt
project/fabfile
project/fabfile/requirements.txt
project/code
is a Python3 project, so I need to use that SDK.
project/fabfile
has to be python2, because Fabric currently doesn't support python3.
On the command line I have two virtualenvs to manage this, but inside IntelliJ (With the python plugin), I have my SDK set to Python3 with my virtualenv for the project SDK. As a result, it isn't detecting the different requirements in fabfile/, and is marking python2 syntax as errors.
How can I get it to use different SDKs for these?
Upvotes: 0
Views: 614
Reputation: 1
Assuming the following repository structure:
.
├── README.md
└── components
└── module_A
├── src/...
│ └── pyproject.toml
└── module_B
├── src/...
└── pyproject.toml
In IntelliJ IDEA 2024, with the JetBrains Python plugin:
File
-> Project Structure
-> Modules
Sources
tabcomponents
dir as excluded)File
-> Project Structure
-> Modules
+
-> Import Module
components/module_A
)Create module from existing sources
and click Next
Next
and Create
Add
-> Framework
-> Python
. This will open a window for you to configure the Python interpreter for that module.I haven't tested running code inside the IDE after this, but I'm able to use full code completion and navigation in the files under each module, with all and only the dependencies of that module's interpreter being visible.
Upvotes: 0
Reputation: 97288
If you're using IntelliJ IDEA, you can set up a multi-module project, and assign a different interpreter to each module. Create one module with 'code' as the content root, and another with 'fabfile' as the content root.
Upvotes: 1
Reputation: 110
As far as I know, I don't think can you use different interpreters simultaneously
You would have to switch interpreters on each project
Go to Preferences > Project Interpreter and point the interpreter to your virtual env(s)
Upvotes: 0