問題描述
我嘗試安裝 Anaconda 的 Theano.它可以工作,但是當我輸入 python -i 時,import theano
顯示 No module named 'theano'
.我是否需要切換另一個 Python 解釋器,如何?另外,對于 conda 安裝的包,如果我不重復安裝它們,我可以在 Python 中找到嗎?Python 與 Anaconda 的 Python 有什么關系?謝謝!!!
I try to install Theano by Anaconda. It works, but when I enter the python -i, import theano
shows No module named 'theano'
. Do I need to switch another interpreter of Python, how? Also, for the packages installed by conda, if I don't double install them, can I find in Python? How is Python related to Python by Anaconda? Thanks!!!
推薦答案
我遇到了類似的問題,嘗試安裝 folium.如果您使用的是Anaconda:
I had have a similar issue, trying to install folium. If you are using the Anaconda:
當你使用conda install -c conda-forge folium
安裝時,包會放在:
When you install using conda install -c conda-forge folium
, the package will be placed in:
./anaconda3/envs/[name env]/lib/python3.7/site-packages/folium
當您使用 pip 安裝時(激活 anaconda env),pip install folium
,包將被放置在:
When you install using pip (with a anaconda env activated), pip install folium
, the package will be placed in:
./anaconda3/lib/python3.7/site-packages/folium
Python首先使用sites-packages作為手動構建python包的目標目錄.當您從源代碼構建和安裝 python 包時(使用 distutils,可能通過執行 python setup.py install ),默認情況下您會在 site-packages 中找到已安裝的模塊.
Python use first the sites-packages as the target directory of manually built python packages. When you build and install python packages from source (using distutils, probably by executing python setup.py install ), you will find the installed modules in site-packages by default.
在這種情況下,您有兩個位置:/anaconda3/lib/python3.7/site-packages/
和 /anaconda3/envs/[name env]/lib/python3.7/site-packages/
.
In this case you have two places: /anaconda3/lib/python3.7/site-packages/
and /anaconda3/envs/[name env]/lib/python3.7/site-packages/
.
首先,這些模塊將在 /anaconda3/lib/python3.7/site-packages/
中默認可用.有時(我真的不知道為什么)sites-packages conda env 中的模塊在不導出 PATH 的情況下無法自動導入.
First the modules will be available as default in /anaconda3/lib/python3.7/site-packages/
. Sometimes (and I really don't know why) the modules inside sites-packages conda env are not available to import automatically without export the PATH.
所以,要解決這個問題,你有兩個選擇:
So, to solve this issue, you have 2 options:
使用
pip install folium
安裝并導入 folium(不需要通過 conda install 安裝),或
Installing using
pip install folium
and import folium (don't need install by conda install), or
在 conda install 之后,運行 conda init
,關閉終端并打開一個新終端.所以,嘗試再次導入.
After conda install , run conda init
, close the terminal and open a new one. So, try to import again.
這里是一些關于使用 pip inconda 環境.
Here are some tips about use a pip in a conda-environment.
這篇關于Conda安裝的包,Python找不到的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!