17
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

`ModuleNotFoundError: No module named 'distutils.sysconfig'`。2018-05-07

Last updated at Posted at 2018-05-07

内容

Ubuntu 16.04 などで Python 3.6 を使いたい場合、 ppa:jonathonf/python-3.6 を利用することがあります。
2018/05/03 にそのパッケージが3.6.5に置き換わったようで、そちらにUpgradeしたらエラーが出るようになりました。

たとえば virtualenv なら

Original exception was:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/virtualenv.py", line 25, in <module>
    import distutils.sysconfig
ModuleNotFoundError: No module named 'distutils.sysconfig'

とか

pip だとちょっと内容が違いますが(python 3.6 で作ったvenv内)

Traceback (most recent call last):
  File "/home/XXX/venv/bin/pip", line 7, in <module>
    from pip._internal import main
  File "/home/XXX/venv/lib/python3.6/site-packages/pip/_internal/__init__.py", line 42, in <module>
    from pip._internal import cmdoptions
  File "/home/XXX/venv/lib/python3.6/site-packages/pip/_internal/cmdoptions.py", line 16, in <module>
    from pip._internal.index import (
  File "/home/XXX/venv/lib/python3.6/site-packages/pip/_internal/index.py", line 25, in <module>
    from pip._internal.download import HAS_TLS, is_url, path_to_url, url_to_path
  File "/home/XXX/venv/lib/python3.6/site-packages/pip/_internal/download.py", line 35, in <module>
    from pip._internal.locations import write_delete_marker_file
  File "/home/XXX/venv/lib/python3.6/site-packages/pip/_internal/locations.py", line 10, in <module>
    from distutils import sysconfig as distutils_sysconfig
  File "/home/XXX/venv/lib/python3.6/distutils/__init__.py", line 25, in <module>
    from distutils import dist, sysconfig
ImportError: cannot import name 'dist'

など。

その解決方法を記します。

解決方法

python3-distutils のインストールで解決
参考: https://github.com/pypa/pip/issues/5367

% sudo apt-get install python3-distutils

まとめ

python3-distutils のインストールで解決で解決しました。

17
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
17
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?