kivy with pycharm import error

2019-05-11 23:58发布

(New in python+kivy here).

Hi, I'm trying to get python with Kivy up in running and I just wanted to know if there's a way to run Kivy apps in PyCharm since I'm getting an error:

Traceback (most recent call last):
  File "C:/Kivy/kivy/examples/tutorials/pong/main.py", line 1, in <module>
    import kivy
ImportError: No module named kivy

when loading this file with pycharm, notice that that's the sample game out of the box, I can run the app via right click->sendTo->kivy.bat but I don't think that large scale apps actually do it that way -.- there must be a simpler(and hopefully more graphic) way to use Kivy, after a lot of asking to Dr. Google I give up, Thanks in advance!:)

BTW: My main interest is making apps that makes basic database requests and at the same time are GUI friendly , Kivy was my first option next to WX but if there are any suggestions they are welcome :)

5条回答
小情绪 Triste *
2楼-- · 2019-05-12 00:36

For OSX 10.10.2, kivy 1.9.0, and Pycharm 5.0.2 (free Community Edition), the instructions at the link below worked for me:

Setting up Kivy 1.9.0 with PyCharm 4.5 EAP on OS X 10.10.3

  1. Substitute PyCharm for PyCharm-EAP in the instructions(which only occurs once).

  2. I entered each Environment variable separately, rather than pasting them in as one long string.

  3. Pay attention to the titles of the windows where you enter things. The instructions tell you EXACTLY which window you should be looking at.

查看更多
太酷不给撩
3楼-- · 2019-05-12 00:37

PyCharm 4.0 changed the answer, now it's just set some environment variables. I updated the Kivy Wiki for setting up PyCharm on OSX

查看更多
Evening l夕情丶
4楼-- · 2019-05-12 00:40

I just put up a tutorial on how to setup pycharm & kivy on os x

Short Version for Windows (I assume this will work):

After you install kivy, you need to create a python interpreter for kivy - if you already had python installed, it's the wrong python to do Kivy work. Check C:/Kivy/kivy/ or the contents of kivy.bat to get the path to the python.exe distributed with kivy ( I found C:\Kivy141\Python\python.exe on one page, but that may be if you install kivy manually)

When you find it, your kivy project python interpreter needt to be that one.

Good luck!

查看更多
迷人小祖宗
5楼-- · 2019-05-12 00:43

With PyCharm on OSX I had the same problem and solved it by creating a VirtualEnv in PyCharm (see PyCharm docs for this) and some Kivy paths to the virtualenv. You can find this by selecting the VirtualEnv and select the tab "Paths". You can probably find out the correct paths by inspecting the kivy.bat file. I did something similar on the Mac. I wanted to include a picture to show my paths settings, but my Stackoverflow karma level doesn't allow this.

查看更多
何必那么认真
6楼-- · 2019-05-12 00:51

To anyone that may see this:

Follow the wiki guide to create the symlink. In Pycharm, add a local file for the project interpreter, then click the "more" button, go to the pencil, and manually change the link to /Applications/Kivy.app/Contents/Resources/script . That's how I got mine to work, latest PyCharm CE, Kivy, Python 3.5, and El Capitan

查看更多
登录 后发表回答