Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从MacPorts运行Python 2.7时出现MAXREPEAT问题_Python_Macos_Macports - Fatal编程技术网

从MacPorts运行Python 2.7时出现MAXREPEAT问题

从MacPorts运行Python 2.7时出现MAXREPEAT问题,python,macos,macports,Python,Macos,Macports,我在MacPorts上运行python2.7时遇到了一些问题 以下是可用Python版本的列表: $ sudo port select python Available versions for python: none python25-apple python26-apple python27 (active) python27-apple 当我将python27设置为活动状态(如上所述)时,在运行python时会出现以下错误: $ sudo por

我在MacPorts上运行python2.7时遇到了一些问题

以下是可用Python版本的列表:

$ sudo port select python
Available versions for python:
    none
    python25-apple
    python26-apple
    python27 (active)
    python27-apple
当我将
python27
设置为活动状态(如上所述)时,在运行
python
时会出现以下错误:

$ sudo port select --set python python27
Selecting 'python27' for 'python' succeeded. 'python27' is now active.
$ python
Traceback (most recent call last):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.py", line 548, in <module>
    main()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.py", line 530, in main
    known_paths = addusersitepackages(known_paths)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.py", line 266, in addusersitepackages
    user_site = getusersitepackages()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.py", line 241, in getusersitepackages
    user_base = getuserbase() # this will also set USER_BASE
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.py", line 231, in getuserbase
    USER_BASE = get_config_var('userbase')
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sysconfig.py", line 516, in get_config_var
    return get_config_vars().get(name)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sysconfig.py", line 449, in get_config_vars
    import re
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/re.py", line 105, in <module>
    import sre_compile
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sre_compile.py", line 14, in <module>
    import sre_parse
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sre_parse.py", line 17, in <module>
    from sre_constants import *
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sre_constants.py", line 18, in <module>
    from _sre import MAXREPEAT
ImportError: cannot import name MAXREPEAT
我在运行
python2.7
时没有出现上述错误,只有在shell中运行
python
时才会出现上述错误

$ which python2.7
/opt/local/bin/python2.7

$ which python
/opt/local/bin/python
有什么建议吗


谢谢。

我也有同样的问题。指向可执行文件的链接似乎有问题,尤其是vim/MacVim。经过讨论,我自己解决了这个问题

还有更多的材料

希望这有帮助


Max

我刚刚经历了同样的问题。快速简便的解决方法是在~/.profile中添加别名:

alias python='python2.7'
如果您还没有.profile文件,只需创建一个。打开一个新的terminal实例,python应该可以正常工作,没有错误

alias python='python2.7'