我已经从 Ubuntu 12.10 升级到 13.10。与此同时,我手动删除了 Enthought Python 发行版,因为我想重新开始使用“官方”软件包。因此,我删除了 python 文件夹并将 pythonpath 重定向到官方软件包。下面是 PYTHONPATH 的转储:
$ echo $PYTHONPATH
/usr/local/Madagascar_1.5/lib/python2.7/dist-packages:/usr/lib/python2.7:/usr/local/lib/python2.7:/usr/local/Madagascar_1.5/lib/python2.7:/usr/local/Madagascar_1.5/lib/python2.7/dist-packages:/usr/local/Madagascar_1.5/lib:/usr/lib/python3
从理论上讲,这就是让一切正常运转所需要的。我使用 Python 2.7 编写代码,一切运行正常。
但是要启动 gedit 我需要导出
PYTHONPATH=/usr/lib/python3
而它已经在 pythonpath 中了。因为 Gedit 现在依赖于 python 3。我遵循了这个解决方案,但对我来说这并不令人满意:
https://askubuntu.com/questions/363291/multiple-versions-of-python
当我使用 aptitude 更新软件包时,我收到一条错误消息,提示 gedit 存在不一致。因此,一般建议重新安装 gedit。以下是输出:
sudo apt-get --reinstall install gedit
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 3 not upgraded.
1 not fully installed or removed.
Need to get 0 B/492 kB of archives.
After this operation, 0 B of additional disk space will be used.
(Reading database ... 304259 files and directories currently installed.)
Preparing to replace gedit 3.8.3-0ubuntu3 (using .../gedit_3.8.3-0ubuntu3_amd64.deb) ...
Fatal Python error: Py_Initialize: Unable to get the locale encoding
File "/usr/lib/python2.7/encodings/__init__.py", line 123
raise CodecRegistryError,\
^
SyntaxError: invalid syntax
Aborted (core dumped)
dpkg: warning: subprocess old pre-removal script returned error exit status 134
dpkg: trying script from the new package instead ...
Fatal Python error: Py_Initialize: Unable to get the locale encoding
File "/usr/lib/python2.7/encodings/__init__.py", line 123
raise CodecRegistryError,\
^
SyntaxError: invalid syntax
Aborted (core dumped)
dpkg: error processing /var/cache/apt/archives/gedit_3.8.3-0ubuntu3_amd64.deb (--unpack):
subprocess new pre-removal script returned error exit status 134
No apport report written because MaxReports is reached already
Fatal Python error: Py_Initialize: Unable to get the locale encoding
File "/usr/lib/python2.7/encodings/__init__.py", line 123
raise CodecRegistryError,\
^
SyntaxError: invalid syntax
Aborted (core dumped)
dpkg: error while cleaning up:
subprocess installed post-installation script returned error exit status 134
Errors were encountered while processing:
/var/cache/apt/archives/gedit_3.8.3-0ubuntu3_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
我想知道是否是我的 PYTHONHOME 没有正确定义,但它没有带我到任何地方导出变量。
现在另一个烦恼是 Ubuntu-desktop 依赖于 gedit,在我进行更新后它也坏了(没想太多……)。所以现在我没有桌面了。登录后屏幕变黑。
有什么建议可以让 gedit 重回正轨吗?
提前致谢
答案1
如果我错了,请纠正我,但你不是说当你的 PYTHONPATH 如下所示时,gedit 将不起作用吗:
/usr/local/Madagascar_1.5/lib/python2.7/dist-packages:/usr/lib/python2.7:/usr/local/lib/python2.7:/usr/local/Madagascar_1.5/lib/python2.7:/usr/local/Madagascar_1.5/lib/python2.7/dist-packages:/usr/local/Madagascar_1.5/lib:/usr/lib/python3
但是当您手动将其更改export
为
/usr/lib/python3
运行正常吗?
您是否有任何理由希望路径始终看起来像第一个示例?您可以通过将命令添加export
到~/bash.rc
编辑:另外,您能否尝试将 gedit 喜欢的部分放在/usr/lib/python3
路径的开头,然后将其余部分放在后面,而不是将 python3 放在最后?也许它使用“短路逻辑”并选择它找到的第一个有效的逻辑。