libspatialindex and Rtree on python - python-2.7

Okay, so I am trying to install libspatialspatialindex to my Ubuntu machine python. I did follow all the instructions and downloaded libspatialindex1_1.4.0-1.1_amd64.deb from http://packages.ubuntu.com/lucid/libspatialindex1 and downloaded the amd64 version of it as my machine is 64bits machine. I installed it and then jumped to Rtree python https://pypi.python.org/pypi/Rtree to download and install the Rtree in python. I followed the installation instruction given in the install.txt file inside the folder. It says run the local setup.py by $ python setup.py install I did that as well but what I get after that is
`root#ubuntu:/# cd /home/neelabh/Desktop/Rtree
root#ubuntu:/home/neelabh/Desktop/Rtree# python setup.py install
Traceback (most recent call last):
File "setup.py", line 4, in <module>
import rtree
File "/home/neelabh/Desktop/Rtree/rtree/__init__.py", line 1, in <module>
from .index import Rtree
File "/home/neelabh/Desktop/Rtree/rtree/index.py", line 6, in <module>
from . import core
File "/home/neelabh/Desktop/Rtree/rtree/core.py", line 110, in <module>
rt.Error_GetLastErrorNum.restype = ctypes.c_int
File "/usr/lib/python2.7/ctypes/__init__.py", line 378, in __getattr__
func = self.__getitem__(name)
File "/usr/lib/python2.7/ctypes/__init__.py", line 383, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: python: undefined symbol: Error_GetLastErrorNum`
Can somebody please help me in resolving this issue!
I really appreciate in advance!

You have to install the package "libspatialindex-dev" with the systems package manager. At least this is true with my system (Mint 17.1) which should be 100% compatible to a default Ubuntu installation.

You have to install libspatialindex-dev in your ubuntu system. Here i am using ubuntu 16.04 or 18.04
sudo apt update
sudo apt install libspatialindex-dev
install Rtree using your python pip version, i have pip 3.7
pip3.7 install Rtree
import rtree

Related

Error when building torchaudio from source

I tried to build torchaudio from source by forking the main branch and then running setup.py. I created a conda environment to do these. I followed the instruction at https://github.com/pytorch/audio/blob/main/CONTRIBUTING.md
The command for installation is:
CC=<my_path_to_gcc> BUILD_SOX=1 USE_CUDA=1 python setup.py develop
The building log seems fine. When I try to import torchaudio I got the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/rds/project/rds-KQ4S3rlDzm8/gs534/audio/torchaudio/__init__.py", line 1, in <module>
from torchaudio import ( # noqa: F401
File "/rds/project/rds-KQ4S3rlDzm8/gs534/audio/torchaudio/_extension.py", line 103, in <module>
_init_extension()
File "/rds/project/rds-KQ4S3rlDzm8/gs534/audio/torchaudio/_extension.py", line 88, in _init_extension
_load_lib("libtorchaudio")
File "/rds/project/rds-KQ4S3rlDzm8/gs534/audio/torchaudio/_extension.py", line 51, in _load_lib
torch.ops.load_library(path)
File "/home/gs534/rds/hpc-work/work/espnet/tools/anaconda/envs/torchaudio/lib/python3.8/site-packages/torch/_ops.py", line 282, in load_library
ctypes.CDLL(path)
File "/home/gs534/rds/hpc-work/work/espnet/tools/anaconda/envs/torchaudio/lib/python3.8/ctypes/__init__.py", line 373, in __init__
self._handle = _dlopen(self._name, mode)
OSError: /rds/project/rds-KQ4S3rlDzm8/gs534/audio/torchaudio/lib/libtorchaudio.so: undefined symbol: gsm_create
This is my environment package list:
# packages in environment at /home/gs534/rds/hpc-work/work/espnet/tools/anaconda/envs/torchaudio:
#
# Name Version Build Channel
_libgcc_mutex 0.1 main
_openmp_mutex 5.1 1_gnu
blas 1.0 mkl
ca-certificates 2022.07.19 h06a4308_0
certifi 2022.6.15 py38h06a4308_0
cmake 3.24.0 pypi_0 pypi
cudatoolkit 11.3.1 h2bc3f7f_2
intel-openmp 2022.0.1 h06a4308_3633
ld_impl_linux-64 2.38 h1181459_1
libffi 3.3 he6710b0_2
libgcc-ng 11.2.0 h1234567_1
libgomp 11.2.0 h1234567_1
libstdcxx-ng 11.2.0 h1234567_1
mkl 2022.0.1 h06a4308_117
ncurses 6.3 h5eee18b_3
ninja 1.10.2.3 pypi_0 pypi
openssl 1.1.1q h7f8727e_0
pip 22.1.2 py38h06a4308_0
pkg-config 0.29.2 h1bed415_8
python 3.8.13 h12debd9_0
pytorch 1.13.0.dev20220808 py3.8_cuda11.3_cudnn8.3.2_0 pytorch-nightly
pytorch-mutex 1.0 cuda pytorch-nightly
readline 8.1.2 h7f8727e_1
setuptools 61.2.0 py38h06a4308_0
sqlite 3.39.2 h5082296_0
tk 8.6.12 h1ccaba5_0
torchaudio 0.13.0a0+b396157 dev_0 <develop>
typing_extensions 4.3.0 py38h06a4308_0
wheel 0.37.1 pyhd3eb1b0_0
xz 5.2.5 h7f8727e_1
zlib 1.2.12 h7f8727e_2
Can anyone help me with this problem?

how to install numba and link to llvm & llvmlite to import it in Python27

When I am trying to run python file .py that uses numba it gives me the below error
Traceback (most recent call last):
File "C:\Myfile.py", line 16, in <module>
import myfile2 as m
File "C:\myfile2.py", line 8, in <module>
import numba
File "C:\Python27\lib\site-packages\numba\__init__.py", line 9, in <module>
from . import config, errors, runtests, types
File "C:\Python27\lib\site-packages\numba\config.py", line 11, in <module>
import llvmlite.binding as ll
File "C:\Python27\lib\site-packages\llvmlite\binding\__init__.py", line 6, in <module>
from .dylib import *
File "C:\Python27\lib\site-packages\llvmlite\binding\dylib.py", line 4, in <module>
from . import ffi
File "C:\Python27\lib\site-packages\llvmlite\binding\ffi.py", line 50, in <module>
raise e
WindowsError: [Error 126] The specified module could not be found
I've tried to isntall numba from command propmt as below :
pip install numba
but it gives me a message that it already exists before
Requirements already satisfied...........etc
so could anyone help me to fix this error ? also How to install numba and link it with llvm and llvmlite ?
I've uninstall the python and re-install it again
and install the below packages in order
pip install scikit_learn
pip install numby+mkl
pip install scipy
pip install numba
pip install matplotlib
also I've installed mini conda and it is working fine as well

ImportError: libcusolver.so.8.0: cannot open shared object file: No such file or directory

Possible duplicate of this question.
I have a gpu account to whom I connect through putty (ssh login). I have created a virtualenv there and I am installing tenorflow through pip for gpu. Everything works fine, when I run command
$ pip list
following list is being shown:
backports.weakref (1.0rc1)
bleach (1.5.0)
funcsigs (1.0.2)
html5lib (0.9999999)
Markdown (2.6.8)
mock (2.0.0)
numpy (1.13.1)
olefile (0.44)
pbr (3.1.1)
Pillow (4.2.1)
pip (9.0.1)
protobuf (3.3.0)
setuptools (36.0.1)
six (1.10.0)
tensorflow-gpu (1.2.1)
Werkzeug (0.12.2)
wheel (0.29.0)
But when I run:
$ python
>>> import tensorflow
It shows the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/nauman/junaid/final/test/lib/python2.7/site-
packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/home/nauman/junaid/final/test/lib/python2.7/site-
packages/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/home/nauman/junaid/final/test/lib/python2.7/site-
packages/tensorflow/python/pywrap_tensorflow.py", line 52, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/home/nauman/junaid/final/test/lib/python2.7/site-
packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/nauman/junaid/final/test/lib/python2.7/site-
packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in
<module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/nauman/junaid/final/test/lib/python2.7/site-
packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in
swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname,
description)
ImportError: libcusolver.so.8.0: cannot open shared object file: No such
file or directory
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/install_sources#common_installation_problems
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
I have also set my environment variables like this:
export CUDA_HOME=/opt/cuda
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$CUDA_HOME/lib64:$CUDA_HOME/extras/CUPTI/lib64"
Moreover, I found that libcusolver.so.8.0 is not there, while libcusolver.so.7.5
is there in cuda/lib64/.
Somehow tensorflow is finding wrong file or I ain't know nothing.
Any help would be appreciated as I am new to all this stuff.
Python version: 2.7
OS: Linux
This may be connected to the incorrect linking of your libraries.
Simply run sudo ldconfig /usr/local/cuda/lib64. It solved for me.
If you need to know more: ldconfig man page.
I solved the issue. Actually I have cuda 7.5 installed and I was installing latest tensorflow version which probably support cuda 8.0.
So I downgraded.
pip install --upgrade \ https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.10.0-cp27-none-linux_x86_64.whl
If you installed tensorflow-gpu by using pip with prebuilt .whl, the cuda version were fixed. As far as I know, starting 0.11.0rc1, all the prebuilt packages are now built for cuda 8. So there are two ways to solve the problem:
install cuda 8 for the prebuilt packages tensorflow-gpu >= 0.11.orc1
keep cuda 7.5 stay, then build tensorflow-gpu from source code
If you are using cuda-9.0 try sudo apt install nvidia-cuda-dev (if you are using an Ubuntu distribution)

trouble importing skllearn

Hi i have installed the Scikit-learn but i keep getting error msgs when i try to import the sklearn module. it shows the following msg. anyone knows what's going on?
import sklearn
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "sklearn/__init__.py", line 31, in <module>
from . import __check_build
File "sklearn/__check_build/__init__.py", line 46, in <module>
raise_build_error(e)
File "sklearn/__check_build/__init__.py", line 41, in raise_build_error
%s""" % (e, local_dir, ''.join(dir_content).strip(), msg))
ImportError: No module named _check_build
___________________________________________________________________________
Contents of sklearn/__check_build:
__init__.py __init__.pyc _check_build.c
_check_build.pyx setup.py setup.pyc
___________________________________________________________________________
It seems that scikit-learn has not been built correctly.
If you have installed scikit-learn from source, please do not forget
to build the package before using it: run `python setup.py install` or
`make` in the source directory.
If you have used an installer, please check that it is suited for your
Python version, your operating system and your platform.
As you can see in your errors: ImportError: No module named _check_build in that directory it has .c file and it never compiled.
If you check this link you will see many parts of scikit-learn has been written in C.
So for installing this kind of packages , you need to install python-dev package in your system.
python-dev package will install many C headers like python.h.
So install python-dev package in your system and then remove and install scikit-learn package again.

Problems running Cython

I'm trying to run cython with Python2.7 installed using OSX running Mountain Lion but I get the following errors:
Traceback (most recent call last):
File "/usr/local/bin/cython", line 5, in <module>
from pkg_resources import load_entry_point
File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py", line 2603, in <module>
working_set.require(__requires__)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py", line 666, in require
needed = self.resolve(parse_requirements(requirements))
File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py", line 565, in resolve
raise DistributionNotFound(req) # XXX put more info here
pkg_resources.DistributionNotFound: Cython==0.17
How can I fix this?
Thanks!
Probably what happened is that you installed cython with one version of python and are trying to run it with another. Rather than doing the standard
python setup.py build
sudo python setup.py install
Try just switching to root and both building and installing using an explicit version of python:
sudo su
/usr/bin/python setup.py build
/usr/bin/python setup.py install
(Note that this all assumes that you're installing from a source tarball).