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?
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 ownlib/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 likelib/python2.7/site-packages
directory which for you would be something like:/home/utkarsh/anaconda2/lib/python2.7/site-packages
.