問題描述
原諒我,但我是 python 新手.我已經使用安裝了一個包(theano)conda install theano
,當我輸入conda list
,包就存在了
Forgive me but I'm new to python. I've installed a package (theano) using
conda install theano
, and when I type conda list
, the package exists
但是,當我通過運行 python
進入 python 解釋器,并嘗試使用 import theano
導入它時,我得到一個錯誤:no module named theano",當我列出所有 python 模塊時,theano 不存在.
However, when I enter the python interpreter by running python
, and try to import it with import theano
, I get an error: "no module named theano", and when I list all python modules, theano doesn't exist.
我錯過了什么?
推薦答案
可能是因為您的計算機中安裝了多個 python 環境.當您執行 which python
時,您可能會在計算機中安裝本機 python.即 /usr/bin/python
Probably due to the fact you have multiply python envs installed in your computer.
when you do which python
you will probably get the native python installed in your computer. that is /usr/bin/python
您想使用安裝 Anaconda 時附帶的 Python.只需將 Anaconda 路徑添加到 $PATH
的開頭即可.(為了做到這一點,您可能需要編輯您的 ~/.bashrc
文件(或您的 shell 的等效文件),然后編輯 source ~/.bashrc
.
You want to use the Python that came when you installed Anaconda.
Just add Anaconda path to the beginning of your $PATH
.
(In order to do this you probably need to edit your ~/.bashrc
file (or the equivalent file for your shell) then source ~/.bashrc
.
下次你會運行 python
和 import theano
你會成功.
Next time you will go to will run python
and import theano
you'll succeed.
這篇關于用 Anaconda 安裝了一個包,無法在 Python 中導入的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!