Installed a package with Anaconda, can#39;t import in Python(用 Anaconda 安装了一个包,无法在 Python 中导入)
问题描述
原谅我,但我是 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 中导入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:用 Anaconda 安装了一个包,无法在 Python 中导入
基础教程推荐
- 比较两个文本文件以找出差异并将它们输出到新的文本文件 2022-01-01
- 在 Python 中将货币解析为数字 2022-01-01
- kivy 应用程序中的一个简单网页作为小部件 2022-01-01
- matplotlib 设置 yaxis 标签大小 2022-01-01
- 对多索引数据帧的列进行排序 2022-01-01
- 在 Django Admin 中使用内联 OneToOneField 2022-01-01
- Kivy 使用 opencv.调整图像大小 2022-01-01
- Python 中是否有任何支持将长字符串转储为块文字或折叠块的 yaml 库? 2022-01-01
- 究竟什么是“容器"?在蟒蛇?(以及所有的 python 容器类型是什么?) 2022-01-01
- Python,确定字符串是否应转换为 Int 或 Float 2022-01-01
