質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Cygwin

Cygwinは、Unixのような環境を、Windows上で構築させるコマンドラインインターフェースです。

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

Q&A

1回答

3637閲覧

(cygwin)python numpyがimportできない

mercurian-teto

総合スコア75

Cygwin

Cygwinは、Unixのような環境を、Windows上で構築させるコマンドラインインターフェースです。

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

0グッド

0クリップ

投稿2018/12/25 05:37

編集2018/12/25 10:28

cygwinでnumpyがインポートできなくて困っています。
下にインストールしたときの手順をいいます。

gnupackを以下のサイトでダウンロードしました。
gnupack pretest 2018.06.10 をインストールしました。
https://ja.osdn.net/projects/gnupack/
そのあと、cygwinと実行し、apt-cyg install libgif7のコマンドを実行しました。

# Host: (パソコン名なので伏せておきます) | User: public_user | Time: 2018-12-25 14:09:31 # Path: /desktop # # cd ✔ Success (retv = 0) # Host: (パソコン名なので伏せておきます) | User: public_user | Time: 2018-12-25 14:09:38 # Path: ~ # # apt-cyg install libgif7 Warning: /etc/setup/installed.db version is less than 3. Before continuing, recommend to execute below command: apt-cyg dist-upgrade Do you continue? [y/N] y continue Cache directory is /setup Mirror is http://ftp.jaist.ac.jp/pub/cygwin chmod: '/setup/.apt-cyg' のパーミッションを変更しています: Invalid argument Error: cannot initialize directory /setup/.apt-cyg ✗ Failure (retv = 1) # Host: (パソコン名なので伏せておきます) | User: public_user | Time: 2018-12-25 14:10:37 # Path: ~ # # apt-cyg install libgif7 Warning: /etc/setup/installed.db version is less than 3. Before continuing, recommend to execute below command: apt-cyg dist-upgrade Do you continue? [y/N] y continue Cache directory is /setup Mirror is http://ftp.jaist.ac.jp/pub/cygwin /tmp/tmp.TDjSGA9YTO 100%[===================>] 1.29K --.-KB/s 時間 0.05s 2018-12-25 14:10:56 URL:https://cygwin.com/key/pubring.asc [1324/1324] -> "/tmp/tmp.TDjSGA9YTO" [1] TRUSTEDKEY_CYGWIN: OK gpg: *警告*: homedir 「/setup/.apt-cyg」の安全でない許可 gpg: *警告*: セキュアでないメモリーを使用しています! gpg: 詳細はhttp://www.gnupg.org/documentation/faq.htmlをご覧ください gpg: 鍵リング「/setup/.apt-cyg/secring.gpg」ができました gpg: WARNING: unable to restore permissions to `/setup/.apt-cyg/pubring.gpg': Invalid argumentgpg: 鍵676041BA: 公開鍵"Cygwin <cygwin@cygwin.com>"をインポートしました gpg: 処理数の合計: 1 gpg: インポート: 1 /tmp/tmp.TDjSGA9YTO 100%[===================>] 1.66K --.-KB/s 時間 0s 2018-12-25 14:10:58 URL:http://cygwinports.org/ports.gpg [1702/1702] -> "/tmp/tmp.TDjSGA9YTO" [1] TRUSTEDKEY_CYGWINPORTS: OK gpg: *警告*: homedir 「/setup/.apt-cyg」の安全でない許可 gpg: *警告*: セキュアでないメモリーを使用しています! gpg: 詳細はhttp://www.gnupg.org/documentation/faq.htmlをご覧ください gpg: WARNING: unable to restore permissions to `/setup/.apt-cyg/pubring.gpg': Invalid argumentgpg: 鍵66EE1F94: 公開鍵"Yaakov Selkowitz (Cygwin Ports) <yselkowitz@users.sourceforge.net>"をインポートしました gpg: 処理数の合計: 1 gpg: インポート: 1 Updating setup.ini setup.bz2 100%[===================>] 3.60M 9.64MB/s 時間 0.4s 2018-12-25 14:11:00 URL:http://ftp.jaist.ac.jp/pub/cygwin/x86/setup.bz2 [3770605/3770605] -> "setup.bz2" [1] setup.bz2.sig 100%[===================>] 72 --.-KB/s 時間 0s 2018-12-25 14:11:00 URL:http://ftp.jaist.ac.jp/pub/cygwin/x86/setup.bz2.sig [72/72] -> "setup.bz2.sig" [1] signature verified: setup.bz2.sig bunzip2: I/O or other error, bailing out. Possible reason follows. bunzip2: Invalid argument Input file = setup.bz2, output file = setup bunzip2: Deleting output file setup, if it exists. setup.ini 100%[===================>] 14.71M 5.47MB/s 時間 2.7s 2018-12-25 14:11:04 URL:http://ftp.jaist.ac.jp/pub/cygwin/x86/setup.ini [15421978/15421978] -> "setup.ini" [1] setup.ini.sig 100%[===================>] 72 --.-KB/s 時間 0s 2018-12-25 14:11:04 URL:http://ftp.jaist.ac.jp/pub/cygwin/x86/setup.ini.sig [72/72] -> "setup.ini.sig" [1] signature verified: setup.ini.sig Updated setup.ini Installing libgif7 Found package libgif7 libgif7-5.1.4-1.tar 100%[===================>] 14.64K --.-KB/s 時間 0.002s 2018-12-25 14:11:05 URL:http://ftp.jaist.ac.jp/pub/cygwin/x86/release/giflib/libgif7/libgif7-5.1.4-1.tar.xz [14992/14992] -> "libgif7-5.1.4-1.tar.xz" [1] hash_check: sha512sum: libgif7-5.1.4-1.tar.xz: OK Unpacking... gzip: /etc/setup/libgif7.lst.gz: Invalid argument Package libgif7 requires the following packages, installing: cygwin Package cygwin is already installed, skipping Running postinstall scripts Warning: Schema “org.gnome.system.locale” has path “/system/locale/”. Paths starting with “/apps/”, “/desktop/” or “/system/” are deprecated. Warning: Schema “org.gnome.system.proxy” has path “/system/proxy/”. Paths starting with “/apps/”, “/desktop/” or “/system/” are deprecated. Warning: Schema “org.gnome.system.proxy.http” has path “/system/proxy/http/”. Paths starting with “/apps/”, “/desktop/” or “/system/” are deprecated. Warning: Schema “org.gnome.system.proxy.https” has path “/system/proxy/https/”. Paths starting with “/apps/”, “/desktop/” or “/system/” are deprecated. Warning: Schema “org.gnome.system.proxy.ftp” has path “/system/proxy/ftp/”. Paths starting with “/apps/”, “/desktop/” or “/system/” are deprecated. Warning: Schema “org.gnome.system.proxy.socks” has path “/system/proxy/socks/”. Paths starting with “/apps/”, “/desktop/” or “/system/” are deprecated. Warning: Schema “org.gnome.system.locale” has path “/system/locale/”. Paths starting with “/apps/”, “/desktop/” or “/system/” are deprecated. Warning: Schema “org.gnome.system.proxy” has path “/system/proxy/”. Paths starting with “/apps/”, “/desktop/” or “/system/” are deprecated. Warning: Schema “org.gnome.system.proxy.http” has path “/system/proxy/http/”. Paths starting with “/apps/”, “/desktop/” or “/system/” are deprecated. Warning: Schema “org.gnome.system.proxy.https” has path “/system/proxy/https/”. Paths starting with “/apps/”, “/desktop/” or “/system/” are deprecated. Warning: Schema “org.gnome.system.proxy.ftp” has path “/system/proxy/ftp/”. Paths starting with “/apps/”, “/desktop/” or “/system/” are deprecated. Warning: Schema “org.gnome.system.proxy.socks” has path “/system/proxy/socks/”. Paths starting with “/apps/”, “/desktop/” or “/system/” are deprecated. Warning: Schema “org.gnome.system.locale” has path “/system/locale/”. Paths starting with “/apps/”, “/desktop/” or “/system/” are deprecated. Warning: Schema “org.gnome.system.proxy” has path “/system/proxy/”. Paths starting with “/apps/”, “/desktop/” or “/system/” are deprecated. Warning: Schema “org.gnome.system.proxy.http” has path “/system/proxy/http/”. Paths starting with “/apps/”, “/desktop/” or “/system/” are deprecated. Warning: Schema “org.gnome.system.proxy.https” has path “/system/proxy/https/”. Paths starting with “/apps/”, “/desktop/” or “/system/” are deprecated. Warning: Schema “org.gnome.system.proxy.ftp” has path “/system/proxy/ftp/”. Paths starting with “/apps/”, “/desktop/” or “/system/” are deprecated. Warning: Schema “org.gnome.system.proxy.socks” has path “/system/proxy/socks/”. Paths starting with “/apps/”, “/desktop/” or “/system/” are deprecated. Warning: Schema “org.gnome.system.locale” has path “/system/locale/”. Paths starting with “/apps/”, “/desktop/” or “/system/” are deprecated. (Warning: Schema “org.gnome.system.locale” has path “/system/locale/”. Paths starting with “/apps/”, “/desktop/” or “/system/” are deprecated.と類似したエラーメッセージが何回も現れました。) Package libgif7 installed ✔ Success (retv = 0) # Host: (パソコン名なので伏せておきます) | User: public_user | Time: 2018-12-25 14:11:32 # Path: ~ # # cd - /desktop ✔ Success (retv = 0) # Host: (パソコン名なので伏せておきます) | User: public_user | Time: 2018-12-25 14:11:47 # Path: /desktop # # cd

その次に
cdと打ち込み、apt-cyg install python2-numpy
Do you continue?をy
何回やっても以下のエラーが出てきました。

Warning: /etc/setup/installed.db version is less than 3. Before continuing, recommend to execute below command: apt-cyg dist-upgrade Do you continue? [y/N] N

ここでyと入力しました。
すると次のようになりました。

abort Warning: some required packages did not install, continuing Package liblapack0 installed Package python2 is already installed, skipping Package python2-setuptools is already installed, skipping Package python2-numpy installed ✔ Success (retv = 0)

その後cygwinでpythonを実行しました。

# Host: (ここはパソコン名なので伏せておきます) | User: public_user | Time: 2018-12-25 14:19:22 # Path: /c # # cd ✔ Success (retv = 0) # Host:(ここはパソコン名なので伏せておきます) | User: public_user | Time: 2018-12-25 14:19:26 # Path: ~ # # python Python 2.7.14 (default, Oct 31 2017, 21:15:21) [GCC 6.4.0] on cygwin Type "help", "copyright", "credits" or "license" for more information. >>> import numpy Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.7/site-packages/numpy/__init__.py", line 142, in <module> from . import add_newdocs File "/usr/lib/python2.7/site-packages/numpy/add_newdocs.py", line 13, in <module> from numpy.lib import add_newdoc File "/usr/lib/python2.7/site-packages/numpy/lib/__init__.py", line 8, in <module> from .type_check import * File "/usr/lib/python2.7/site-packages/numpy/lib/type_check.py", line 11, in <module> import numpy.core.numeric as _nx File "/usr/lib/python2.7/site-packages/numpy/core/__init__.py", line 14, in <module> from . import multiarray ImportError: No such file or directory

また、gnupack-pretest_devel-2018.06.10\home以下の
.bashrcのファイルの最後の行に
PATH=/usr/lib/lapack:$PATHと書き込みました。
あるテキストに沿ってインストールしたのですが、
numpyがインポートできなくて困っています。
解決方法を教えてくださいませんか。
#追記
追記の続きは回答者の欄にかいてあります。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

coco_bauer

2018/12/25 06:00

質問に書かれているURLのページを見ると、「開発者によるgnupackの動作テストは、Windows 7のみです。Windows 8.1/8/Vista/XPに関して、動作する可能性はありますが、動作テストの対象外です。」との記述がありますが、Windows7のマシンで操作しているのでしょうか?
mercurian-teto

2018/12/25 06:26 編集

windows10で一様動かしていますが、 周りの人はちゃんとimport numpyもできるそうです。 (機種もOSも同じです。) また、import以外の基本的なコードは使えます。
guest

回答1

0

質問者です。追記がかけないので特別にここに追記を表記しています。
#追記1
また、先ほどのエラーで

Warning: /etc/setup/installed.db version is less than 3. Before continuing, recommend to execute below command: apt-cyg dist-upgrade Do you continue? [y/N] N

とありましたが、ここでNを選択していざapt-cyg dist -upgradeを実行してみると、
続行するには何かキーを押してくださいと表示され次に下の画像のような
画面が表示されます。
イメージ説明
何を選択するのかがわかりません。
そもそもapt-cyg dist -upgradeはpythonに含まれるパッケージをすべてアップグレードするという認識しかないため、上記のウェブサイトを選択する箇所に対して全くわかりません。

#追記2
もう一度numpyをインストールする手順を実行してみたところ
次のようになりました。

# Host: LAPTOP-O6FVFD2G | User: public_user | Time: 2018-12-25 14:42:03 # Path: /desktop # # cd ✔ Success (retv = 0) # Host: LAPTOP-O6FVFD2G | User: public_user | Time: 2018-12-25 14:42:51 # Path: ~ # # apt-cyg install python2-numpy Warning: /etc/setup/installed.db version is less than 3. Before continuing, recommend to execute below command: apt-cyg dist-upgrade Do you continue? [y/N] y continue Cache directory is /setup Mirror is http://ftp.jaist.ac.jp/pub/cygwin cp: `setup.ini~' のパーミッションを保存しています: Invalid argument cp: `setup.ini.sig~' のパーミッションを保存しています: Invalid argument cp: `setup.bz2.sig~' のパーミッションを保存しています: Invalid argument Updating setup.ini setup.bz2 100%[===================>] 3.60M 9.31MB/s 時間 0.4s 2018-12-25 14:43:09 URL:http://ftp.jaist.ac.jp/pub/cygwin/x86/setup.bz2 [3770605/3770605] -> "setup.bz2" [1] signature verified: setup.bz2.sig bunzip2: I/O or other error, bailing out. Possible reason follows. bunzip2: Invalid argument Input file = setup.bz2, output file = setup bunzip2: Deleting output file setup, if it exists. signature verified: setup.ini.sig Updated setup.ini Package python2-numpy is already installed, skipping ✔ Success (retv = 0) # Host: LAPTOP-O6FVFD2G | User: public_user | Time: 2018-12-25 14:43:11 # Path: ~ # # python Python 2.7.14 (default, Oct 31 2017, 21:15:21) [GCC 6.4.0] on cygwin Type "help", "copyright", "credits" or "license" for more information. >>> import numpy Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.7/site-packages/numpy/__init__.py", line 142, in <module> from . import add_newdocs File "/usr/lib/python2.7/site-packages/numpy/add_newdocs.py", line 13, in <module> from numpy.lib import add_newdoc File "/usr/lib/python2.7/site-packages/numpy/lib/__init__.py", line 8, in <module> from .type_check import * File "/usr/lib/python2.7/site-packages/numpy/lib/type_check.py", line 11, in <module> import numpy.core.numeric as _nx File "/usr/lib/python2.7/site-packages/numpy/core/__init__.py", line 14, in <module> from . import multiarray ImportError: No such file or directory >>>

#追記3
環境は
windows 10 proです
#追記4
以前はvisualstudioでpythoをインストールしていましたが、
いまは削除しています。

#追記5
インポートディレクトリを調べてみました。
下のURLを参考にしました。
https://teratail.com/questions/80680
実行結果は以下の通りです。

>>> from pprint import pprint >>> import sys >>> print(sys.version_info) sys.version_info(major=2, minor=7, micro=14, releaselevel='final', serial=0) >>> pprint(sys.path) ['', '/usr/local/lib/python2.7/site-packages', '/usr/local/lib/python2.7/site-packages/pip-10.0.1-py2.7.egg', '/usr/lib/python27.zip', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-cygwin', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/lib/python2.7/site-packages']

#追記6
先述したとおり、apt-up cyg upgradeを実行してくださいという警告がありました。

Warning: /etc/setup/installed.db version is less than 3. Before continuing, recommend to execute below command: apt-cyg dist-upgrade Do you continue? [y/N] N

apt-cyg dist-upgradeを実行した後、再度先述したとおり、numpyをインストールするコマンドを実行して
numpyが使えるかどうか確認を取りましたが、依然エラーが発生してしまいます。

Host: LAPTOP-O6FVFD2G | User: public_user | Time: 2018-12-25 23:12:26 # Path: /desktop # # apt-cyg install python2-numpy Cache directory is /setup Mirror is http://ftp.jaist.ac.jp/pub/cygwin cp: `setup.ini~' のパーミッションを保存しています: Invalid argument cp: `setup.ini.sig~' のパーミッションを保存しています: Invalid argument cp: `setup.bz2.sig~' のパーミッションを保存しています: Invalid argument Updating setup.ini setup.bz2 100%[===================>] 3.60M 10.5MB/s 時間 0.3s 2018-12-25 23:13:09 URL:http://ftp.jaist.ac.jp/pub/cygwin/x86/setup.bz2 [3770862/3770862] -> "setup.bz2" [1] setup.bz2.sig 100%[===================>] 72 --.-KB/s 時間 0s 2018-12-25 23:13:10 URL:http://ftp.jaist.ac.jp/pub/cygwin/x86/setup.bz2.sig [72/72] -> "setup.bz2.sig" [1] signature verified: setup.bz2.sig bunzip2: I/O or other error, bailing out. Possible reason follows. bunzip2: Invalid argument Input file = setup.bz2, output file = setup bunzip2: Deleting output file setup, if it exists. setup.ini 100%[===================>] 14.71M 11.1MB/s 時間 1.3s 2018-12-25 23:13:17 URL:http://ftp.jaist.ac.jp/pub/cygwin/x86/setup.ini [15421987/15421987] -> "setup.ini" [1] setup.ini.sig 100%[===================>] 72 --.-KB/s 時間 0s 2018-12-25 23:13:18 URL:http://ftp.jaist.ac.jp/pub/cygwin/x86/setup.ini.sig [72/72] -> "setup.ini.sig" [1] signature verified: setup.ini.sig Updated setup.ini Package python2-numpy is already installed, skipping ✔ Success (retv = 0) # Host: LAPTOP-O6FVFD2G | User: public_user | Time: 2018-12-25 23:13:21 # Path: /desktop # # python Python 2.7.14 (default, Oct 31 2017, 21:15:21) [GCC 6.4.0] on cygwin Type "help", "copyright", "credits" or "license" for more information. >>> import numpy Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.7/site-packages/numpy/__init__.py", line 142, in <module> from . import add_newdocs File "/usr/lib/python2.7/site-packages/numpy/add_newdocs.py", line 13, in <module> from numpy.lib import add_newdoc File "/usr/lib/python2.7/site-packages/numpy/lib/__init__.py", line 8, in <module> from .type_check import * File "/usr/lib/python2.7/site-packages/numpy/lib/type_check.py", line 11, in <module> import numpy.core.numeric as _nx File "/usr/lib/python2.7/site-packages/numpy/core/__init__.py", line 14, in <module> from . import multiarray ImportError: No such file or directory >>> installed.db version is less than 3.

投稿2018/12/25 05:53

編集2018/12/25 14:20
mercurian-teto

総合スコア75

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問