[Tutor] pip stopped working gives error

Zachary Ware zachary.ware+pytut at gmail.com
Thu May 3 16:40:32 EDT 2018

On Thu, May 3, 2018 at 2:10 PM, Jim <jf_byrnes at comcast.net> wrote:
> I have python 3.6 installed in a virtual environment on Mint 18. Today I
> wanted to use pip and got this error when I tried to use it.
>  (env36) jfb at jims-mint18 ~ $ pip help
> Traceback (most recent call last):
>   File "/home/jfb/EVs/env36/bin/pip", line 7, in <module>
>     from pip import main
>   File "/home/jfb/EVs/env36/lib/python3.6/site-packages/pip/__init__.py",
> line 43, in <module>
>     from pip.utils import get_installed_distributions, get_prog
>   File
> "/home/jfb/EVs/env36/lib/python3.6/site-packages/pip/utils/__init__.py",
> line 23, in <module>
>     from pip.locations import (
>   File "/home/jfb/EVs/env36/lib/python3.6/site-packages/pip/locations.py",
> line 9, in <module>
>     from distutils import sysconfig
> ImportError: cannot import name 'sysconfig'
> I searched for sysconfig and found this:
> /home/jfb/EVs/env36/lib/python3.6/site-packages/pip/_vendor/distlib/_backport/__pycache__/sysconfig.cpython-36.pyc
> /home/jfb/EVs/env36/lib/python3.6/site-packages/pip/_vendor/distlib/_backport/sysconfig.cfg
> /home/jfb/EVs/env36/lib/python3.6/site-packages/pip/_vendor/distlib/_backport/sysconfig.py
> The results seem to be the same as when I searched a python 3.5 virtual
> environment I have setup.
> It has worked in the past as I have installed pylint and pykeyboard with it.
> As I type this I just remembered Mint updated python 3.6 earlier today.
> So now I suspect the update is involved. Has anyone else experienced this
> and know how to fix it?

First, try a clean venv (python3.6 -m venv venv && ./venv/bin/pip help).

If that works, then one of the nice things about virtual environments
is that they're easy to recreate, especially if you have a handy list
of the packages you want, say in a `requirements.txt` file.  Then all
you need to do is `python3.6 -m venv --clear /path/to/your/old/venv &&
/path/to/your/old/venv/bin/pip install -r requirements.txt`.  If you
don't already have a requirements.txt file, you can create one by
listing the names of the packages you want in a file, each on its own


More information about the Tutor mailing list