0

我是 Python 编程的新手,并试图为自己建立一个功能基础,从中我可以运行看起来非常令人兴奋的 IPython Notebook 之类的东西。

到目前为止,我在OS X 10.6 (Snow Leopard)Python 2.7和. 到目前为止,我尝试过的几乎所有东西都按预期工作。我专注于学习,但也希望有使用的选择。我阅读了几份文档,我需要开始使用 Python 包管理器访问 PyPI 包,而这正是我应该用于 3k 的文件。所以我根据我找到的文档安装了它,它似乎工作正常。3.3python.orgActiveTcl 8.5.133.32.7distribute

我也pip按指示安装了,还有其他一些。

在这一点上,我有:

$ pip freeze
distribute==0.6.34
ipython==0.13.1
nose==1.2.1 (installed after IPython)
pexpect==2.4 (installed after IPython)
pyflakes3k==0.4.3
readline==6.2.4.1 (installed after IPython)

在这一点上,我在ipython.org 指导下这样做

当我这样做时$ easy_install pexpect,我得到了一堆错误:

$ easy_install pexpect
Searching for pexpect
Reading http://pypi.python.org/simple/pexpect/
Reading http://pexpect.sourceforge.net/
Reading http://sourceforge.net/project/showfiles.php?group_id=59762
Best match: pexpect 2.4
Downloading http://pypi.python.org/packages/source/p/pexpect/pexpect-2.4.tar.gz#md5=fe82d69be19ec96d3a6650af947d5665
Processing pexpect-2.4.tar.gz
Writing /var/folders/td/td0Sh8EfGFuMCnKex1v+q++++TI/-Tmp-/easy_install-s4dtyy/pexpect-2.4/setup.cfg
Running pexpect-2.4/setup.py -q bdist_egg --dist-dir /var/folders/td/td0Sh8EfGFuMCnKex1v+q++++TI/-Tmp-/easy_install-s4dtyy/pexpect-2.4/egg-dist-tmp-5h5cg4
File "build/bdist.macosx-10.6-intel/egg/fdpexpect.py", line 36
raise ExceptionPexpect, 'The fd argument is not a valid file descriptor.'
                      ^
SyntaxError: invalid syntax

File "build/bdist.macosx-10.6-intel/egg/FSM.py", line 77
return `self.value`
       ^
SyntaxError: invalid syntax

File "build/bdist.macosx-10.6-intel/egg/pexpect.py", line 82
except ImportError, e:
                  ^
SyntaxError: invalid syntax

zip_safe flag not set; analyzing archive contents...
File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pexpect-2.4-py3.3.egg/fdpexpect.py", line 36
raise ExceptionPexpect, 'The fd argument is not a valid file descriptor.'
                      ^
SyntaxError: invalid syntax

File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pexpect-2.4-py3.3.egg/FSM.py", line 77
return `self.value`
       ^
SyntaxError: invalid syntax

File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pexpect-2.4-py3.3.egg/pexpect.py", line 82
except ImportError, e:
                  ^
SyntaxError: invalid syntax

Adding pexpect 2.4 to easy-install.pth file

Installed /Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pexpect-2.4-py3.3.egg
Processing dependencies for pexpect
Finished processing dependencies for pexpect

这对我来说看起来很糟糕(尽管我还没有专业知识来真正解释它),所以我不确定我是否有完整的pexpect.

安装后nosepexpect按照上面的 URL 之前),我尝试从命令行运行,但都找不到命令,但是在我iptest再次(之后)之后,我注意到这个安装添加了(以及其他一些scripts) 到我的路径,现在我的 bash shell可以找到 iptest3,但是当我运行它时,我得到了一些更难看的输出:iptest3easy_install ipythonnoseiptest3ipcluster3

$ iptest3
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.3/bin/iptest3", line 9, in <module>
load_entry_point('ipython==0.13.1', 'console_scripts', 'iptest3')()
File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/distribute-0.6.34-py3.3.egg/pkg_resources.py", line 343, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/distribute-0.6.34-py3.3.egg/pkg_resources.py", line 2308, in load_entry_point
return ep.load()
File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/distribute-0.6.34-py3.3.egg/pkg_resources.py", line 2014, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/IPython/__init__.py", line 43, in <module>
from .config.loader import Config
File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/IPython/config/__init__.py", line 16, in <module>
from .application import *
File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/IPython/config/application.py", line 31, in <module>
from IPython.config.configurable import SingletonConfigurable
File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/IPython/config/configurable.py", line 26, in <module>
from .loader import Config
File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/IPython/config/loader.py", line 27, in <module>
from IPython.utils.path import filefind, get_ipython_dir
File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/IPython/utils/path.py", line 25, in <module>
from IPython.utils.process import system
File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/IPython/utils/process.py", line 27, in <module>
from ._process_posix import _find_cmd, system, getoutput, arg_split
File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/IPython/utils/_process_posix.py", line 22, in <module>
from IPython.external import pexpect
File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/IPython/external/pexpect/__init__.py", line 2, in <module>
import pexpect
File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pexpect-2.4-py3.3.egg/pexpect.py", line 82
except ImportError, e:
                  ^
SyntaxError: invalid syntax

在完成所有这些之后,我注意到 my/Library/Frameworks/Python.framework/Versions/Current一直指向2.7,我猜这可能与我的问题有关,并将符号链接更改为指向3.3,但iptest3仍然失败并出现上述错误。

关于如何解决此问题的任何其他想法?很明显,这对于做我想做的iptest任何其他事情(比如)非常重要。IPython Notebook

4

1 回答 1

3

pexpect 有一个与 py3 兼容的分支,称为pexpect-u(u 代表 unicode,两者的主要区别)。您需要它来在 Python 3 上运行基于 pexpect 的 IPython 部分。应该是一个简单的

pip install pexpect-u

旁注:pexpect-u 由 IPython 开发人员 Thomas Kluyver 编写,他完成了大部分繁重的工作,为 IPython 带来了 py3 兼容性。

于 2013-01-11T06:06:40.120 回答