Python Forum

Full Version: Installing from source and getting import working in linux
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello!
I installed kivy and cython from source like this:

git clone https://github.com/kivy/kivy.git
cd kivy
make

same for cython.
I installed packages to
/home/lasse/.local/lib/python2.7/site-packages/

There are four directories at /home/lasse/.local/lib/python2.7/site-packages/
they are kivy, cython, numpy and numpy-1.14.0.dist-info

I installed numpy with pip and I can import it anywhere.
kivy and cython imports work only in their directories, not elsewhere.

I have tried adding .bashrc this:
PYTHONPATH="${PYTHONPATH}:/home/lasse/.local/lib/python2.7/site-packages/kivy:/home/lasse/.local/lib/python2.7/site-packages/cython"
export PYTHONPATH

It does not work.

I also tried this:
import sys
sys.path.append('/home/lasse/.local/lib/python2.7/site-packages/cython')
It works, but it does not solve the problem.

Appreciate help
1. which GNU/Linux distro are you using.

2. always use package manager numpy. Unless you using different python version then system.

3. cython is a programming language. Normal install with package manager.
cython code is compile. Then you can import code to python.
Linux distro is Ubuntu 17.10
instead installing by source.
Kivy install docs

use package manager to install cython.
use package manager to install numpy.
sudo apt-get install cython
pip install numpy
or you could do
sudo apt-get install python-numpy
then download and setup buildozer (which is kivy's app for installing itself and dependencies and allows easy changes when creating APK files)
git clone https://github.com/kivy/buildozer
cd buildozer
sudo python setup.py install
EDIT:
Quote:apparently they now buidozer doesnt download the NDK for you, they want you to download it from
https://www.crystax.net/en/download
and extract it, and change the spec file to its directory path.
# Point to the directory where you extracted the crystax-ndk:
android.ndk_path = <Your install path here. Use ~ for home DIR>

go into your app directory and execute
buildozer init
buildozer android debug deploy run
the first time will take a long time as its installing SDK, NDK, etc. You can add --verbose arg to see what is going on. But every other time after that will be quick.

To test on PC, download for your architecture and OS.
https://kivy.org/#download
and then
sudo python setup.py install
python [SCRIPTNAME]
Don't use PYTHONPATH, it is not compatible with having several python interpreters. The better alternatives are using files usercustomize.py and sitecustomize.py. That said, follow above advices first.
What confuses me is this: Why does not import work?
Directories (kivy, cython and numpy) are at same directory.
/home/lasse/.local/lib/python2.7/site-packages/
|kivy |cyton |numpy

And only numpy (installed with pip) can be imported.
Dont attempt to manually move things to site-packages because you are just going to do it wrong. pip is going to install it properly, which is why numpy is the only one that works for you.

install kivy
sudo add-apt-repository ppa:kivy-team/kivy
sudo apt-get update
sudo apt-get install kivy
install cython
sudo apt-get install cython 
Have you looked at the documentation?
Yes I have.
I just wanted to test the latest dev versions.