0

I'm trying to execute kivy 1.9.1 examples in Ubuntu 14.

Running the examples from command line gave me the error:

ImportError: No module named _clock

Downloading kivy source code from git, and checking the installed packages in the virtualenv directories, I found the _clock.so file was missing in the venvs/kivyinstall/lib/python2.7/site-packages/kivy folder.

So, I went into the kivy_sorce/kivy folder, and create a simple setup.py to execute with cython to get de .so compiled version:

from distutils.core import setup
from Cython.Build import cythonize

setup(
  name = 'clock',
  ext_modules = cythonize("_clock.pyx"),
)

and

python setup.py build_ext --inplace

Then I copied the resulting .so file into my virtual environment in the expected folder venvs/kivyinstall/lib/python2.7/site-packages/kivy.

Now, examples run from command line (activating virtual environment),

python examples/demo/pictures/main.py

And it also runs properly from pycharm's python console (I previosly configured as python interpreter the python executable from my kivy-install venv) executing this:

import subprocess
subprocess.call(['python', 'examples/demo/pictures/main.py'])

Pycharm seems to find the package cause the kivy._clock import appear no more in red, but if I execute the example directly from pycharm (ctrl+shift+F10), it keeps asking for the missing kivy._clock module.

Any hint about why pycharm still can't find the module?

kothvandir
  • 2,111
  • 2
  • 19
  • 34

2 Answers2

1

I tried marking the kivy and examples folders as "Sources" as recommended here.

But it didn't work, finally, unchecking the "add source roots to PYTHONPATH" option in running configuration in the Run -> Edit configurations menu did the trick.

Hope it helps someone else.

Community
  • 1
  • 1
kothvandir
  • 2,111
  • 2
  • 19
  • 34
0

This happens sometimes when PyCharm's internal cache is out-of-sync with what is on the disk.

It usually corrects itself, but you can force it from FileInvalidate caches / Restart...

Burhan Khalid
  • 169,990
  • 18
  • 245
  • 284