ipython读错了python版本 [英] ipython reads wrong python version
问题描述
我在使用Python,iPython和库时遇到了麻烦。以下几点显示了问题链。我在Mac Lion上运行Python 2.7。
I've been having trouble with Python, iPython and the libraries. The following points show the chain of the problematics. I'm running Python 2.7 on Mac Lion.
- iPython不会读取scipy,matplotlib的库,但它确实读取了numpy。
- 为了解决这个问题,我尝试安装Python的源代码版本,它只给了我更多的问题,因为现在我有两个不同的版本:2.7.1和2.7.2
- 我注意到运行Python,使用版本2.7.2并导入scipy,matplotlib和numpy,但是在iPython上版本是2.7.1,它不会打开scipy或matplotlib。
我尝试过其他一些我从其他博客中遇到的事情。但是他们都没有帮助,也不幸的是我不知道我在做些什么。例如:
我尝试使用easy_install和pip卸载并重新安装ipython。我还尝试通过自制程序重新安装所有内容,并修改路径.bash_profile。
I've tried several things that I've encountered from other blogposts. But none of them have helped, and also unfortunately I don't quite know what I'm doing with some of them. For example: I tried uninstalling and reinstalling ipython with easy_install and pip. I also tried reinstalling everything through homebrew, and modifying the path .bash_profile.
推荐答案
好的快速修复:
which python
给出你 / usr / bin / python
,对吗?做
which ipython
我打赌那将是 / usr / local / bin / ipython
。让我们看一下:
and I bet that'll be /usr/local/bin/ipython
. Let's look inside:
编辑9/7/16 - 文件现在看起来像这样:
cat /usr/local/bin/ipython
#!/usr/bin/python
# -*- 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())
我的工作正常,但我的情况并不完全像OP的。
And mine works properly like this, but my situation isn't exactly like the OP's.
原始答案 - 2013年9月30日:
cat /usr/local/bin/ipython
#!/usr/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 'ipython==0.12.1','console_scripts','ipython'
__requires__ = 'ipython==0.12.1'
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.exit(
load_entry_point('ipython==0.12.1', 'console_scripts', 'ipython')()
)
Aha - 在您的编辑器中打开 / usr / local / bin / ipython
(具有权限),并将第一行更改为
Aha - open /usr/local/bin/ipython
in your editor (with privileges), and change the first line to
#!/usr/local/bin/python
保存,启动iPython,应该说它正在使用你想要的版本。
save, start iPython, should say it's using the version you want now.
这篇关于ipython读错了python版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!