20

Today, I installed Pipenv via

pip install pipenv

As mentioned in the documentation I went to a test directory and created a new virtual environment using

pipenv shell

and tried to install a package via

pipenv install numpy

I got the following error message:

Installing numpy…
⠧
Error:  An error occurred while installing numpy!
Traceback (most recent call last):
  File "/Users/florian/.local/share/virtualenvs/test-bJfQ6Jzk/bin/pip", line 7, in <module>
    from pip._internal import main
ModuleNotFoundError: No module named 'pip._internal'

This error occurs even after reinstalling pipenv, deleting all files and recreate the environment. It also had no impact if I ran pipenv install numpy inside or outside the environment.

Python 3.6.3
Pipenv 11.10.1

Thank you in advance.

Train
  • 585
  • 1
  • 6
  • 20
  • Try force reinstalling `pipenv`. This error is encountered while updating `pip` too. `--force-reinstall` i.e. – Ganesh Kathiresan May 02 '18 at 13:05
  • Actually my bad, such an option ain't there. Try an update on all your packages and then reinstall, in their main repo, they say the same – Ganesh Kathiresan May 02 '18 at 13:07
  • I solved the problem by completely removing pip and reinstalling it. Thank you anyway for your fast responses! – Train May 02 '18 at 13:19
  • No problem. Edit your question to include the answer as others might benefit too. – Ganesh Kathiresan May 02 '18 at 16:12
  • @Train Any chance you could add the solution as an answer, then accept it? That helps keep the site tidy and avoids an answered question looking like it still needs an answer. – ash May 03 '18 at 22:42
  • Post the answer separately and will accept it in 9 hours. – Train May 04 '18 at 03:29
  • I have also recevied this when python was built from source with parts of 'site-packages' not having execute permissions for the user. – JerodG Sep 04 '18 at 17:47

5 Answers5

18

I have had the same issue (python 3.5/Ubuntu 16.04LTS). Reinstalling pip with:

sudo apt install python-pip python-pip3 --reinstall

didn't solve the issue with me.

What worked in my case was reinstalling pipenv itself, from pip:

sudo pip3 install pipenv --force-reinstall

If you are running python 2.x or if your system is different than mine, you can try to replace pip3 with pip in the command:

sudo pip install pipenv --force-reinstall
cedbeu
  • 1,919
  • 14
  • 24
4

Ubuntu 18.04, Python 3.6 :

Reinstalling pipenv did not work for me. Reinstall pip3 was the only issue, but

sudo apt install python3-pip

did not work too. Found a link to get pip3 in AskUbuntu.com which worked fine :

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
sudo python3 get-pip.py --force-reinstall
Romain Ferry
  • 49
  • 1
  • 2
2

After trying around for a while, I fully reinstalled pip. This solved the problem and everything is working now as expected.

Before providing the two commands, which solved the problem, I want to specify some things:

  • I'm on MacOS
  • python stands for python3 (added an alias for that, because I only use python3)
  • pip is on version 9 and NOT 10

Here are both commands:

sudo pip uninstall pip
sudo python get-pip.py
Train
  • 585
  • 1
  • 6
  • 20
2

The environment pipenv is trying to use may be corrupt for the current project. Removing it, and re-running pipenv install worked in my case. I am on Fedora 35, where the python virtualenvs are located in ~/.local/share/virtualenvs/, this may be different in your case.

find out which virtualenvs are on your disk:

ls ~/.local/share/virtualenvs/

remove the ones belonging to your project:

rm -rf ~/.local/share/virtualenvs/yourprojectname*
nylki
  • 498
  • 5
  • 15
2

I resolved problem using this command:

pip3 install pipenv --upgrade

feeela
  • 29,399
  • 7
  • 59
  • 71
kaxi1993
  • 4,535
  • 4
  • 29
  • 47