LoginSignup
4
2

More than 3 years have passed since last update.

cloud9上でnumpyインストールに失敗した時の対処法

Last updated at Posted at 2019-07-17

困ったこと

numpyを使ったプログラムを実行したら
モジュールが入ってないよと叱られた。
「しょうがないなぁ」とpipでinstallしたらエラーになった…。
なんかpython2.7以降のやつ使ってね、みたいなエラー。

コマンド&実行結果
ec2-user:~/environment/deep-learning-from-scratch/ch03 (master) $ python 3.2.3.step_function.py 
Traceback (most recent call last):
  File "3.2.3.step_function.py", line 2, in <module>
    import numpy as np
ImportError: No module named numpy
ec2-user:~/environment/deep-learning-from-scratch/ch03 (master) $ pip install numpy
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Collecting numpy
  Using cached https://files.pythonhosted.org/packages/1f/c7/198496417c9c2f6226616cff7dedf2115a4f4d0276613bab842ec8ac1e23/numpy-1.16.4-cp27-cp27mu-manylinux1_x86_64.whl
Installing collected packages: numpy
ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/usr/lib64/python2.7/dist-packages/numpy-1.16.4.dist-info'
Consider using the `--user` option or check the permissions.

やったこと

調べてみると同じ状況の人がたくさんいたようで調べたらコマンドが見つかった。
試してみたら見事に成功!

コマンド
$ python3 -m pip install numpy --user

実際の結果はコチラ

実行結果

ec2-user:~/environment/deep-learning-from-scratch/ch03 (master) $ python3 -m pip install numpy --user
Collecting numpy
  Cache entry deserialization failed, entry ignored
  Downloading https://files.pythonhosted.org/packages/87/2d/e4656149cbadd3a8a0369fcd1a9c7d61cc7b87b3903b85389c70c989a696/numpy-1.16.4-cp36-cp36m-manylinux1_x86_64.whl (17.3MB)
    100% |████████████████████████████████| 17.3MB 75kB/s 
Installing collected packages: numpy
Successfully installed numpy-1.16.4
You are using pip version 9.0.3, however version 19.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
ec2-user:~/environment/deep-learning-from-scratch/ch03 (master) $ 

何がよかったの?

ポイントは2つ
 1.pipだけだとpython2を使おうとするのでpython3 -m を頭に入れてやった
 2.それだけだと権限エラーになるので「--user」を加えてやった ←ちなみにコレを使うことはは↑↑のエラーメッセージにも指摘されてた。。。

お世話になったURL

Qiita(Python3 > pipのインストール / numpyのインストール)
 https://qiita.com/7of9/items/d2625ed24d7124c50d99

teratali(Cloud9上にpythonのモジュール(numpyなど)をインストールしようとしても、pkg_resources.VersionConflictのエラーが出る)
https://teratail.com/questions/119338

~めでたしめでたし~

4
2
1

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
4
2