What's the difference between virtual environment and existing interpreter in PyCharm?

Answered

I opened PyCharm for the first time, and I see an option to choose 'New environment using: Virtualenv / Conda' or 'Existing interpreter'.

So:

1) What's the difference between the 2?

2) What's the difference between Virtualenv and Conda?

 

Thanks!

6
8 comments

Hello,

1.Pycharm detects existing python environments on your system and shows them in the Existing Environment| Interpreter drop-down list. If your existing environment is not detected automatically, you could press cogwheel and navigate to its path manually.

For more info please check https://www.jetbrains.com/help/pycharm/configuring-python-interpreter.html and feel free to ask any questions.

2. Please check https://conda.io/docs/user-guide/install/download.html. To know more about conda environments please take a look at https://conda.io/docs/user-guide/concepts.html#conda-environments.

 

-8

Sorry I don't understand. I have 3 options: Virtualenv / Conda / Existing Interpreter. In Virtualenv and Existing Interpreter I can choose the Python.exe file in Anaconda's directory (I have Anconda 3 installed). So what's the difference here? And if I choose Conda environment with the same Python version, does it make this choice any different?

The code runs successfully in all 3 options... So I don't understand what's the difference and what's the best choice for me.

Thanks

1

> In Virtualenv and Existing Interpreter I can choose the Python.exe file in Anaconda's directory (I have Anconda 3 installed). So what's the difference here?

Difference is that if you use virtualenv for the project and add/remove packages it affects only virtual environment. If you use Existing Interpreter then  all changes will affect system wide interpreter and these changes will be available in all projects that use that interpreter

> And if I choose Conda environment with the same Python version, does it make this choice any different?

When you create conda interpterer it asks for base interpreter it will use to create environment. Generally it checks for packages that should be imported in new environment.

Long story short:

Existing interpreter  - all changes are system wide

Conda/Virtual interpreter - uses selected interpreter as initial source, but creates independent copy which could be modified fot project needs.

 

 

 

5

Yaroslav Bedrov you say that Pycharm detect existing python installs, does this ability extend to venvs in the project directory ?

perhaps in a venv folder ?

We clone and create the projects directory from a script and thus the virtualenv is already there just needs setting each time we create an environment.

0

>you say that Pycharm detect existing python installs, does this ability extend to venvs in the project directory ?

Yes, it does. If it doesn't work, you can always select "Virtulaenv > Existing environment" and point manually to `venv/bin/python` (for Linux)

0

I have an additional question:

I see, I can choose/add/create a run/debug configuration for my special project, and I can choose an interpreter here (and a virtual environment).

Below in the bottom bar on the right, I can also choose a Python Interpreter. Why is this? I have found out some dependencies regarding autocompletion or pylint, if I do not choose this bottom bar interpreter the same like in my venv...

 

Maybe you can clarify what is the difference? Plus: And In the configuration I found a third setting in the console....I am confused. I guess the global setting is done in the bottom bar?

0

Hello peddanet,

 

>Below in the bottom bar on the right, I can also choose a Python Interpreter. Why is this?  

This is the same action as changing Project Interpreter Settings.

 

>Maybe you can clarify what is the difference? Plus: And In the configuration I found a third setting in the console....I am confused. I guess the global setting is done in the bottom bar?

 

When you change the Project Interpreter PyCharm will change it in all places ( python console, terminal, run configuration). For the console you can define the interpreter explicitly in the Python Console Settings

 

> if I do not choose this bottom bar interpreter the same like in my venv...

I am wondering if this is reproducible without pylint plugin enabled, the thing is that it is a third-party plugin, https://github.com/leinardi/pylint-pycharm/issues is best to report related issues. 

1

Thanks a lot, Antonina!!

0

Please sign in to leave a comment.