Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
172 views
in Technique[技术] by (71.8m points)

python 2.7 - iPython installed but not found

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

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: command not found

I've located the installation at:

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

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

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

Whenever terminal starts.

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

Any help would be much appreciated!

EDIT: added some more info to @cel request:

echo $PATH gives:

/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 gives: /usr/local/bin/python and /usr/bin/python.

EDIT: 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)
question from:https://stackoverflow.com/questions/34441943/ipython-installed-but-not-found

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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]:

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())

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

UPDATE: Here are some more possibly-relevant links:


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...