用 Anaconda 安装了一个包,无法在 Python 中导入 [英] Installed a package with Anaconda, can't import in Python

查看:127
本文介绍了用 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.

下次你会运行 pythonimport theano 你会成功.

Next time you will go to will run python and import theano you'll succeed.

这篇关于用 Anaconda 安装了一个包,无法在 Python 中导入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆