在gedit和virtualenv中进行pylons/pyramid代码补全

3 投票
3 回答
927 浏览
提问于 2025-04-16 16:31

我正在学习关于pyramid的文档,特别希望能有代码补全的功能。我安装了gedit-plugin-codecompletion这个插件。

我在使用virtualenv,创建好后,我会用bin/文件夹里的'activate'文件来切换我的终端窗口。可是当我启动gedit的时候,出现了这些错误:

(env)agd@hephaestus:~/Dev/projects/LearningPyramid$ gedit 

** (gedit:11418): WARNING **: Error initializing Python interpreter: could not import pygtk.

** (gedit:11418): WARNING **: Please check the installation of all the Python related packages required by gedit and try again.

** (gedit:11418): WARNING **: Cannot load python plugin Python 'Bracket Completion' since gedit wasnot able to initialize the Python interpreter.

** (gedit:11418): WARNING **: Error loading plugin 'Bracket Completion'

** (gedit:11418): WARNING **: Cannot load python plugin Python 'Evolved Code Completion' since gedit wasnot able to initialize the Python interpreter.

** (gedit:11418): WARNING **: Error loading plugin 'Evolved Code Completion'

如果你能帮我解决这个问题,我会非常感激!

3 个回答

0

作为一个初步的建议,我建议你在你的 env 虚拟环境中运行 pip install pygtk。你试过这个吗?

1

如果我是你,我就不会在你的虚拟环境里运行gedit。要是需要的话,可以打开一个新的终端窗口。这样做看起来更干净,因为在虚拟环境里安装非开发类的软件包并不是个好主意。

不使用--no-site-packages选项也许可以,但有些人觉得保持虚拟环境和系统完全隔离是个好主意。这样你就能完全控制它,而不使用这个选项就会失去这种隔离。

2

你应该创建虚拟环境的时候,不要加上 --no-site-packages 这个参数,这样才能使用系统中已经安装的Python包。

撰写回答