当我尝试在虚拟python环境中导入挂架时,出现错误
C:\env\Scripts>python Python 2.7 (r27:82525, Jul 4 2010, 07:43:08) [MSC v.1500 64 bit (A MD64)] on win32 Type "help", "copyright", "credits" or "license" for more informati on. >>> import pylons Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\env\lib\site-packages\pylons-1.0-py2.7.egg\pylons\__init __.py", line 6, in <module> from paste.registry import StackedObjectProxy ImportError: No module named registry
据我了解这个错误,Python告诉我,它无法find模块命名registry 。 也许这是我在安装Pylons时得到的错误的结果,这里解释了为什么在Windows Vista 64中使用easy_install和Python 2.7安装Pylons 1.0的最后一行时出现错误?
看来,许多Pylon组件被安装了,但我想registry不是可能的,或者Pylons不能看到它。
任何想法如何解决这个问题?
您必须先激活虚拟环境才能导入塔架。
C:\Users\Josh>env\scripts\activate (env) C:\Users\Josh>python ActivePython 2.6.2.2 (ActiveState Software Inc.) based on Python 2.6.2 (r262:71600, Apr 21 2009, 15:05:37) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import pylons >>>
与此相对
C:\Users\Josh\env\Scripts>python ActivePython 2.6.2.2 (ActiveState Software Inc.) based on Python 2.6.2 (r262:71600, Apr 21 2009, 15:05:37) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> pylons Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'pylons' is not defined >>>
我猜你的虚拟环境中安装了外挂软件包。 所以Python是让你导入塔,但粘贴包没有安装在您的虚拟环境之外,所以你得到一个错误。
运行激活批处理脚本(应该在你的env \ Scripts文件夹中)应该可以解决问题。