Skip to content
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 · 18 comments
Closed

ImportError: cannot import name 'sysconfig' #5356

fengberlin opened this issue May 1, 2018 · 18 comments
Labels
auto-locked Outdated issues that have been locked by automation project: <downstream> When the cause/effect is related to redistributors type: support User Support

Comments

@fengberlin
Copy link

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
Copy link
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
Copy link

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
Copy link
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
Copy link

Tarliton commented May 1, 2018

It seems that python3-distutils is not installed.

sudo apt install python3-distutils

fix this issue.

@pfmoore
Copy link
Member

pfmoore commented May 1, 2018

Yay Ubuntu :-(

Are you OK to close this issue in that case?

@fengberlin
Copy link
Author

@Tarliton It works! Thank u very much!

@fengberlin
Copy link
Author

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

@ryanfox
Copy link

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
Copy link

@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
Copy link

ryanfox commented May 16, 2018

18.04 doesn't have 2.7 installed.

@fengberlin
Copy link
Author

@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
Copy link

@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
Copy link

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
Copy link
Contributor

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

@ryanfox
Copy link

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.

@pradyunsg pradyunsg added the project: <downstream> When the cause/effect is related to redistributors label May 21, 2018
@pSnehanshu
Copy link

Thanks, @Tarliton, your solution worked.

@LyonOconner
Copy link

It seems that python3-distutils is not installed.

sudo apt install python3-distutils

fix this issue.

on windows ?

@lock
Copy link

lock bot commented May 31, 2019

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.

@lock lock bot added the auto-locked Outdated issues that have been locked by automation label May 31, 2019
@lock lock bot locked as resolved and limited conversation to collaborators May 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation project: <downstream> When the cause/effect is related to redistributors type: support User Support
Projects
None yet
Development

No branches or pull requests

10 participants