How do I properly setup pipenv in PyCharm?

I need krakenex in a project, so I import it with

import krakenex

I have one version of krakenex in

/Users/x/Library/Python/3.6/lib/python/site-packages

. When I execute the script and

print(krakenex)

it shows me the path mentioned above.

In the future, I want to use the modules from the packages I installed with e.g.

pipenv install krakenex

with priority.

How do I manage to do that? Is it sufficient to add the path of the virtual environment to the sys path, or is there a more elegant way?


You should be pointing your Project Interpreter to the virtualenv python bin. So in PyCharm File->Settings->Project: ProjectName->Project Interpreter, then a windows showing the Project Interpreter should be displayed.

Project Interpreter

Next to the top dropdown is a gear and your going to want to Add Local and navigate to the virtualenvs python bin. Something like virtualenvs/virtualenv_name/bin/python. Then your project should be pointing to the right place.


To add more clarification on how to setup PyCharm with pipenv for now:

  1. Execute in your project directory

    pipenv --venv

Save the output, you'll reference this path later

  1. In PyCharm, Open Project Settings, and then select project interpreter Preferences > Project Interpreter

  2. Click Add a Python Interpreter > System Interpreter > Select Python Interpreter and paste the output from the first command, appending /bin/python onto the end. enter image description here

Note that you will need to use the command line to install any packages since PyCharm currently doesn't support pipenv in their package management tools. However, I haven't had a problem with this method.