Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PyCharm & Pyenv local?

After I broke my Ubuntu precise with a Cython compilation I like to keep the system Python clean. I like to have 2.7.x & 3.4.x besides each other and used Pyenv to have a global default interpreter independent from the system python. Now I also want to define local interpreters on a per project basis, usually done with pyenv local. Unfortunately my favorite IDE PyCharm does only support pyenv global, the local .python-version files are obviously not recognized by PyCharm.

So I tried to use the pyenv global interpreter in PyCharm with ~/.pyenv/bin/python-local-exec which works but unfortunately is already deprecated. When I then tried to create a virtualenv from the pyenv Python 3 global interpreter, it throwed the follwing error:

The following command was executed:

virtualenv.py /home/barrios/code/so/venv

The error output of the command:

pyenv: `python-local-exec' is deprecated and will be removed in the next release.
       To upgrade: https://github.com/yyuu/pyenv/wiki/python-local-exec

Failed to import the site module
Traceback (most recent call last):
  File "/home/barrios/code/so/venv/lib/python3.4/site.py", line 67, in <module>
    import os
  File "/home/barrios/code/so/venv/lib/python3.4/os.py", line 634, in <module>
    from _collections_abc import MutableMapping
ImportError: No module named '_collections_abc'

Using base prefix '/home/barrios/.pyenv/versions/3.4.0b3'
New python executable in /home/barrios/code/so/venv/bin/python
ERROR: The executable /home/barrios/code/so/venv/bin/python is not functioning
ERROR: It thinks sys.prefix is '/home/barrios/.pyenv/bin' (should be '/home/barrios/code/so/venv')
ERROR: virtualenv is not compatible with this system or executable

As mentioned before, I don't want to install Python 3 into my Ubuntu system folders. Any ideas how to achieve that?

TNX a lot!

like image 253
barrios Avatar asked Mar 31 '14 08:03

barrios


People also ask

What is PyCharm used for?

PyCharm is a dedicated Python Integrated Development Environment (IDE) providing a wide range of essential tools for Python developers, tightly integrated to create a convenient environment for productive Python, web, and data science development.

Which is better Python or PyCharm?

PyCharm is the best IDE for python development. PyCharm offers various features: source code completion, support for unit testing, integration with Docker/GitLab/Git, ability to manage and configure virtual environments, auto-indentation, and re-factoring code with ease.

Is PyCharm a free?

PyCharm is a cross-platform IDE that provides consistent experience on the Windows, macOS, and Linux operating systems. PyCharm is available in three editions: Professional, Community, and Edu. The Community and Edu editions are open-source projects and they are free, but they have fewer features.

Is PyCharm an editor or IDE?

While text editors support many languages alongside Python, PyCharm is unique in the power it brings beyond Python. For example, PyCharm is a first-class web development IDE.


1 Answers

I'd suggest to use https://github.com/yyuu/pyenv-virtualenv to create virtualenv for a desired interpreter and then add it as a Python interpreter in PyCharm.

like image 74
Dmitry Trofimov Avatar answered Oct 22 '22 22:10

Dmitry Trofimov