Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PyCharm with Pyenv

Tags:

python

pycharm

How to use Pyenv virtualenv's with Pycharm 2016.3? In the earlier version of Pycharm, I could easily set up local interpreter to point anything installed on my machine.

My first idea was to add .python-version file on the root of the project. I Pyenv virtualenv installed so this will activate & run the project with correct environment automatically. However, Pycharm still doesn't see the correct interpreter causing it to though import and syntax errors.

How can I select my local Pyenv in new PyCharm 2016.3 I used to be able to set the path as variable now I can only browse the path using drop-down menu. It doesn't seem to show hidden files like default path for pyenv ~./.pyenv/versions{project}.

like image 339
Kimmo Hintikka Avatar asked Dec 13 '16 19:12

Kimmo Hintikka


People also ask

Does PyCharm use Pyenv?

Now comes the tricky part: PyCharm is supporting Pipenv as an interpreter, but it doesn't recognize it automatically anymore after the initial interpreter selection (which happens at project initiation / first time opening of the project, automatically).

Should I use Pyenv or Pipenv?

As tools, Pyenv and Pipenv are tidy and maintainable as well as easy to understand and use. Pyenv is used to manage different Python versions, whereas Pipenv is used to manage Python packages. I really like using both and I hope you are encouraged to try these tools for Python development.

Should I use Pyenv or virtualenv?

If you are working with your personal projects and not installing pipenv, I recommend installing pyenv-virtualenv. If you are working in a team or with more than one system, I recommend you to install pipenv which I am covering next.


1 Answers

In Pycharm version 2017.3, you can go to Pycharm -> Preferences -> Project -> Project Interpreter -> <project_name> -> settings button on the right of the python interpreter text box -> Add local

This will open a new window with virtualenv Environment as one of the options on the left. On Selecting it, you will get an option to make a new virtualenv environment or use an existing virtual environment. Here next to the dropdown text box, you can click "..." and browse to your existing virtualenv created using pyenv and select it. It will select this virtualenv when you start terminal from Pycharm and also use the corresponding python interpreter as set while creating that virtualenv.

enter image description here

like image 139
Viral Modi Avatar answered Sep 24 '22 02:09

Viral Modi