MAXREPEAT issue when running Python 2.7 from MacPorts

北城以北 提交于 2019-12-11 10:18:02

问题


I'm running into some issues with running python2.7 from MacPorts.

Here's a list of the available Python versions:

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

$ 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):

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.

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

$ which python
/opt/local/bin/python

Any suggestions?

Thanks.


回答1:


I just experienced the same issue. A quick and easy workaround is to add an alias in ~/.profile:

alias python='python2.7'

If you don't have a .profile file already, just create one. Open a new instance of terminal and python should work fine with no errors.




回答2:


I had the same problem. Appears to be a problem with links to executables, particularly vim/MacVim. I resolved the issue for myself by following the discussion here.

There is also more material here.

Hope this helps.

Max



来源:https://stackoverflow.com/questions/18106790/maxrepeat-issue-when-running-python-2-7-from-macports

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!