using GTKAgg backend on python 3.5 (anaconda) and centos 7 - python

I tried to use GTKAgg as back-end for matplotlib package.
matplotlib.use('GTKAgg')
Failed to enable GUI event loop integration for 'gtk'
Traceback (most recent call last):
File "/home/oshri/.pycharm_helpers/pydev/_pydev_bundle/pydev_console_utils.py", line 569, in do_enable_gui
enable_gui(guiname)
File "/home/oshri/.pycharm_helpers/pydev/pydev_ipython/inputhook.py", line 528, in enable_gui
return gui_hook(app)
File "/home/oshri/.pycharm_helpers/pydev/pydev_ipython/inputhook.py", line 244, in enable_gtk
from pydev_ipython.inputhookgtk import create_inputhook_gtk
File "/home/oshri/.pycharm_helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "/home/oshri/.pycharm_helpers/pydev/pydev_ipython/inputhookgtk.py", line 19, in <module>
import gtk, gobject # #UnresolvedImport
File "/home/oshri/.pycharm_helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
ImportError: No module named 'gtk'
I tried to install the gtk using conda, using this repo, the conda outputs that the package is installed.
import conda.cli
conda.cli.main('conda','install','-c','ska','pygtk=2.16.0')
Fetching package metadata .............
Solving package specifications: .
# All requested packages already installed.
# packages in environment at /data/anaconda:
#
pygtk 2.16.0 0 ska
When I tried to install the pygtk using pip I got this error.
[oshri#analytics ~]$ pip install pygtk
Collecting pygtk
Using cached pygtk-2.24.0.tar.bz2
Complete output from command python setup.py egg_info:
********************************************************************
* Building PyGTK using distutils is only supported on windows. *
* To build PyGTK in a supported way, read the INSTALL file. *
********************************************************************
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-x78h7u1k/pygtk/
When I tried to use python2.7 I success to import the model.
[oshri#analytics ~]$ /bin/python2.7
Python 2.7.5 (default, Nov 6 2016, 00:28:07)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygtk
>>> exit()
For this reason I think that the issue is related to the python version.
I tried to use this guide but I didn't succeed to use JHBuild.
[oshri#analytics ~]$ jhbuild build pygobject
Required packages:
System installed packages which are too old:
(none)
No matching system package installed:
itstool
libffi (libffi.pc, required=3.0.0)
python3-devel (python3.pc, required=3.2)
libxslt (libxslt.pc, required=1.1.26)
cairo (cairo.pc, required=1.14.0)
libxml2 (libxml-2.0.pc, required=2.7.8)
jhbuild build: Required system dependencies not installed. Install using the command 'jhbuild sysdeps --install' or to ignore system dependencies use command-line option --nodeps
[oshri#analytics ~]$ jhbuild build sysdeps --install pygobject
Usage: jhbuild build [ options ... ] [ modules ... ]
jhbuild: error: no such option: --install
[oshri#analytics ~]$ jhbuild sysdeps --install pygobject
System installed packages which are new enough:
zlib (zlib.pc, installed=1.2.7)
automake
docbook-xml
docbook-xsl
libtool
pkg-config
cc
make
git
xmlcatalog
bison (required=2.4)
intltool (required=0.50.2)
xmllint
xsltproc
libpcre (libpcre.pc, required=8.31, installed=8.32)
flex (required=2.0)
Required packages:
System installed packages which are too old:
(none)
No matching system package installed:
itstool
libxml2 (libxml-2.0.pc, required=2.7.8)
libxslt (libxslt.pc, required=1.1.26)
cairo (cairo.pc, required=1.14.0)
libffi (libffi.pc, required=3.0.0)
python3-devel (python3.pc, required=3.2)
Optional packages: (JHBuild will build the missing packages)
System installed packages which are too old:
(none)
No matching system package installed:
I: Installing dependencies on system: itstool libxml2 libxslt cairo libffi python3-devel
I: Computing packages to install. This might be slow. Please wait.
I: Installing:
itstool;1.2.0-4.el7;noarch;base
libffi-devel;3.0.13-18.el7;x86_64;base
python34-devel;3.4.5-4.el7;x86_64;epel
cairo-devel;1.14.2-1.el7;x86_64;base
libxml2-devel;2.9.1-6.0.1.el7_2.3;x86_64;ol7_latest
libxslt-devel;1.1.28-5.0.1.el7;x86_64;ol7_latest
I: This might take a very long time. Do not turn off your computer. You can run `pkmon' to monitor progress.
E: PackageKit: Failed to obtain authentication.
I: Complete!
[oshri#analytics ~]$ sudo jhbuild sysdeps --install pygobject
[sudo] password for oshri:
sudo: jhbuild: command not found
I'm right that issues related to python version?
Should I install JHBuild under root user?

Related

Unable to install PyQt5 with pip

Im running into a problem installing PyQt5 with pip:
pip install pyqt5
DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621
Collecting pyqt5
Using cached PyQt5-5.15.6.tar.gz (3.2 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... error
ERROR: Command errored out with exit status 1:
command: /opt/homebrew/opt/python#3.9/bin/python3.9 /opt/homebrew/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py prepare_metadata_for_build_wheel /var/folders/rv/nylh_sjx44b1bq2pmbn1lwkr0000gn/T/tmpi8zk3o59
cwd: /private/var/folders/rv/nylh_sjx44b1bq2pmbn1lwkr0000gn/T/pip-install-9w2kcz7l/pyqt5_a170d636f15d43c8bb4ae5d9a73574fc
Complete output (24 lines):
Querying qmake about your Qt installation...
/opt/homebrew/bin/qmake -query
Traceback (most recent call last):
File "/opt/homebrew/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 156, in prepare_metadata_for_build_wheel
hook = backend.prepare_metadata_for_build_wheel
AttributeError: module 'sipbuild.api' has no attribute 'prepare_metadata_for_build_wheel'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/homebrew/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
main()
File "/opt/homebrew/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/opt/homebrew/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 160, in prepare_metadata_for_build_wheel
whl_basename = backend.build_wheel(metadata_directory, config_settings)
File "/private/var/folders/rv/nylh_sjx44b1bq2pmbn1lwkr0000gn/T/pip-build-env-fyh98wta/overlay/lib/python3.9/site-packages/sipbuild/api.py", line 51, in build_wheel
project = AbstractProject.bootstrap('pep517')
File "/private/var/folders/rv/nylh_sjx44b1bq2pmbn1lwkr0000gn/T/pip-build-env-fyh98wta/overlay/lib/python3.9/site-packages/sipbuild/abstract_project.py", line 83, in bootstrap
project.setup(pyproject, tool, tool_description)
File "/private/var/folders/rv/nylh_sjx44b1bq2pmbn1lwkr0000gn/T/pip-build-env-fyh98wta/overlay/lib/python3.9/site-packages/sipbuild/project.py", line 603, in setup
self.update(tool)
File "project.py", line 160, in update
sipbuild.exceptions.UserException
----------------------------------------
Im using macOS Monterey 12.0.1, with the Apple M1 chip.
What I've tried so far:
Installed PyQt5 using homebrew. Result: PyQt5 got installed via brew but without the necessary package PyQtWebengine. Means when I try to run my application, I receive the error message, that PyQtWebengine package/module is not installed which Im not able to install with pip. So I uninstalled it.
Installed sip and uninstalled
qt (6.2.2) and qt#5 (5.15.2) are installed with brew
Run cmd: python3 -m pip install PyQt5
Pip is up to date (21.3.1)
pip install with a specific PyQt5 Version
Any ideas to solve this problem?
Thanks in advance for any ideas/solutions!
The way I solved the same problem in my M1s was installing the library via terminal launched in Rosetta mode (left click on the Terminal icon -> Get Info -> Open in Rosetta).
So, detailed steps are:
Open a Terminal with Rosetta 2 via left click on the Terminal icon -> Get Info -> Open in Rosetta (https://dev.to/courier/tips-and-tricks-to-setup-your-apple-m1-for-development-547g)
Use non-homebrew python (mine was in /usr/bin/python3) to create virtual environment
$ /usr/bin/python3 -m venv venv
$ source venv/bin/activate
Upgrade pip
(venv)$ pip install --upgrade pip
Install PyQt5
(venv) $pip install PyQt5
Alternatively, you can do a one-off installation via this command:
$ arch -x86_64 python -m pip install PyQt5
I use macos 12.1 (m1), and I use mini-forge with homebrew, I have installed pyqt5 with conda install pyqt.
P.S. my python version is 3.9.
conda create -n py3.9.13 python=3.9.13
conda install pyqt
Worked for me. I'm using macOS Monterey 12.4, with the Apple M1 chip. Anaconda3 installed many dependences automatically while installing. After the above installation, my conda list:
# Name Version
bzip2 1.0.8
ca-certificates 2022.6.15
gettext 0.19.8.1
glib 2.70.2
glib-tools 2.70.2
gst-plugins-base 1.20.3
gstreamer 1.20.3
icu 70.1
jpeg 9e
krb5 1.19.3
libclang 14.0.6
libclang13 14.0.6
libcxx 14.0.6
libedit 3.1.20191231
libffi 3.4.2
libglib 2.70.2
libiconv 1.16
libllvm14 14.0.6
libogg 1.3.4
libopus 1.3.1
libpng 1.6.37
libpq 14.4
libvorbis 1.3.7
libzlib 1.2.12
lz4-c 1.9.3
mysql-common 8.0.29
mysql-libs 8.0.29
ncurses 6.3
nspr 4.32
nss 3.78
openssl 1.1.1p
packaging 21.3
pcre 8.45
pip 22.1.2
ply 3.11
pyparsing 3.0.9
pyqt 5.15.4
pyqt5-sip 12.9.0
python 3.9.13
python_abi 3.9
qt-main 5.15.4
readline 8.1.2
setuptools 62.6.0
sip 6.6.2
sqlite 3.39.0
tk 8.6.12
toml 0.10.2
tzdata 2022a
wheel 0.37.1
xz 5.2.5
zlib 1.2.12
zstd 1.5.2
As I answered here, Rosetta is not required if you're willing to use Homebrew's pyqt#5. Homebrew includes an arm64-compiled pyqt5, and one can leverage its installation in a venv using the --system-site-packages flag to venv:
$ # Install pyqt5 via homebrew
$ brew install pyqt#5
$ # Note that it's installed in python3.9, not 3.10
$ brew cat pyqt#5 | grep 'depends_on.*python'
depends_on "python#3.9"
$ # Make a python3.9 virtualenv with access to the system's site-packages
$ /opt/homebrew/bin/python3.9 -m venv --system-site-packages .venv
$ source .venv/bin/activate

pip not installing numba/llvmlite properly within conda environment

I create a new conda environment
user#machine:~/project$ conda create -n test-env -c numba python=3.5.2 llvmdev=3.8
Fetching package metadata ...........
Solving package specifications: .
Package plan for installation in environment /home/user/anaconda2/envs/test-env:
The following NEW packages will be INSTALLED:
llvmdev: 3.8.1-7 numba
openssl: 1.0.2k-0
pip: 9.0.1-py35_1
python: 3.5.2-0
readline: 6.2-2
setuptools: 27.2.0-py35_0
sqlite: 3.13.0-0
system: 5.8-2 numba
tk: 8.5.18-0
wheel: 0.29.0-py35_0
xz: 5.2.2-1
zlib: 1.2.8-3
Proceed ([y]/n)? y
#
# To activate this environment, use:
# > source activate test-env
#
# To deactivate this environment, use:
# > source deactivate test-env
#
and then activate it and attempt to use specifically pip (not conda) to install llvmlite and numba, which appears to succeed. (Note: I've tried also --no-cache-dir and it doesn't change anything.)
user#machine:~/project$ source activate test-env
(test-env) user#machine:~/project$ pip install llvmlite==0.15 numba==0.30.1
Collecting llvmlite==0.15
Collecting numba==0.30.1
Collecting numpy (from numba==0.30.1)
Using cached numpy-1.12.0-cp35-cp35m-manylinux1_x86_64.whl
Installing collected packages: llvmlite, numpy, numba
Successfully installed llvmlite-0.15.0 numba-0.30.1 numpy-1.12.0
But the library is not installed properly,
(test-env) user#machine:~/project$ python
Python 3.5.2 |Continuum Analytics, Inc.| (default, Jul 2 2016, 17:53:06)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numba
Traceback (most recent call last):
File "/home/user/anaconda2/envs/test-env/lib/python3.5/site-packages/llvmlite/binding/ffi.py", line 42, in <module>
lib = ctypes.CDLL(os.path.join(_lib_dir, _lib_name))
File "/home/user/anaconda2/envs/test-env/lib/python3.5/ctypes/__init__.py", line 347, in __init__
self._handle = _dlopen(self._name, mode)
OSError: /home/user/anaconda2/envs/test-env/lib/python3.5/site-packages/llvmlite/binding/libllvmlite.so: undefined symbol: _ZNKSt14error_category23default_error_conditionEi
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/user/anaconda2/envs/test-env/lib/python3.5/site-packages/numba/__init__.py", line 9, in <module>
from . import config, errors, runtests, types
File "/home/user/anaconda2/envs/test-env/lib/python3.5/site-packages/numba/config.py", line 11, in <module>
import llvmlite.binding as ll
File "/home/user/anaconda2/envs/test-env/lib/python3.5/site-packages/llvmlite/binding/__init__.py", line 6, in <module>
from .dylib import *
File "/home/user/anaconda2/envs/test-env/lib/python3.5/site-packages/llvmlite/binding/dylib.py", line 4, in <module>
from . import ffi
File "/home/user/anaconda2/envs/test-env/lib/python3.5/site-packages/llvmlite/binding/ffi.py", line 47, in <module>
lib = ctypes.CDLL(_lib_name)
File "/home/user/anaconda2/envs/test-env/lib/python3.5/ctypes/__init__.py", line 347, in __init__
self._handle = _dlopen(self._name, mode)
OSError: libllvmlite.so: cannot open shared object file: No such file or directory
Why does the conda installation of llvmdev from the numba channel fail to "just work".
In my use case, I'm coming to a project that has a pip-styled requirements.txt file, and I need to create conda environments from that file. Some project developers will use venv+pip, some will use conda, and some packages it contains are not found in any anaconda channels, so pip installation is mandatory. We don't want to maintain a separate envrionment.yaml in addition to the requirements.txt, so installing from requirements.txt inside of a conda envrionment is part of my constraints.
Everything seems OK, except for the pip installation of numba/llvmlite, which expects a system dependency of llvm 3.8+. I want to satisfy that as part of the conda environment though.
How can I ensure from a conda environment only that the right llvmdev exists for installing numba and llvmlite?
Installing llvmdev:
Installing llvmdev from the conda-forge channel can be achieved by adding conda-forge to your channels with:
conda config --add channels conda-forge
Once the conda-forge channel has been enabled, llvmdev can be installed with:
conda install llvmdev
It is possible to list all of the versions of llvmdev available on your platform with:
conda search llvmdev --channel conda-forge
HELP:I cloned the relevant files from their GitHub sources and did
python setup.py install
for more without conda use pip
sudo pip install -U llvmlite
sudo pip install -U numba
This is what worked for me using the Anaconda environment:
pip uninstall llvmlite
pip install -U --ignore-installed numba
In an ideal scenario, the required shared library should be present after the installation of llvmlite.
(test-env) ~/condaexpts$ conda create -n test-env -c numba python=3.5.2 llvmdev=3.8
(test-env) ~/condaexpts$ source activate test-env
(test-env) ~/condaexpts$ pip install numpy==1.12.0 llvmlite==0.15 numba==0.30.1
(test-env) ~/condaexpts$ find $CONDA_PREFIX | grep libllvmlite
/home/ubuntu/condaexpts/m3/envs/test-env/lib/python3.5/site-packages/llvmlite/binding/libllvmlite.so
If this file is not present in the test-env, then something went wrong while installing llvmlite.
Also, think about this approach the other way round. You don't need to have a requirements file separate from conda environment file. You can have both dependencies in the conda environment file itself:
(test-env) ~/condaexpts$ conda env export
name: test-env
channels:
- !!python/unicode
'numba'
- !!python/unicode
'defaults'
dependencies:
- !!python/unicode
'openssl=1.0.2k=0'
- !!python/unicode
'pip=9.0.1=py35_1'
- !!python/unicode
'python=3.5.2=0'
- !!python/unicode
'readline=6.2=2'
- !!python/unicode
'setuptools=27.2.0=py35_0'
- !!python/unicode
'sqlite=3.13.0=0'
- !!python/unicode
'tk=8.5.18=0'
- !!python/unicode
'wheel=0.29.0=py35_0'
- !!python/unicode
'xz=5.2.2=1'
- !!python/unicode
'zlib=1.2.8=3'
- !!python/unicode
'llvmdev=3.8.1=7'
- !!python/unicode
'system=5.8=2'
- pip:
- llvmlite==0.15.0
- numba==0.30.1
- numpy==1.12.0
prefix: !!python/unicode '/home/ubuntu/condaexpts/m3/envs/test-env'
On second note, you can install the pre-built binaries required from the 'numba' conda channel itself. With:
(root) ~/condaexpts$ ./Miniconda3-latest-Linux-x86_64.sh -b -p m3
(root) ~/condaexpts$ source ./m3/bin/activate
(root) ~/condaexpts$ conda create -n test-env -c numba python=3.5.2 llvmdev=3.8 numba=0.30.1 llvmlite=0.15.0
(root) ~/condaexpts$ source activate test-env
(test-env) ~/condaexpts$ python
Python 3.5.2 |Continuum Analytics, Inc.| (default, Jul 2 2016, 17:53:06)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numba
>>> numba.__version__
'0.30.1'

Matplotlib not installing inside virtualenv mac

So I have Python 3 and matplotlib installed globally. If I run python outside of a virtual environment and import matplotlib to check the version it shows 1.5.1 . But I am facing problems installing matplotlib within a virtual environment. I created a virtual environment using the command python3 -m venv ds and activated ds. These are the contents of my requirements.txt
matplotlib==1.4.2
numpy==1.9.1
When I do pip3 install -r requirements.txt I get this
Collecting matplotlib==1.4.2 (from -r requirements.txt (line 1))
Using cached matplotlib-1.4.2.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 20, in <module>
File "/private/var/folders/ym/gfrm424x31j4vd944cdhn4hr0000gn/T/pip-build-pcfq8bhb/matplotlib/setup.py", line 155, in <module>
result = package.check()
File "/private/var/folders/ym/gfrm424x31j4vd944cdhn4hr0000gn/T/pip-build-pcfq8bhb/matplotlib/setupext.py", line 962, in check
min_version='2.3', version=version)
File "/private/var/folders/ym/gfrm424x31j4vd944cdhn4hr0000gn/T/pip-build-pcfq8bhb/matplotlib/setupext.py", line 446, in _check_for_pkg_config
if (not is_min_version(version, min_version)):
File "/private/var/folders/ym/gfrm424x31j4vd944cdhn4hr0000gn/T/pip-build-pcfq8bhb/matplotlib/setupext.py", line 174, in is_min_version
return found_version >= expected_version
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/distutils/version.py", line 70, in __ge__
c = self._cmp(other)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/distutils/version.py", line 337, in _cmp
if self.version < other.version:
TypeError: unorderable types: str() < int()
IMPORTANT WARNING:
pkg-config is not installed.
matplotlib may not be able to find some of its dependencies
============================================================================
Edit setup.cfg to change the build options
BUILDING MATPLOTLIB
matplotlib: yes [1.4.2]
python: yes [3.5.1 (v3.5.1:37a07cee5969, Dec 5 2015,
21:12:44) [GCC 4.2.1 (Apple Inc. build 5666) (dot
3)]]
platform: yes [darwin]
REQUIRED DEPENDENCIES AND EXTENSIONS
numpy: yes [version 1.10.4]
six: yes [using six version 1.10.0]
dateutil: yes [dateutil was not found. It is required for date
axis support. pip/easy_install may attempt to
install it after matplotlib.]
pytz: yes [pytz was not found. pip will attempt to install
it after matplotlib.]
tornado: yes [tornado was not found. It is required for the
WebAgg backend. pip/easy_install may attempt to
install it after matplotlib.]
pyparsing: yes [pyparsing was not found. It is required for
mathtext support. pip/easy_install may attempt to
install it after matplotlib.]
pycxx: yes [Official versions of PyCXX are not compatible
with matplotlib on Python 3.x, since they lack
support for the buffer object. Using local copy]
libagg: yes [pkg-config information for 'libagg' could not
be found. Using local copy.]
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/ym/gfrm424x31j4vd944cdhn4hr0000gn/T/pip-build-pcfq8bhb/matplotlib
You are using pip version 7.1.2, however version 8.0.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
How should I install matplotlib version 1.4.2 in virtual environment ?
My question has been marked as duplicate but that link doesn't solve my question. The solution given is for Ubuntu
I was able to do it by solving the dependencies for matplotlib,
(if you have brew installed)
then first do brew install freetype followed by brew install ttfautohint --with-qt. After that try again to pip install.
You can use the system package in your virtualenv with this option.
Otherwise, this SO post may help you.

Install GDAL in virtualenvwrapper environment

I tried to install gdal (pip install gdal)in virtualenvwrapper environment but I got this error :
error: command 'gcc' failed with exit status 1
----------------------------------------
Failed building wheel for gdal
Failed to build gdal
I tried also "pip install --no-install GDAL" but there is nooption --no-install
what should I do !?
Yes, installing GDAL in a venv is a doozy. Conveniently, I just wrote up the documentation on how to do so for my advisor's lab! While I am not savvy enough to pinpoint the exact cause of your error, I can give you a bunch of things to try to fix it.
First, ensure you have gdal installed on the host (i.e. not in a venv). I just run the following:
sudo apt-get install libgdal1i libgdal1-dev libgdal-dev
Now run gdal-config --version to get the version that apt-get provided you with. For example I get 1.11.3
Now, the easiest way in my experience to get the python bindings in a venv is using pygdal. The trick is to get the right version! To do so, activate your virtual environment and run
pip install pygdal==1.11.3
but replace the version with whatever you got from gdal-config --version. Note: you may get an error that says
Could not find a version that satisfies the requirement pygdal==1.11.3 (from versions: 1.8.1.0, 1.8.1.1, 1.8.1.2, 1.8.1.3, 1.9.2.0, 1.9.2.1, 1.9.2.3, 1.10.0.0, 1.10.0.1, 1.10.0.3, 1.10.1.0, 1.10.1.1, 1.10.1.3, 1.11.0.0, 1.11.0.1, 1.11.0.3, 1.11.1.0, 1.11.1.1, 1.11.1.3, 1.11.2.1, 1.11.2.3, 1.11.3.3, 1.11.4.3, 2.1.0.3) No matching distribution found for pygdal==1.11.3
If that happens, run the pip install again but with the highest version that still matches. e.g. in this case you would run pip install pygdal==1.11.3.3
Once pygdal has been successfully installed, you should be able to call
>>> from osgeo import gdal
Please let me know if anything fails and I'll do what I can to adjust my instructions. Also, if you need help with Proj.4, GEOS, or Cartopy, I have some experience there too.
use pygdal
pd#asghar:~$sudo apt-get install python3-gdal
pd#asghar:~$ virtualenv -p python3 test
Running virtualenv with interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in /home/pd/test/bin/python3
Also creating executable in /home/pd/test/bin/python
Installing setuptools, pip, wheel...done.
pd#asghar:~$ gdal-config --version
2.1.3
pd#asghar:~$ test/bin/pip install pygdal==2.1.3
Collecting pygdal==2.1.3
Could not find a version that satisfies the requirement pygdal==2.1.3 (from versions: 1.8.1.0, 1.8.1.1, 1.8.1.2, 1.8.1.3, 1.9.2.0, 1.9.2.1, 1.9.2.3, 1.10.0.0, 1.10.0.1, 1.10.0.3, 1.10.1.0, 1.10.1.1, 1.10.1.3, 1.11.0.0, 1.11.0.1, 1.11.0.3, 1.11.1.0, 1.11.1.1, 1.11.1.3, 1.11.2.1, 1.11.2.3, 1.11.3.3, 1.11.4.3, 1.11.5.3, 2.0.0.3, 2.0.1.3, 2.0.2.3, 2.0.3.3, 2.1.0.3, 2.1.1.3, 2.1.2.3, 2.1.3.3, 2.2.0.3)
No matching distribution found for pygdal==2.1.3
pd#asghar:~$ test/bin/pip install pygdal==2.1.3.3
Collecting pygdal==2.1.3.3
Collecting numpy>=1.0.0 (from pygdal==2.1.3.3)
Using cached numpy-1.13.1-cp35-cp35m-manylinux1_x86_64.whl
Installing collected packages: numpy, pygdal
Successfully installed numpy-1.13.1 pygdal-2.1.3.3
pd#asghar:~$ source test/bin/activate
(test) pd#asghar:~$ python
Python 3.5.2 (default, Nov 17 2016, 17:05:23)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from osgeo import gdal
>>>
On MacOS, first do brew install:
brew install gdal
Then do pip install:
pip install gdal

How to install pygtk within virtualenv?

I installed ipython in a virtual env (1.13 with 2.7.2) and tried ipython -gui=gtk but still got the basic terminal interface with no %paste support for example.
Now I tried installing pygtk but no success there either.
I'm running Crunchbang linux with OpenBox WM.
[TerminalIPythonApp] GUI event loop or pylab initialization failed
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
...python2.7/local/lib/python2.7/site-packages/IPython/lib/inputhook.pyc in enable_gui(gui, app)
526 e = "Invalid GUI request %r, valid ones are:%s" % (gui, guis.keys())
527 raise ValueError(e)
--> 528 return gui_hook(app)
529
...python2.7/local/lib/python2.7/site-packages/IPython/lib/inputhook.pyc in enable_gtk(self, app)
286 IPython.
287 """
--> 288 import gtk
289 try:
290 gtk.set_interactive(True)
ImportError: No module named gtk
I've tried to pip install pygtk within the virtualenv I've activated but no luck.
Full log:
$ pip install pygtk
Downloading/unpacking pygtk
Downloading pygtk-2.24.0.tar.bz2 (2.4MB): 2.4MB downloaded
Running setup.py egg_info for package pygtk
********************************************************************
* Building PyGTK using distutils is only supported on windows. *
* To build PyGTK in a supported way, read the INSTALL file. *
********************************************************************
Complete output from command python setup.py egg_info:
********************************************************************
* Building PyGTK using distutils is only supported on windows. *
* To build PyGTK in a supported way, read the INSTALL file. *
********************************************************************
----------------------------------------
Command python setup.py egg_info failed with error code 1 in ...python2.7/build/pygtk
Since you are running a debian-based distribution; you can save yourself some headaches and simply sudo apt-get install ipython (and sudo apt-get install ipython3 if you want to play with Python 3).
This will ensure that the proper GTK bindings are installed as well. This is the most supported way.
Latest versions of ipython have auto-detection of virtualenvironments.
I first installed gi with pip (on ubuntu) and got the same error, without a virtualenv. My solution was to uninstall gi:
sudo -H pip uninstall gi
and then install using:
sudo apt-get install --reinstall python-gi

Categories