kivy 1.10.0,蟒蛇3.4.5,窗戶10,使用蟒蛇的Spyder的IDE新Kivy安裝:AttributeError的: '模塊' 對象有沒有屬性 '需要'
大的麻煩後試圖在我的Windows安裝kivy 10臺電腦,我可以......有點。我將python降級到最新的支持版本。
我把kivy的股票代碼,以確保它的工作:
import kivy
kivy.require('1.0.6') # replace with your current kivy version !
from kivy.app import App
from kivy.uix.label import Label
class MyApp(App):
def build(self):
return Label(text='Hello world')
if __name__ == '__main__':
MyApp().run()
更改我的版本1.10.0。但我得到了以下錯誤和追溯:
Traceback (most recent call last):
File "<ipython-input-6-498c1728e978>", line 1, in runfile('C:/Users/Andrew/Documents/Programming/Kivvv/UsageExample.py', wdir='C:/Users/Andrew/Documents/Programming/Kivvv')
File "C:\Users\Andrew\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 866, in runfile execfile(filename, namespace)
File "C:\Users\Andrew\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/Andrew/Documents/Programming/Kivvv/UsageExample.py", line 12, in kivy.require('1.10.0') # replace with your current kivy version !
AttributeError: 'module' object has no attribute 'require'
也跑
print(dir(kivy))
其返回此列表:
['doc', 'loader', 'name', 'package', 'path', 'spec']
我的猜測是,kivy沒有正確安裝,但我已經安裝了很多麻煩,所以我不想重新安裝它,直到這顯然是下一個最佳選擇。
另外,如果有幫助,運行kivy網站上的kivy安裝過程時,幾個步驟就返回「splitlines」即使每一步成功finishes--
Exception:
Traceback (most recent call last):
File "C:\Users\Andrew\Anaconda3\lib\site-packages\pip\basecommand.py", line 215, in main
status = self.run(options, args)
File "C:\Users\Andrew\Anaconda3\lib\site-packages\pip\commands\install.py", line 335, in run
wb.build(autobuilding=True)
File "C:\Users\Andrew\Anaconda3\lib\site-packages\pip\wheel.py", line 749, in build
self.requirement_set.prepare_files(self.finder)
File "C:\Users\Andrew\Anaconda3\lib\site-packages\pip\req\req_set.py", line 380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "C:\Users\Andrew\Anaconda3\lib\site-packages\pip\req\req_set.py", line 666, in _prepare_file
check_dist_requires_python(dist)
File "C:\Users\Andrew\Anaconda3\lib\site-packages\pip\utils\packaging.py", line 48, in check_dist_requires_python
feed_parser.feed(metadata)
File "C:\Users\Andrew\Anaconda3\lib\email\feedparser.py", line 177, in feed
self._input.push(data)
File "C:\Users\Andrew\Anaconda3\lib\email\feedparser.py", line 100, in push
parts = data.splitlines(True)
AttributeError: 'NoneType' object has no attribute 'splitlines'
不知道是否發生錯誤有一點不同,但我決定將其納入以防萬一它是一個很好的線索。
非常感謝!
更新,17年5月12日:
我繼續通過在記事本中粘貼,並從那裏運行它嘗試過的節目,但我得到了同樣的錯誤消息。
我再在PowerShell中確實
python -m pip list
,並沒有這些彈出:
Kivy (1.10.0)
Kivy-Garden (0.1.4)
kivy.deps.angle (0.1.4)
kivy.deps.glew (0.1.9)
kivy.deps.sdl2 (0.1.17)
它看起來像kivy沒有安裝畢竟。試圖再次運行安裝,以後這裏就是我的電腦在我後面拍攝:
PS C:\Users\Andrew> python -m pip install kivy
Collecting kivy
Using cached Kivy-1.10.0-cp34-cp34m-win_amd64.whl
Collecting Kivy-Garden>=0.1.4 (from kivy)
Using cached kivy-garden-0.1.4.tar.gz
Requirement already satisfied: docutils in
c:\users\andrew\anaconda3\lib\site-packages (from kivy)
Requirement already satisfied: pygments in
c:\users\andrew\anaconda3\lib\site-packages (from kivy)
Exception:
Traceback (most recent call last):
File "C:\Users\Andrew\Anaconda3\lib\site-packages\pip\basecommand.py",
line 215, in main
status = self.run(options, args)
File "C:\Users\Andrew\Anaconda3\lib\site-
packages\pip\commands\install.py", line 335, in run
wb.build(autobuilding=True)
File "C:\Users\Andrew\Anaconda3\lib\site-packages\pip\wheel.py", line 749, in build
self.requirement_set.prepare_files(self.finder)
File "C:\Users\Andrew\Anaconda3\lib\site-packages\pip\req\req_set.py", line 380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "C:\Users\Andrew\Anaconda3\lib\site-packages\pip\req\req_set.py", line 666, in _prepare_file
check_dist_requires_python(dist)
File "C:\Users\Andrew\Anaconda3\lib\site-packages\pip\utils\packaging.py", line 48, in check_dist_requires_python
feed_parser.feed(metadata)
File "C:\Users\Andrew\Anaconda3\lib\email\feedparser.py", line 177, in feed
self._input.push(data)
File "C:\Users\Andrew\Anaconda3\lib\email\feedparser.py", line 100, in push
parts = data.splitlines(True)
AttributeError: 'NoneType' object has no attribute 'splitlines'
因爲我沒有得到我說:「kivy安裝」的消息時,它看起來像這樣「splitlines」屬性錯誤預防安裝完成。任何想法如何我可以解決這個問題?
對不起,我無法幫助您解決錯誤,我只想指出,在任何Python版本的Windows上安裝Kivy並沒有什麼困難。您需要將Kivy安裝爲純Python模塊:1)從https://kivy.org/downloads/appveyor/kivy/下載您需要Python版本的whl文件。2)使用pip install your_filename_here.whl來安裝文件。 –