Andy Reagan
Andy Reagan

Reputation: 639

Pip installation in virtualenv broken

I get this error from the virtualenv's pip installation:

➜  myproject git:(master) ✗ pyenv/bin/pip --help
Failed checking if argv[0] is an import path entry
ValueError: character U+6e657970 is not in range [U+0000; U+10ffff]
Fatal Python error: no mem for sys.argv
ValueError: character U+6e657970 is not in range [U+0000; U+10ffff]

Current thread 0x00007fff767c5000 (most recent call first):
[1]    10941 abort      pyenv/bin/pip --help

The virtual env's python works, the system python and pip work (all python3).

Upvotes: 2

Views: 5466

Answers (3)

Dhruv Jimulia
Dhruv Jimulia

Reputation: 621

According to the pip documentation, you can install pip in a virtual environment by typing the following command when your virtual environment is activated:

python -m ensurepip --upgrade

For your information, ensurepip is an in-built Python module that serves the purpose of installing pip in your Python environment.

This solution can be used if you do not want to start a fresh new virtual environment and you want to retain your dependencies

Upvotes: 8

Deepak
Deepak

Reputation: 1545

First, try updating pip

pip install --upgrade pip

if this does not fix it, I would try uninstalling pip and then reinstall.

to remove try:

sudo pip uninstall pip

then install again.

pip install -U pip setuptools

also i am assuming your are using linux or mac. on windows commands differ.

Upvotes: -2

Andy Reagan
Andy Reagan

Reputation: 639

Turns out that virtualenv hard links the python executable to the system python, so that when I upgraded python, it got out of line with the virtual env's pip installation.

Posting here for other to find, in case this happens to them.

Solution is to wipe the pyenv folder, and reinstall a fresh virtualenv (if you've been using a requirements.txt file, this is what the virtual env is designed to do!

Upvotes: 10

Related Questions