23
19

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 5 years have passed since last update.

python3にpipがインストールされてないし、できなくてハマってる人へ

Last updated at Posted at 2018-07-25

こんな人向けの内容です

  1. デフォルトで用意されているはずのpython3.4以降でpipがない
  2. じゃあpipダウンロードしよう、けどインストールができない

以下「起きたこと」で悩んでいる人には、助けになるかな。と思います
※vagrant, centos7で実施しました。

起きたこと

上記①のパターン

$ python3 -m pip list
/usr/bin/python3: No module named pip

上記②のパターン

$ sudo curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
$ sudo python3 get-pip.py 
Traceback (most recent call last):
  File "get-pip.py", line 20651, 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
zipimport.ZipImportError: can't decompress data; zlib not available

もしくは、

$ sudo python3 get-pip.py
Traceback (most recent call last):
  File "get-pip.py", line 20651, 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/tmpfmhu0bvn/pip.zip/pip/_internal/__init__.py", line 42, in <module>
  File "/tmp/tmpfmhu0bvn/pip.zip/pip/_internal/cmdoptions.py", line 16, in <module>
  File "/tmp/tmpfmhu0bvn/pip.zip/pip/_internal/index.py", line 24, in <module>
  File "/tmp/tmpfmhu0bvn/pip.zip/pip/_internal/download.py", line 38, in <module>
  File "/tmp/tmpfmhu0bvn/pip.zip/pip/_internal/utils/glibc.py", line 3, in <module>
  File "/usr/local/lib/python3.7/ctypes/__init__.py", line 7, in <module>
    from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'

解決策

python3より、zlib-devellibffi-develをインストールしておく

$ sudo yum install -y zlib-devel
$ sudo yum install -y libffi-devel

## これを実行してからpython3をインストール
## すでにに実施してたら、もう一回やる(もちろん、wget、tar解凍は不要です)
$ sudo wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz
$ sudo tar xvzf Python-3.7.0.tgz
$ cd Python-3.7.0/
$ sudo ./configure
$ sudo make altinstall

思ったより、ハマってしまった。。。

23
19
2

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
23
19

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?