iPython 已安装但未找到 [英] iPython installed but not found

查看:46
本文介绍了iPython 已安装但未找到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近删除了 Anaconda 并用 brew 重新安装了 python.我已经根据 这些 说明.

I've recently deleted Anaconda and reinstalled python with brew. I've installed everything according to these instructions.

Python 运行良好,到目前为止我测试过的所有包也运行良好.我已经安装了 ipython,但尝试从终端启动它会给出:

Python works great, and all packages I've tested so far also work. I've got ipython installed, but trying to launch it from the terminal gives:

-bash: ipython: 命令未找到

-bash: ipython: command not found

我已在以下位置找到安装:

I've located the installation at:

/usr/local/lib/python2.7/site-packages/ipython

/usr/local/lib/python2.7/site-packages/ipython

根据较早的相关问题,我尝试将此路径添加到 .bash_profile 但得到:

Following older related questions, I've tried adding this path to .bash_profile but got:

-bash: :/usr/local/lib/python2.7/site-packages/ipython: 没有那个文件或目录

-bash: :/usr/local/lib/python2.7/site-packages/ipython: No such file or directory

每当终端启动时.

更多信息:Anaconda 安装了一个已删除的 El-Capitan 10.11.2、python 2.7.

Some more info: Anaconda installed an removed, El-Capitan 10.11.2, python 2.7.

任何帮助将不胜感激!

向@cel 请求添加了更多信息:

added some more info to @cel request:

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 的请求中:

added the output of python -m pip install ipython to cel's request:

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)

推荐答案

Searching the web for "bash: ipython: command not found" 出现了几个点击(包括 ​​this SO question),但它们并不是特别有用.从它的声音来看,您已经安装了IPython,Python ,但是ipython——入口点(即,包装器/启动器脚本)——无论出于何种原因都不见了.要检查是否是这种情况,请尝试运行:

Searching the web for "bash: ipython: command not found" turns up several hits (including this SO question), but they're not particularly helpful. From the sound of it, you have IPython, the Python package installed, but ipython—the entry point (i.e., wrapper/launcher script) for it—is missing for whatever reason. To check whether this is the case, try running:

% 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,那么您可以尝试按照上面链接的 SO 答案所建议的那样创建一个 shell 别名,即,在您的 shell 的启动脚本中放置类似的内容:alias ipython='python -m IPython'.或者,自己创建启动程序脚本.对我来说,它位于 /usr/local/bin/ipython 并包含以下内容:

If that brings up IPython, then you might try making a shell alias as the SO answer linked above suggests, i.e., put something like this in your shell's startup script: alias ipython='python -m IPython'. Or, create the launcher script yourself. For me, it lives in /usr/local/bin/ipython and contains the following:

#!/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 question 进行投票...)

Hope this helps. (If it does, please consider up-voting the other SO question as well...)

更新:这里有一些可能更相关的链接:

UPDATE: Here are some more possibly-relevant links:

这篇关于iPython 已安装但未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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