【问题标题】:Python3 installed successfully, but cannot be opened in terminalPython3安装成功,但终端打不开
【发布时间】:2013-09-27 14:01:06
【问题描述】:

昨天我重新安装了我的 Mac OS X 10.8,在重新安装之前,我的机器上安装了 python2.7.5 和 python3.3.2 并且工作正常,但是在重新安装这个系统之后,我无法再次打开 python3。于是我下载了Python3的DMG包,重新安装了一遍,终端还是抛出这个异常:

Fatal Python error: Py_Initialize: unable to load the file system codec 
File"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/encodings/__init__.py", line 123
raise CodecRegistryError,\
                        ^
SyntaxError: invalid syntax
Abort trap: 6

然后出现系统问题报告窗口: 它说:

Process:         Python [51780]
Path:            /Library/Frameworks/Python.framework/Versions/3.3/Resources/Python.app/Contents/MacOS/Python
Identifier:      Python
Version:         3.3.2 (3.3.2)
Code Type:       X86-64 (Native)
Parent Process:  bash [51586]
User ID:         501

Date/Time:       2013-09-23 00:40:19.908 +0800
OS Version:      Mac OS X 10.8.5 (12F37)
Report Version:  10

Interval Since Last Report:          77033 sec
Crashes Since Last Report:           1982088234
Per-App Crashes Since Last Report:   4
Anonymous UUID:                      1FEE4EB2-0D26-4DDF-9954-4423C040AECB

Crashed Thread:  0  Dispatch queue: com.apple.main-thread

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000

Application Specific Information:
abort() called

【问题讨论】:

  • python3 尝试从 python2 导入内容 - 您是否将 PYTHONPATH 设置为 python2.7 库目录?
  • 我以前从未接触过这些 python 路径,我已经阅读了这个 forum.codecall.net/topic/70489-python32-alongside-python27 并删除了我的 ~/.bash_profile 和 ~/.bash_aliases 文件中包含“python”的所有内容,重新启动了我的机器,但是它没用。你说的是 PYTHONPATH,但我不知道我还能在哪里找到这些设置?
  • 哦,我刚试了echo $PYTHONPATH,显示:/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7:,我试试删掉~
  • 好的,我刚试过 unset PYTHONPATH ,它确实工作了~现在我的python3很好了~非常感谢~

标签: python macos python-3.x


【解决方案1】:

解决办法是取消设置$PYTHONPATH,然后一切顺利。

【讨论】:

  • 还要检查 Windows 系统上是否设置了 PYTHONHOME。
  • 如果你不能取消设置 pythonpath 怎么办,因为如果你这样做就会有人打你?
猜你喜欢
  • 2019-08-10
  • 2013-03-08
  • 2012-09-19
  • 2012-12-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-11-19
相关资源
最近更新 更多