Reputation: 51988
I want to use Intellij Idea within my existing python django project which was built within a virtual environment in ubuntu. How do I configure Intellij Idea to use the libraries of the virtual environment?
Upvotes: 62
Views: 33453
Reputation: 2189
Additional permutation:
Can one add an additional "SDK" (vague term in this context) as a "library" dependency and set the "scope=runtime"?
Does this "activate" the python 3.12 prior to any run/debug executions for this project?
This appears to work, but I'm just not feeling super-confident about it at the moment.
Upvotes: 0
Reputation: 51988
As per documentation from Pycharm:
In the left-hand pane of the Add Python Interpreter dialog box, select Virtualenv Environment. The following actions depend on whether the virtual environment existed before.
If Existing environment is selected:
Click OK to complete the task.
To add an existing virtual environment to the list of available interpreters
Go to this link for more information.
Well I solved the above problem. I have added virtualenv folder's python to project sdk. The virtualenv directory's python( for example venv/bin/python2.7) needs to be added to Intellij Idea project path. Example: need to go to file>project structure (intellij Idea)
press new in Project SDK, and add new path to virtualenv's python directory like this:
Go to Modules>Dependencies and set your module sdk to Python SDK which is marked on this picture:
Click on Django (option marked in next the image) and set Django project root
, Settings
,Manage Script
like this:
Now press ok and final look of the Project settings:
Now need to run the project.
Upvotes: 83
Reputation: 2641
The above answer is based on older version of IntelliJ. For new, look here: https://www.jetbrains.com/help/pycharm/2016.1/adding-existing-virtual-environment.html
Upvotes: 2