0
votes

PyCharm version: Professional 2018.1

Django version: 2.0

virtualenv: pipenv

I have setup project interpreter to the virtual environment created using pipenv

File > Default settings > Project interpreter

enter image description here

can see installed applications like djangorestframework

import from Django seems to be working but not from djangorestframework

enter image description here

same happens with other installed apps. Also installing from terminal within the PyCharm

pipenv install package_name

installs the application at root instead of virtualenv

2
have you tried closing the pycharm terminal and then reopening it. If you made the venv whilst the terminal was open it won't notice the new venv. Or click the rest_framwork, and Alt+Enter/Command+n and select install. - ktzr
I have even restarted my PC multiple times. The main issue is not with terminal window as I can use main terminal but the import. packages are not being detected even after setting interpreter - Anuj TBE
Have you tried creating new virtualenv and selecting it as the project interpreter? I usually use Conda Environments for Python 3.6 projects. - Nour Wolf
Regarding the other point of installing packages from Python terminal, you have to make sure PyCharm is activating the environment from Preferences > Tools > Terminal > Activate virtualenv (this works for Conda envs too). I install them using pip install djangorestframework for example. - Nour Wolf

2 Answers

2
votes

there are two settings path, both having settings for Project Interpreter

If you are on mac machine

  1. File > Default Settings > Project Interpreter
  2. PyCharm > preference > Project: <project_name> > Project Interpreter

You need to setup Project Interpreter in 2nd path.

0
votes

PyCharm (2018.1) does not support Pipenv at the time of writing this answer.

You can vote for that here https://youtrack.jetbrains.com/issue/PY-26492.