简体   繁体   English

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

[英]MAXREPEAT issue when running Python 2.7 from MacPorts

I'm running into some issues with running python2.7 from MacPorts. 我在从MacPorts中运行python2.7时遇到了一些问题。

Here's a list of the available Python versions: 以下是可用的Python版本的列表:

$ sudo port select python
Available versions for python:
    none
    python25-apple
    python26-apple
    python27 (active)
    python27-apple

When I set python27 to be active (as above), I get the following error when running python : 当我将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

The version of the port I have installed is (according to sudo port installed ): 我已安装的端口版本为(根据sudo port installed ):

python27 @2.7.5_1
python27 @2.7.5_1+universal (active)

I do not get the above error when running python2.7 , only when I run python in the shell. 运行时,我没有得到上面的错误python2.7 ,只有当我运行python的外壳。

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

$ which python
/opt/local/bin/python

Any suggestions? 有什么建议么?

Thanks. 谢谢。

I just experienced the same issue. 我只是遇到了同样的问题。 A quick and easy workaround is to add an alias in ~/.profile: 一个快速简便的解决方法是在〜/ .profile中添加一个别名:

alias python='python2.7'

If you don't have a .profile file already, just create one. 如果您还没有.profile文件,则只需创建一个。 Open a new instance of terminal and python should work fine with no errors. 打开一个新的终端实例,python应该可以正常工作,没有错误。

I had the same problem. 我有同样的问题。 Appears to be a problem with links to executables, particularly vim/MacVim. 似乎是指向可执行文件的链接的问题,尤其是vim / MacVim。 I resolved the issue for myself by following the discussion here . 我按照此处的讨论为自己解决了这个问题。

There is also more material here . 还有更多的材料在这里

Hope this helps. 希望这可以帮助。

Max 马克斯

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM