bash anaconda ipython 的路径是否已损坏?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20951424/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is path broken for anaconda ipython?
提问by Pippi
I wish to use anaconda distribution of ipython, but typing ipython
at the terminal produces an error message:
我希望使用 ipython 的 anaconda 发行版,但ipython
在终端输入会产生错误消息:
Traceback (most recent call last):
File "/usr/local/bin/ipython", line 5, in <module>
from pkg_resources import load_entry_point
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2603, in <module>
working_set.require(__requires__)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 666, in require
needed = self.resolve(parse_requirements(requirements))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 565, in resolve
raise DistributionNotFound(req) # XXX put more info here
pkg_resources.DistributionNotFound: ipython==0.13.1
Adding PATH to .bash_profile
as below produces the same error message. Asking which python
produces //anaconda/bin/python
, and which ipython
produces /usr/local/bin/ipython
. How can I fix this such that ipython
launches anaconda ipython?
如下添加 PATH.bash_profile
会产生相同的错误消息。问which python
产生//anaconda/bin/python
,which ipython
产生/usr/local/bin/ipython
。如何解决此问题以ipython
启动 anaconda ipython?
# MacPorts Installer addition on 2012-11-03_at_23:50:01: adding an appropriate PATH variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
# Finished adapting your PATH environment variable for use with MacPorts.
# Add colors to terminal
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
# added by Anaconda 1.6.1 installer
export PATH="//anaconda/bin:$PATH"
export PATH=/anaconda//bin/isympy:$PATH
# added to Homebrew: bad command
export PATH=/usr/local/bin:$PATH
Update: I updated anaconda and ipython using conda update
as suggested, but still get the same error message.
更新:我conda update
按照建议更新了 anaconda 和 ipython ,但仍然收到相同的错误消息。
Update 2: Thanks for all the suggestions. I modified /usr/local/bin/ipython
as follows:
更新 2:感谢您的所有建议。我修改/usr/local/bin/ipython
如下:
#!//anaconda/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 'ipython==1.1.0','console_scripts','ipython'
__requires__ = 'ipython==1.1.0'
import sys
from pkg_resources import load_entry_point
sys.exit(
load_entry_point('ipython==1.1.0', 'console_scripts', 'ipython')()
)
Now which ipython
produces //anaconda/bin/ipython, and ipython
launches.
现在which ipython
生成 //anaconda/bin/ipython,并ipython
启动。
采纳答案by jfs
One possible reason is that there are multiple ipython
versions installed e.g., brew
might install to /usr/local/bin
, conda
might install to /anaconda/bin
(it is just a guess). The advice from similar issueis to remove all ipython
installation completely and install the one that you will use.
一个可能的原因是ipython
安装了多个版本,例如,brew
可能安装到/usr/local/bin
,conda
可能安装到/anaconda/bin
(这只是猜测)。来自类似问题的建议是ipython
完全删除所有安装并安装您将使用的安装。
回答by Peter Wang
Your problem is in your $PATH. If you look at your traceback, it's running /usr/local/bin/ipython - this is the one that is installed by Homebrew, and not by Anaconda. (Anaconda installs everything into /anaconda/bin.)
您的问题出在 $PATH 中。如果您查看回溯,它正在运行 /usr/local/bin/ipython - 这是由 Homebrew 安装的,而不是由 Anaconda 安装的。(Anaconda 将所有内容安装到 /anaconda/bin 中。)
The reason this is getting picked up is because the very last line of your .bash_profile sticks /usr/local/bin at the front of your path. This means that the ipython that you installed via Homebrew is masking the one that's installed by Anaconda.
之所以出现这种情况,是因为 .bash_profile 的最后一行将 /usr/local/bin 放在路径的前面。这意味着您通过 Homebrew 安装的 ipython 掩盖了由 Anaconda 安装的 ipython。
You have two options:
您有两个选择:
Uninstall the ipython that Homebrew installed, and just use Anaconda for your Python packages.
In your .bash_profile, move the Homebrew PATH modification line above the Anaconda one. This way, Anaconda's ipython, python, and various other Python commands will take precedence.
卸载 Homebrew 安装的 ipython,只需将 Anaconda 用于您的 Python 包。
在您的 .bash_profile 中,将 Homebrew PATH 修改行移到 Anaconda 上面。这样,Anaconda 的 ipython、python 和各种其他 Python 命令将优先。
Remember, if you change your .bash_profile, you need to close your Terminal and start a new one for the changes to take effect.
请记住,如果您更改 .bash_profile,则需要关闭终端并启动一个新终端以使更改生效。
回答by Pawel Miech
It looks like your path is completely ok. Notice that the error comes from "/usr/local/bin/ipython". It is not a bash error, it is more likely an error involving setup_tools, or pip, that is Python packaging tools. Bash finds ipython and executes ipython startup file but encounters an error there.
看起来你的路径完全没问题。请注意,错误来自“/usr/local/bin/ipython”。这不是 bash 错误,更可能是涉及 setup_tools 或 pip,即 Python 打包工具的错误。Bash 找到 ipython 并执行 ipython 启动文件,但在那里遇到错误。
The error appears to be saying that your version of ipython is incompatible. Have you tried doing something like this?
该错误似乎是说您的 ipython 版本不兼容。你试过做这样的事情吗?
conda update conda
conda update ipython
Updaing conda and ipython is recommended in iPython documentation. Perhaps this will fix the problem. If not, then add an information saying that you updated conda and ipython to your question.
iPython文档中推荐更新 conda 和 ipython 。也许这会解决问题。如果没有,请添加一条信息,说明您已将 conda 和 ipython 更新到您的问题中。
回答by Conor Svensson
Ensure you check the path to the Python executable specified at the start of the script. When I installed iPython it was defined as:
确保检查脚本开头指定的 Python 可执行文件的路径。当我安装 iPython 时,它被定义为:
#!/usr/bin/python
Instead of:
代替:
#!/usr/local/bin/python
Hence the default OS X install of Python was being used instead of my brew installed version.
因此,使用 Python 的默认 OS X 安装而不是我的 brew 安装版本。
回答by Alexiscanny
For me was slightly different because even with Anaconda installed wasn't able to find the command or to run ipython and wasn't able to find the PATH. My solution was to run these commands:
对我来说略有不同,因为即使安装了 Anaconda 也无法找到命令或运行 ipython 并且无法找到 PATH。我的解决方案是运行这些命令:
nano ~/.bash_profile
export PATH="/anaconda3/bin:$PATH"
source ~/.bash_profile
and then to check conda version:
然后检查 conda 版本:
conda
and I update conda and ipython running:
我更新 conda 和 ipython 运行:
conda update conda
conda update ipython
Hope this could help someone. This helped me: https://stackoverflow.com/a/49925193/3351569
希望这可以帮助某人。这对我有帮助:https: //stackoverflow.com/a/49925193/3351569