VSCode中运行Kivy1.11(带有SDL2的Py3.6)

问题描述 投票:0回答:1

[我正在尝试使用kivy1.11,python3.6.9和Win10在VSCode(1.39.1)中调试我的GUI,但是VSCode无法编译。

我根据conda中的the official Kivy-page安装了kivy软件包。我测试了是否在VSCode之外,并在终端中启动了它。这有效:

(kivy_py36) C:\Users\...\RASPIapp_py3>python main.py
[INFO   ] [Logger      ] Record log in C:\Users\...\.kivy\logs\kivy_19-10-16_6.txt
[INFO   ] [Kivy        ] v1.11.1
[INFO   ] [Kivy        ] Installed at "C:\Users\...\Anaconda3\envs\kivy_py36\lib\site-packages\kivy\__init__.py"
[INFO   ] [Python      ] v3.6.9 |Anaconda, Inc.| (default, Jul 30 2019, 14:00:49) [MSC v.1915 64 bit (AMD64)]
[INFO   ] [Python      ] Interpreter at "C:\Users\...\Anaconda3\envs\kivy_py36\python.exe"
[INFO   ] [Factory     ] 184 symbols loaded
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored)
[INFO   ] [Text        ] Provider: sdl2
[INFO   ] [Window      ] Provider: sdl2
[INFO   ] [GL          ] Using the "OpenGL" graphics system
[INFO   ] [GL          ] GLEW initialization succeeded
[INFO   ] [GL          ] Backend used <glew>
[INFO   ] [GL          ] OpenGL version <b'4.5.0 - Build 25.20.100.6472'>
[INFO   ] [GL          ] OpenGL vendor <b'Intel'>
[INFO   ] [GL          ] OpenGL renderer <b'Intel(R) HD Graphics 630'>
[INFO   ] [GL          ] OpenGL parsed version: 4, 5
[INFO   ] [GL          ] Shading version <b'4.50 - Build 25.20.100.6472'>
[INFO   ] [GL          ] Texture max size <16384>
[INFO   ] [GL          ] Texture max units <32>
[INFO   ] [Window      ] auto add sdl2 input provider
[INFO   ] [Window      ] virtual keyboard not allowed, single mode, not docked

但是当我在VSCode中尝试相同的环境时,我得到了:

[INFO   ] [Logger      ] Record log in C:\Users\...\.kivy\logs\kivy_19-10-16_1.txt
[INFO   ] [Kivy        ] v1.11.1
[INFO   ] [Kivy        ] Installed at "C:\Users\...\Anaconda3\envs\kivy_py36\lib\site-packages\kivy\__init__.py"
[INFO   ] [Python      ] v3.6.9 |Anaconda, Inc.| (default, Jul 30 2019, 14:00:49) [MSC v.1915 64 bit (AMD64)]
[INFO   ] [Python      ] Interpreter at "C:\Users\...\Anaconda3\envs\kivy_py36\python.exe"
[INFO   ] [Factory     ] 184 symbols loaded
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_gif (img_sdl2, img_pil, img_ffpyplayer ignored)
[CRITICAL] [Text        ] Unable to find any valuable Text provider. Please enable debug logging (e.g. add -d if running from the command line, or change the log level in the config) and re-run your app to identify potential causes
sdl2 - ImportError: DLL load failed: Das angegebene Modul wurde nicht gefunden.
  File "C:\Users\...\Anaconda3\envs\kivy_py36\lib\site-packages\kivy\core\__init__.py", line 63, in core_select_lib
    fromlist=[modulename], level=0)
  File "C:\Users\...\Anaconda3\envs\kivy_py36\lib\site-packages\kivy\core\text\text_sdl2.py", line 13, in <module>
    from kivy.core.text._text_sdl2 import (_SurfaceContainer, _get_extents,

pil - ImportError: DLL load failed: Das angegebene Modul wurde nicht gefunden.
  File "C:\Users\...\Anaconda3\envs\kivy_py36\lib\site-packages\kivy\core\__init__.py", line 63, in core_select_lib
    fromlist=[modulename], level=0)
  File "C:\Users\...\Anaconda3\envs\kivy_py36\lib\site-packages\kivy\core\text\text_pil.py", line 7, in <module>
    from PIL import Image, ImageFont, ImageDraw
  File "C:\Users\...\Anaconda3\envs\kivy_py36\lib\site-packages\PIL\Image.py", line 95, in <module>
    from . import _imaging as core

[CRITICAL] [App         ] Unable to get a Text provider, abort.

在两种情况下,标准的“ .kivy / config.ini”均未更改。py36的一些已安装软件包是:

cython                    0.29.13          py36ha925a31_0
…
kivy                      1.11.1           py36hbc14df2_0    conda-forge
kivy-examples             1.11.1                   pypi_0    pypi
…
pillow                    6.1.0            py36h643dfcc_1    conda-forge
…
python                    3.6.9                h5500b2f_0
…sdl2                      2.0.10               h6538335_0    conda-forge
sdl2_image                2.0.5                h63225fd_0    conda-forge
sdl2_mixer                2.0.4                h6538335_0    conda-forge
sdl2_ttf                  2.0.15               h4636d2b_0    conda-forge

和一些py27:

cython                    0.27.3           py27h566c365_0
…
kivy                      1.10.1           py27h7bc4a79_2    conda-forge
kivy-deps-glew            0.1.10                   pypi_0    pypi
kivy-deps-sdl2            0.1.18                   pypi_0    pypi
...
pillow                    6.1.0            py27h6202ca7_0    conda-forge
…
python                    2.7.13              h1b6d89f_16
...
sdl2                      2.0.9                hc56fc5f_2    conda-forge
sdl2_image                2.0.5                h4bcde91_0    conda-forge
sdl2_mixer                2.0.1                hc56fc5f_1    conda-forge
sdl2_ttf                  2.0.15               hdbef25a_0    conda-forge

这是kivy-examples中的animate.py示例。

import kivy
from kivy.animation import Animation
from kivy.app import App
from kivy.uix.button import Button

class TestApp(App):

    def animate(self, instance):
        animation = Animation(pos=(100, 100), t='out_bounce')
        animation += Animation(pos=(200, 100), t='out_bounce')
        animation &= Animation(size=(500, 500))
        animation += Animation(size=(100, 50))

        animation.start(instance)

    def build(self):
        button = Button(size_hint=(None, None), text='plop',
                        on_press=self.animate)
        return button

if __name__ == '__main__':
    TestApp().run()

因此,我希望它可以在vscode中工作,但是它只能在终端中工作。所以我的问题是:[[如何强制VSCode查找和使用SDL2?有趣的是,如果我使用Kivy和Python2.7(!)尝试与上述相同的操作,则它可以在VSCode和终端中使用。

python-3.x visual-studio-code kivy sdl-2
1个回答
0
投票
[在使用VSCode并找到this helpful link之后,我终于改变了:

1)用户-> settings.json

"terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\cmd.exe",

2)如果使用了具有不同文件夹的工作空间(例如我的情况)->更改“ .code-workspace”

"folders": [ { "name": "RASPIapp_py3", "path": "C:\\Users\\<YOURPATH>\\RASPIapp_py3", "python.pythonPath": "C:\\Users\\<YOURUSERNAME>\\Anaconda3\\envs\\<YOURENVNAME>\\python.exe", "terminal.integrated.shellArgs.windows": [ "/K", "C:\\Users\\<YOURUSERNAME>\\Anaconda3\\Scripts\\activate.bat", "C:\\Users\\<YOURUSERNAME>\\Anaconda3" ] }

不,我只是想知道为什么它能够首先找到基维,尽管似乎唯一的问题是康达壳没有被激活。
© www.soinside.com 2019 - 2024. All rights reserved.