我最近删除了Anaconda并用brew重新安装了python。我已根据these说明安装了所有内容。
Python效果很好,到目前为止我测试的所有软件包都可以使用。我已经安装了ipython,但尝试从终端启动它会产生:
-bash:ipython:找不到命令
我找到了安装位置:
/usr/local/lib/python2.7/site-packages/ipython
在更早的相关问题之后,我尝试将此路径添加到.bash_profile但得到了:
-bash :: /usr/local/lib/python2.7/site-packages/ipython:没有这样的文件或目录
每当终端开始时。
更多信息:Anaconda安装了一个删除的El-Capitan 10.11.2,python 2.7。
非常感谢任何帮助!
编辑:在@cel请求中添加了更多信息:
echo $PATH
给出:
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/git/bin:/Library/TeX/texbin:/Applications/Sublime Text.app/Contents/SharedSupport/bin
which -a python
给出:
/usr/local/bin/python
和/usr/bin/python
。
编辑:将python -m pip install ipython
的输出添加到cel的请求中:
Requirement already satisfied (use --upgrade to upgrade): ipython in /usr/local/lib/python2.7/site-packages
Requirement already satisfied (use --upgrade to upgrade): traitlets in /usr/local/lib/python2.7/site-packages (from ipython)
Requirement already satisfied (use --upgrade to upgrade): pickleshare in /usr/local/lib/python2.7/site-packages (from ipython)
Requirement already satisfied (use --upgrade to upgrade): simplegeneric>0.8 in /usr/local/lib/python2.7/site-packages (from ipython)
Requirement already satisfied (use --upgrade to upgrade): decorator in /usr/local/lib/python2.7/site-packages (from ipython)
Requirement already satisfied (use --upgrade to upgrade): gnureadline in /usr/local/lib/python2.7/site-packages (from ipython)
Requirement already satisfied (use --upgrade to upgrade): appnope in /usr/local/lib/python2.7/site-packages (from ipython)
Requirement already satisfied (use --upgrade to upgrade): pexpect in /usr/local/lib/python2.7/site-packages (from ipython)
Requirement already satisfied (use --upgrade to upgrade): ipython-genutils in /usr/local/lib/python2.7/site-packages (from traitlets->ipython)
Requirement already satisfied (use --upgrade to upgrade): path.py in /usr/local/lib/python2.7/site-packages (from pickleshare->ipython)
Requirement already satisfied (use --upgrade to upgrade): ptyprocess>=0.5 in /usr/local/lib/python2.7/site-packages (from pexpect->ipython)
答案 0 :(得分:42)
在网上搜索"bash: ipython: command not found"
会产生几次点击(包括this SO question),但它们并没有特别帮助。从它的声音来看,你安装了IPython
,Python 包,但ipython
- 它的包装/启动器 - 因任何原因而丢失。要检查是否是这种情况,请尝试运行:
% python -m IPython
Python 2.7.9 (default, Feb 10 2015, 03:28:08)
Type "copyright", "credits" or "license" for more information.
IPython 4.0.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]:
如果这会带来IPython,那么您可能会尝试创建一个shell别名,因为上面链接的SO答案表明,即在shell的启动脚本中添加类似的内容:alias ipython='python -m IPython'
。或者,自己创建启动器脚本。对我而言,它位于/usr/local/bin/ipython
并包含以下内容:
#!/usr/local/opt/python/bin/python2.7
# -*- coding: utf-8 -*-
import re
import sys
from IPython import start_ipython
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(start_ipython())
希望这会有所帮助。 (如果确实如此,请考虑对其他SO 问题进行投票 ......)
更新:以下是一些可能相关的链接:
答案 1 :(得分:2)
如果使用 Python3 ,只需尝试:
ipython3
对我有用。
答案 2 :(得分:1)
由@evadeflow给出的答案可以完成这项工作,但是pip还安装了其他几个软件包,为每个软件包继续添加alias
将非常不舒服。
一种相当优雅的方法是将安装这些软件包的路径添加到$PATH
变量中。就我而言,在〜/ .bashrc中添加以下行即可完成工作:
export PATH=$PATH:/home/my_user_name/.local/bin
Addl refs:https://askubuntu.com/q/551990/632996; https://askubuntu.com/q/556090
答案 3 :(得分:0)
上面的答案可能足够了,但是我想分享自己的经验,因为我今天遇到了同样的问题并找到了一个简单的解决方案。我在Ubuntu 18.04中安装了ipython use apt,如下所示:
sudo apt安装python-ipython
然后,“ ipython”命令不起作用,并且出现了上面提到的相同的“找不到命令”错误。安装python3-python之后也发生了同样的情况。但是,然后我尝试了“ sudo apt install ipython”并安装了正确的包装器。我不知道pip是否会发生类似的情况,但这就是我使用apt的经验。
答案 4 :(得分:0)
有时候,在成功安装anaconda之后,您只需要提供bash_profile。
source ~/.bash_profile
答案 5 :(得分:0)
对我有用的是取消使用:
~pip3 uninstall ipython
然后:
~sudo pip3 install ipython
我正在使用Debian在(W10)WSL2上运行它。
答案 6 :(得分:0)
对于 anaconda 用户:
conda install -c conda-forge ipywidgets