Ubuntu 下安装 pip 遇到的问题

安装 pip 时产生错误 ImportError: cannot import name 'sysconfig' ,原因是缺少依赖,故记录之。

安装

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

报错

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'

解决

1
sudo apt install python3-distutils

References

ImportError: cannot import name ‘sysconfig’

Mastodon