python - Kivy:如何让外部库工作?

标签 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 . . .

最佳答案

当您使用 kivy 的 windows 可移植包时,您必须在随附的 python 安装中安装这些库。为此,您只需启动 kivy.bat,并在其中使用 pip install,这样安装的库将可用于 kivy 应用程序。

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

关于python - Kivy:如何让外部库工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20780579/

相关文章:

python - 打印频域图的最高峰值

python - 行李箱工作标签没有吗? ---导入错误: No module named 2. 1.2

python - 自定义字体的 Kivy 标签标记

python - 访问 Pandas 中多索引的一级

python - Groupby & Sum 从某个特定值的出现到另一个特定值或相同值的出现

python - CoLab 访问文件

python - ImportError:无法从 'ModelFactory' 导入名称 'frlearn.base'

python - 导入错误:C 扩展:没有名为 'parsing' 的模块未构建

python - 如何在Kivy Python中设置GridLayout的某些按钮的高度?

Android通知到kivy中的通知栏