0

I am working on Python 2.7 in Anaconda in Spyder IDE. I am making a project using kivy and I am importing the following libraries and kivy packages:

import numpy as np
from random import random, randint
import matplotlib.pyplot as plt
import time

# Importing the Kivy packages
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.uix.button import Button
from kivy.graphics import Color, Ellipse, Line
from kivy.config import Config
from kivy.properties import NumericProperty, ReferenceListProperty, ObjectProperty
from kivy.vector import Vector
from kivy.clock import Clock

But upon compiling the line:

from kivy.app import App 

I am getting an error in the console:

from kivy.app import App
Traceback (most recent call last):

File "<ipython-input-2-04ecba6f9778>", line 1, in <module>
from kivy.app import App

ImportError: No module named kivy.app

How can I resolve the issue?

karel
  • 114,770
Utkarsh
  • 671

1 Answers1

0

from kivy.app import App runs without showing an error from the terminal in the python interpreter (Python 2.7), so clearly the error on your computer is caused by Anaconda. Anaconda is known for making a big mess out of the default paths for many Python modules. To fix it you need to tell conda the paths to Python files that were installed by apt (e.g. sudo apt install python-kivy).

You can use symbolic links to tell conda the paths to Python files that were installed by apt in /usr/lib/python2.7/dist-packages/kivy/. Put the symbolic links in conda's own lib/python/site-packages directory which for you would be something like: /home/utkarsh/anaconda2/lib/python/site-packages if utkarsh is your username. Or maybe it's something like lib/python2.7/site-packages directory which for you would be something like: /home/utkarsh/anaconda2/lib/python2.7/site-packages.

karel
  • 114,770
  • Sir can you please tell the syntax, the source should be lib/python/site-packages and destination should be anaconda2. – Utkarsh Oct 07 '18 at 14:35
  • Sir, I got this output message: File "/home/utkarsh/anaconda2/lib/python2.7/site-packages/kivy/clock.py", line 362, in from kivy._clock import CyClockBase, ClockEvent, FreeClockEvent, \

    ImportError: No module named _clock

    – Utkarsh Oct 07 '18 at 15:48