Kivy:我如何让外部图书馆工作?

时间:2013-12-26 06:59:13

标签: python importerror kivy

我有一个脚本,我正在使用fbconsoletwitter。这些脚本可以自行运行。

对于GUI部分,我正在尝试使用Kivy。现在当我导入我的脚本时,我收到错误ImportError说没有名为twitter / fbconsole的模块。我该怎么办?

我检查了运行kivy应用时显示的路径。这是完整的日志

botstrapping Kivy @ C:\Users\roy\Desktop\Kivy-1.7.2-w32\
Setting Environment Variables:
#################################
GST_REGISTRY
C:\Users\roy\Desktop\Kivy-1.7.2-w32\gstreamer\registry.bin
---------------
GST_PLUGIN_PATH:
C:\Users\roy\Desktop\Kivy-1.7.2-w32\gstreamer\lib\gstreamer-0.10
---------------
PATH:
C:\Users\roy\Desktop\Kivy-1.7.2-w32\;C:\Users\roy\Desktop\Kivy-1.7.2-w32\Python;
C:\Users\roy\Desktop\Kivy-1.7.2-w32\Python\Scripts;C:\Users\roy\Desktop\Kivy-1.7
.2-w32\gstreamer\bin;C:\Users\roy\Desktop\Kivy-1.7.2-w32\MinGW\bin;C:\Program Fi
les (x86)\NVIDIA Corporation\PhysX\Common;C:\Windows\system32;C:\Windows;C:\Wind
ows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\python27\;C:\Pr
ogram Files (x86)\Java\jdk1.7.0\bin;C:\Python27\Scripts;C:\Users\roy\Desktop\Kiv
y-1.7.2-w32;C:\Program Files (x86)\Google\google_appengine\;C:\Python27\Lib\site
-packages\;
----------------------------------
PYTHONPATH:
C:\Users\roy\Desktop\Kivy-1.7.2-w32\kivy;
----------------------------------
##################################
done bootstraping kivy...have fun!\n
running "python.exe C:\Users\roy\Desktop\CSE310\merging\gui1.py" \n
[INFO              ] Kivy v1.7.2
Purge log fired. Analysing...
Purge finished !
[INFO              ] [Logger      ] Record log in C:\Users\roy\.kivy\logs\kivy_1
3-12-26_25.txt
[INFO              ] [Factory     ] 144 symbols loaded
[DEBUG             ] [Cache       ] register <kv.lang> with limit=None, timeout=
Nones
[DEBUG             ] [Cache       ] register <kv.image> with limit=None, timeout
=60s
[DEBUG             ] [Cache       ] register <kv.atlas> with limit=None, timeout
=Nones
[INFO              ] [Image       ] Providers: img_tex, img_dds, img_pygame, img
_pil, img_gif
[DEBUG             ] [Cache       ] register <kv.texture> with limit=1000, timeo
ut=60s
[DEBUG             ] [Cache       ] register <kv.shader> with limit=1000, timeou
t=3600s
[INFO              ] [Text        ] Provider: pygame
[DEBUG             ] [Cache       ] register <kv.loader> with limit=500, timeout
=60s
[INFO              ] [Loader      ] using a thread pool of 2 workers
[DEBUG             ] [Cache       ] register <textinput.label> with limit=None,
timeout=60.0s
[DEBUG             ] [Cache       ] register <textinput.width> with limit=None,
timeout=60.0s
 Traceback (most recent call last):
   File "C:\Users\roy\Desktop\CSE310\merging\gui1.py", line 9, in <module>
     import twit
   File "C:\Users\roy\Desktop\CSE310\merging\twit.py", line 1, in <module>
     from twitter import *
 ImportError: No module named twitter
Press any key to continue . . .

2 个答案:

答案 0 :(得分:5)

当您使用kivy的可移植软件包进行Windows时,您必须在随附的python安装中安装这些库。要做到这一点,你只需启动kivy.bat,并在其中使用pip install,以这种方式安装的库将可用于kivy应用程序。

另一种解决方案是在系统范围内安装kivy,包含所有必需的依赖项。

答案 1 :(得分:0)

您必须编辑PYTHONPATH以包含python可以找到fbconsoletwitter的文件夹。

那样import 会在sys.modules找到它们。