Pip: ImportError: cannot import name 'sysconfig'

Created on 1 May 2018  ·  18Comments  ·  Source: pypa/pip

  • Pip version:
  • Python version: Python 3.6.5
  • Operating system: Ubuntu 18.04 LTS

Description:

This is my first time to install pip in my Ubuntu 18.04 LTS that I have just installed for serveral days. After using "curl" command to download the "get-pip.py" file and running the command "python3 get-pip.py", I got the error message. The error message is following.

What I've run:

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

python3 get-pip.py

The error message:

Traceback (most recent call last):
  File "get-pip.py", line 20649, in <module>
    main()
  File "get-pip.py", line 197, in main
    bootstrap(tmpdir=tmpdir)
  File "get-pip.py", line 82, in bootstrap
    import pip._internal
  File "/tmp/tmpaa4p6j0e/pip.zip/pip/_internal/__init__.py", line 42, in <module>
  File "/tmp/tmpaa4p6j0e/pip.zip/pip/_internal/cmdoptions.py", line 16, in <module>
  File "/tmp/tmpaa4p6j0e/pip.zip/pip/_internal/index.py", line 25, in <module>
  File "/tmp/tmpaa4p6j0e/pip.zip/pip/_internal/download.py", line 35, in <module>
  File "/tmp/tmpaa4p6j0e/pip.zip/pip/_internal/locations.py", line 10, in <module>
ImportError: cannot import name 'sysconfig'
downstream auto-locked support

Most helpful comment

It seems that python3-distutils is not installed.

sudo apt install python3-distutils

fix this issue.

All 18 comments

sysconfig is a standard library module. If you run python3 -c "import sysconfig" does it work, or does it give the same import error? If you get an import error, then your Python installation is somehow broken. If importing from Python does work, then we'll need to dig further to see why get-pip.py is failing to find the standard library on your machine.

The line giving the error is this one.

So to get the error we run:

python3 -c "from distutils import sysconfig as distutils_sysconfig"

Looks like your python3 installation is broken, then, as distutils is part of the stdlib and should be present. I wonder whether Ubuntu does something weird like not installing the whole stdlib by default? I wouldn't put it past them. It might be worth checking...

It seems that python3-distutils is not installed.

sudo apt install python3-distutils

fix this issue.

Yay Ubuntu :-(

Are you OK to close this issue in that case?

@Tarliton It works! Thank u very much!

@pfmoore I have sovled my problem! Thank's a lot!

I'm having the same issue on a fresh 18.04. I can import sysconfig without error - do you still recommend installing python3-distutils?

@ryanfox are you using pip3 or pip(2.7)? python3-distutils is for pip3. I also needed python3-setuptools to actually install a python library.

18.04 doesn't have 2.7 installed.

@ryanfox With the same situation, I can import sysconfig too, but I must install the python3-distutils so that I can use the pip3.

@ryanfox when you apt-get install pip, python2.7 will be installed and pip will be python 2.7 based. When you install pip3, it will be python3 based, yes.

I installed pip via get-pip.py:

$ python3.6 get-pip.py

Surely that doesn't install 2.7.

@ryanfox still - did you ensure the full python stdlib is present?

Python3.6 and Python3.6-dev are installed. I can successfully import sysconfig. Does that imply the full stdlib is present? I would have thought so.

For what it's worth, I apt installed python3-distutils and it's working for me now. I just thought it was strange, considering I _thought_ I had the full python installation.

Thanks, @Tarliton, your solution worked.

It seems that python3-distutils is not installed.

sudo apt install python3-distutils

fix this issue.

on windows ?

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings