0

I'm trying to work with python in PyCharm, and set up a virtualenv for my project. What I imagine should be the way this works is that I set up a project to pull from a repository. It's a Django project, so I enable Django support. Setting up a pyenv is good hygiene, so I set the interpreter to use a pyenv. PyCharm supposedly includes pyenv, so I don't need to install it from my os, and I was under the impression that either Django came with it as well, or I could install it from PyCharm.

Instead of any of that working the way it seems like it should and has been described, pyenv doesn't appear to be installed:

$ pyenv
No command 'pyenv' found, did you mean:
 Command 'p7env' from package 'libnss3-tools' (main)
 Command 'pyvenv' from package 'python3-venv' (universe)
pyenv: command not found
$ virtualenv
The program 'virtualenv' is currently not installed. You can install it by typing:
sudo apt-get install virtualenv

Of course, the only reason I'm even caring about that is that going to Settings --> Project --> Project Interpreter to install new modules doesn't work, either with or without a Pycharm-created virtualenv. I made a post to the Jetbrains forums here, but I'm not expecting a response, as they seem almost completely abandoned.

Then I thought I'd try enabling Django support, so that I could at least get that module working. But instead it says that Django isn't installed; In the Run/Debug configuration, at the bottom it says Django is not importable, the django icon has an x on it, and of course, every import django statement is underlined in red, indicating it can't be imported. My versions are:

Ubuntu 15.10
PyCharm 5.0.4 
Python 2.7.10

So why does everything seem to be broken? What am I missing? If I have to install outside of pycharm, I don't really care, I'm just trying to set everything up the right way, so that nothing steps on anything else, and everything works as intended. Pycharm seemed to "volunteer" to handle everything, and I'm just trying to make that work. Using a pyenv seems to be what everyone recommends, and I'm just trying to do that. Any help at all would be appreciated.

  • 1
    PyCharm and pyenv work well together, but PyCharm does not include pyenv. You need to install it using one of the methods detailed at https://github.com/yyuu/pyenv – wjv Jan 10 '17 at 10:18

1 Answers1

0

To install Django on your virtualenv using pyenv please use the following command line:

pyenv activate <virtualenv_name>
pip install django

Or (for example if pyenv fails to activate your virtualenv due to some reason) it is possible to just execute pip using the full path:

<path_to_virtualenv_folder>/bin/pip install django

Then select the Python interpreter from your virtualenv as a project interpreter in PyCharm.

Normally PyCharm should be able to install packages, if it doesn't work please submit an issue to PyCharm tracker.

Dmitry Trofimov
  • 7,371
  • 1
  • 30
  • 34