jupyter notebookでmoduleがimport出来ない
最近機械学習の勉強を初めて、不慣れながら独学で勉強をしていたところ、
jupyter notebook上でmoduleをimportしようとしたところうまくいかなかった。
発生している問題・エラーメッセージ
import pydotplus --------------------------------------------------------------------------- ModuleNotFoundError Traceback (most recent call last) <ipython-input-7-a9f11fc9cbbc> in <module>() ----> 1 import pydotplus ModuleNotFoundError: No module named 'pydotplus'
試したこと
他のサイトを確認していたところ、
!pip install pydotplus
によりjupyter notebookからダウンロードできることが分かったため、実行したところ、
Requirement already satisfied: pydotplus in ./.pyenv/versions/3.6.5/lib/python3.6/site-packages (2.0.2) Requirement already satisfied: pyparsing>=2.0.1 in ./.pyenv/versions/3.6.5/lib/python3.6/site-packages (from pydotplus) (2.4.7)
のように表示され、既にインストールが完了している?ことが分かった。
これ以降どうしたら良いのかわかりません。勉強不足で申し訳ないのですが、どなたか教えていただけると嬉しいです。
<追記>
aokikenichi様のコメントを参照させてもらい確認を行いました。
jupyter上でコマンドを打ったところ、
!pip list Package Version ------------------- ------- cycler 0.10.0 graphviz 0.14.1 japanize-matplotlib 1.1.2 kiwisolver 1.2.0 matplotlib 3.2.2 numpy 1.19.0 pip 20.1.1 pydotplus 2.0.2 pyparsing 2.4.7 python-dateutil 2.8.1 setuptools 39.0.1 six 1.15.0
!conda list ERROR: The install method you used for conda--probably either `pip install conda` or `easy_install conda`--is not compatible with using conda as an application. If your intention is to install conda as a standalone application, currently supported install methods include the Anaconda installer and the miniconda installer. You can download the miniconda installer from https://conda.io/miniconda.html.
condaのコマンドの方はこのように出てしまいました。
pipのlistにjupyterが入っておらず、jupyterの参照元が違っているのかと思いますので、現在参照先の調べ方と参照先へのpydotplusの追加方法を調べています。
<追記その2>
当サイトの他の投稿を閲覧していたところ、jupyterではなくコマンドプロンプトから開いたpythonからは正しくimportできるので、それぞれの参照先を確認したところ、
(コマンドプロンプト)
>>> import sys >>> sys.prefix '/Users/y.kuma/.pyenv/versions/3.6.5' >>> sys.executable '/Users/y.kuma/.pyenv/versions/3.6.5/bin/python'
(jupyter)
import sys sys.prefix sys.executable '/Users/y.kuma/.pyenv/versions/anaconda3-5.0.0/bin/python'
のような結果が出ました。これは恐らく参照しているanacondaのバージョンが違うためjupyterの方ではimport errorが起きるのだと思いますが、この推論は正しいでしょうか。また、恐らく異なる二つのanacondaが共存していると思いますが、どちらかを削除するのが良いでしょうか。
回答1件
あなたの回答
tips
プレビュー