New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: cannot import name 'sysconfig' #5356

Closed
fengberlin opened this Issue May 1, 2018 · 17 comments

Comments

Projects
None yet
9 participants
@fengberlin

fengberlin commented May 1, 2018

  • 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'
@pfmoore

This comment has been minimized.

Member

pfmoore commented May 1, 2018

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.

@Tarliton

This comment has been minimized.

Tarliton commented May 1, 2018

The line giving the error is this one.

So to get the error we run:

python3 -c "from distutils import sysconfig as distutils_sysconfig"
@pfmoore

This comment has been minimized.

Member

pfmoore commented May 1, 2018

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...

@Tarliton

This comment has been minimized.

Tarliton commented May 1, 2018

It seems that python3-distutils is not installed.

sudo apt install python3-distutils

fix this issue.

@pfmoore

This comment has been minimized.

Member

pfmoore commented May 1, 2018

Yay Ubuntu :-(

Are you OK to close this issue in that case?

@fengberlin

This comment has been minimized.

fengberlin commented May 1, 2018

@Tarliton It works! Thank u very much!

@fengberlin

This comment has been minimized.

fengberlin commented May 1, 2018

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

@ryanfox

This comment has been minimized.

ryanfox commented May 16, 2018

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

@lukastribus

This comment has been minimized.

lukastribus commented May 16, 2018

@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.

@ryanfox

This comment has been minimized.

ryanfox commented May 16, 2018

18.04 doesn't have 2.7 installed.

@fengberlin

This comment has been minimized.

fengberlin commented May 16, 2018

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

@lukastribus

This comment has been minimized.

lukastribus commented May 16, 2018

@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.

@ryanfox

This comment has been minimized.

ryanfox commented May 21, 2018

I installed pip via get-pip.py:

$ python3.6 get-pip.py

Surely that doesn't install 2.7.

@RonnyPfannschmidt

This comment has been minimized.

Contributor

RonnyPfannschmidt commented May 21, 2018

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

@ryanfox

This comment has been minimized.

ryanfox commented May 21, 2018

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.

@pSnehanshu

This comment has been minimized.

pSnehanshu commented Sep 30, 2018

Thanks, @Tarliton, your solution worked.

@LyonOconner

This comment has been minimized.

LyonOconner commented Nov 1, 2018

It seems that python3-distutils is not installed.

sudo apt install python3-distutils

fix this issue.

on windows ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment