Python Forum
Installing from source and getting import working in linux
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Installing from source and getting import working in linux
#1
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
Reply
#2
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.
99 percent of computer problems exists between chair and keyboard.
Reply
#3
Linux distro is Ubuntu 17.10
Reply
#4
instead installing by source.
Kivy install docs

use package manager to install cython.
use package manager to install numpy.
99 percent of computer problems exists between chair and keyboard.
Reply
#5
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]
Recommended Tutorials:
Reply
#6
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.
Reply
#7
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.
Reply
#8
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 
Recommended Tutorials:
Reply
#9
Have you looked at the documentation?
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#10
Yes I have.
I just wanted to test the latest dev versions.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  import pandas as pd not working in pclinuxos loren41 3 2,269 May-19-2019, 03:49 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020