Installing GDAL on Google Cloud Datalab - installation

I am having trouble installing GDAL on Google Cloud Datalab. When I run:
!pip install gdal
I get the following error
Collecting gdal
Using cached GDAL-2.2.4.tar.gz
Complete output from command python setup.py egg_info:
running egg_info
creating pip-egg-info/GDAL.egg-info
writing pip-egg-info/GDAL.egg-info/PKG-INFO
writing top-level names to pip-egg-info/GDAL.egg-info/top_level.txt
writing dependency_links to pip-egg-info/GDAL.egg-
info/dependency_links.txt
writing manifest file 'pip-egg-info/GDAL.egg-info/SOURCES.txt'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-umhRKK/gdal/setup.py", line 342, in <module>
**extra )
File "/usr/local/lib/python2.7/dist-packages/setuptools/__init__.py",
line 129, in setup
return distutils.core.setup(**attrs)
File "/usr/lib/python2.7/distutils/core.py", line 151, in setup
dist.run_commands()
File "/usr/lib/python2.7/distutils/dist.py", line 953, in
run_commands
self.run_command(cmd)
File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/usr/local/lib/python2.7/dist-packages/setuptools/command/egg_info.py", line 278, in run
self.find_sources()
File "/usr/local/lib/python2.7/dist-packages/setuptools/command/egg_info.py", line 293, in find_sources
mm.run()
File "/usr/local/lib/python2.7/dist-packages/setuptools/command/egg_info.py", line 524, in run
self.add_defaults()
File "/usr/local/lib/python2.7/dist-packages/setuptools/command/egg_info.py", line 560, in add_defaults
sdist.add_defaults(self)
File "/usr/local/lib/python2.7/dist-packages/setuptools/command/py36compat.py", line 36, in add_defaults
self._add_defaults_ext()
File "/usr/local/lib/python2.7/dist-packages/setuptools/command/py36compat.py", line 119, in _add_defaults_ext
build_ext = self.get_finalized_command('build_ext')
File "/usr/lib/python2.7/distutils/cmd.py", line 312, in get_finalized_command
cmd_obj.ensure_finalized()
File "/usr/lib/python2.7/distutils/cmd.py", line 109, in ensure_finalized
self.finalize_options()
File "/tmp/pip-build-umhRKK/gdal/setup.py", line 217, in finalize_options
self.gdaldir = self.get_gdal_config('prefix')
File "/tmp/pip-build-umhRKK/gdal/setup.py", line 191, in get_gdal_config
return fetch_config(option)
File "/tmp/pip-build-umhRKK/gdal/setup.py", line 144, in fetch_config
raise gdal_config_error, e""")
File "<string>", line 4, in <module>
__main__.gdal_config_error: [Errno 2] No such file or directory
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-umhRKK/gdal/
Same thing goes for :
!pip install gdal==2.2
or:
!pip install python-gdal
and a few other similar commands I have tried. The fix I discovered which was to update the setup-tools still gives me this problem after updating it.
What is the problem?

As per the Datalab documentation on how to add a Python library to Cloud Datalab, there are three approaches that you can follow to perform an installation of a third-party library in Cloud Datalab:
Use !pip install lib-name. This has obviously not worked for you, even by applying some of the troubleshooting fixes you have found after looking around.
Use the code in # Option 2 below to specify the command to run in the startup script of the Datalab instance, then proceed to restart it.
Use your own Docker customized container, inherited from the Datalab Docker container. I know this option is the most complex, but it may be the most appropriate one for packages that require a more flexible customization, such as the gdal one you are having issues with.
Script to be used in option 2:
#Option 2
%%bash
echo "pip install lib-name" >> /content/datalab/.config/startup.sh
cat /content/datalab/.config/startup.sh

Related

cannot compile wammu on opensuse-15.3

Successfully compiled from source gammu-1.42.0.
Despite a missing a final sudo ldconfig it worked as described.
Now I want to compile wammu-0.44.
I maually installed wxPython
then
python setup.py build
sudo python setup.py install
However, running wammu ends up in searching for missing modules.
First it does not find /usr/share/Wammu/images - copied it maually from the source directory /usr/local/src/wammu-0.44/images to /usr/share/Wammu
MT1:~ # wammu
Failed to load translation!
Traceback (most recent call last):
File "/usr/local/bin/wammu", line 4, in <module>
__import__('pkg_resources').run_script('wammu==0.44', 'wammu')
File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 661, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 1441, in run_script
exec(code, namespace, namespace)
File "/usr/local/lib/python2.7/site-packages/wammu-0.44-py2.7.egg/EGG-INFO/scripts/wammu", line 199, in <module>
import Wammu.App
File "/usr/local/lib/python2.7/site-packages/wammu-0.44-py2.7.egg/Wammu/App.py", line 29, in <module>
import Wammu.Main
File "/usr/local/lib/python2.7/site-packages/wammu-0.44-py2.7.egg/Wammu/Main.py", line 57, in <module>
import Wammu.Editor
File "/usr/local/lib/python2.7/site-packages/wammu-0.44-py2.7.egg/Wammu/Editor.py", line 28, in <module>
from wx import DateTimeFromDMY, DateTime_Today
ImportError: cannot import name DateTime_Today
MT1:~ #
Being only an experienced c/c++ developer I would very much appreciate a comprehensive install summary for a non python expert :-).
Tanks for reading and comments.

Pip not working; from 'ImportError: No module named urllib3' to non-admin windows user

I am facing some problems with pip. The original error message in my command prompt (windows, Python 2.7.14 and this is the version I must keep) when typing for instance pip was
Traceback (most recent call last):
File "c:\python27\lib\runpy.py", line 174, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "c:\python27\lib\runpy.py", line 72, in _run_code
exec code in run_globals
File "C:\Python27\Scripts\pip.exe\__main__.py", line 5, in <module>
File "c:\python27\lib\site-packages\pip\__init__.py", line 21, in <module>
from pip._vendor.requests.packages.urllib3.exceptions import DependencyWarning
File "c:\python27\lib\site-packages\pip\_vendor\requests\__init__.py", line 62, in <module>
from .packages.urllib3.exceptions import DependencyWarning
File "c:\python27\lib\site-packages\pip\_vendor\requests\packages\__init__.py", line 29, in <module>
import urllib3
ImportError: No module named urllib3
My journey to solve/explore the problem:
This happend no matter which of the following prompt commands I was trying
pip
pip --version
pip list
pip freeze
pip install --upgrade requests
pip install urllib3
Other commands might have change the error message a little bit in terms of the files listed like
python -m pip install --upgrade pip
Traceback (most recent call last):
File "C:\Python27\lib\runpy.py", line 163, in _run_module_as_main
mod_name, _Error)
File "C:\Python27\lib\runpy.py", line 111, in _get_module_details
__import__(mod_name) # Do not catch exceptions initializing package
File "C:\Python27\lib\site-packages\pip\__init__.py", line 21, in <module>
from pip._vendor.requests.packages.urllib3.exceptions import DependencyWarning
File "C:\Python27\lib\site-packages\pip\_vendor\requests\__init__.py", line 62, in <module>
from .packages.urllib3.exceptions import DependencyWarning
File "C:\Python27\lib\site-packages\pip\_vendor\requests\packages\__init__.py", line 29, in <module>
import urllib3
ImportError: No module named urllib3
I have checked the following (according to several suggestions I found in related questions on stackoverflow)
a pip application can be found in C:\Python27\Scripts
dont have something called PYTHONPATH in system variables only Path
C:\Python27\Scripts is listed in system variables>Path
anaconda was installed by the user before me. I uninstalled as apparently this could cause troubles and deleted all remaining .condarc files,./conda & conda folders as well as the system variable>Path listing.
I have tried the solution which was voted for here by downloading and running python get-pip.py. This is the error message:
>python get-pip.py
Traceback (most recent call last):
File "get-pip.py", line 23974, in <module>
main()
File "get-pip.py", line 188, in main
tmpdir = tempfile.mkdtemp()
File "C:\Python27\lib\tempfile.py", line 331, in mkdtemp
dir = gettempdir()
File "C:\Python27\lib\tempfile.py", line 275, in gettempdir
tempdir = _get_default_tempdir()
File "C:\Python27\lib\tempfile.py", line 200, in _get_default_tempdir
with _io.open(fd, 'wb', closefd=False) as fp:
AttributeError: 'module' object has no attribute 'open'
I was told there were some problems noticed before: The computer has 2 users, an administrator and an additional user with '(user)' in its name. I was told that it was not possible to install anaconda for that user - it was installed by the administrator for all users but in the end spyder for instance and the anaconda prompt could only be ran as administrator, too. So I am not sure if there is a problem in general with the user setup?!
I ran the command prompt as administrator and pip --version worked
pip 9.0.1 from c:\python27\lib\site-packages (python 2.7)
So I ran python -m pip install --upgrade pip as administrator, opened the command prompt again (not as administrator and now the new error is
Traceback (most recent call last):
File "c:\python27\lib\runpy.py", line 174, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "c:\python27\lib\runpy.py", line 72, in _run_code
exec code in run_globals
File "C:\Python27\Scripts\pip.exe\__main__.py", line 5, in <module>
File "c:\python27\lib\site-packages\pip\_internal\cli\main.py", line 10, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "c:\python27\lib\site-packages\pip\_internal\cli\autocompletion.py", line 9, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "c:\python27\lib\site-packages\pip\_internal\cli\main_parser.py", line 7, in <module>
from pip._internal.cli import cmdoptions
File "c:\python27\lib\site-packages\pip\_internal\cli\cmdoptions.py", line 25, in <module>
from pip._internal.cli.progress_bars import BAR_TYPES
File "c:\python27\lib\site-packages\pip\_internal\cli\progress_bars.py", line 12, in <module>
from pip._internal.utils.logging import get_indentation
File "c:\python27\lib\site-packages\pip\_internal\utils\logging.py", line 18, in <module>
from pip._internal.utils.misc import ensure_dir
File "c:\python27\lib\site-packages\pip\_internal\utils\misc.py", line 21, in <module>
from pip._vendor import pkg_resources
File "c:\python27\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 26, in <module>
import zipfile
File "c:\python27\lib\zipfile.py", line 501, in <module>
class ZipExtFile(io.BufferedIOBase):
AttributeError: 'module' object has no attribute 'BufferedIOBase'
Tried step 3 again, same outcome
Now I am frustrated and I am hoping for help because I am not super experienced and I don't want to mess up things even more (probably already did by uninstalling anaconda).
Thank you for helping!
PS: I can not exclude that I did not miss the correct solution for this problem, as several topics are addressing pip and urllib3 already, however I have tried my best to cover all suggestions. I apologize if there is already a similar topic solving this problem out there.

Getting error when trying to install apache-airflow on Mac. How can I fix this?

Error output below:
ronakvora:dtc ronakvora$ pip install apache-airflow
Installing build dependencies ... done
Complete output from command python setup.py egg_info:
running egg_info
creating pip-egg-info/pendulum.egg-info
writing requirements to pip-egg-info/pendulum.egg-info/requires.txt
writing pip-egg-info/pendulum.egg-info/PKG-INFO
writing top-level names to pip-egg-info/pendulum.egg-info/top_level.txt
writing dependency_links to pip-egg-info/pendulum.egg-info/dependency_links.txt
writing manifest file 'pip-egg-info/pendulum.egg-info/SOURCES.txt'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/6x/xsb52c7936l38mmb9f7s268m0000gn/T/pip-install-WFGcOd/pendulum/setup.py", line 50, in <module>
setup(**setup_kwargs)
File "/usr/local/Cellar/python#2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 151, in setup
dist.run_commands()
File "/usr/local/Cellar/python#2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/usr/local/Cellar/python#2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/private/var/folders/6x/xsb52c7936l38mmb9f7s268m0000gn/T/pip-build-env-HZt1xp/lib/python2.7/site-packages/setuptools/command/egg_info.py", line 296, in run
self.find_sources()
File "/private/var/folders/6x/xsb52c7936l38mmb9f7s268m0000gn/T/pip-build-env-HZt1xp/lib/python2.7/site-packages/setuptools/command/egg_info.py", line 303, in find_sources
mm.run()
File "/private/var/folders/6x/xsb52c7936l38mmb9f7s268m0000gn/T/pip-build-env-HZt1xp/lib/python2.7/site-packages/setuptools/command/egg_info.py", line 534, in run
self.add_defaults()
File "/private/var/folders/6x/xsb52c7936l38mmb9f7s268m0000gn/T/pip-build-env-HZt1xp/lib/python2.7/site-packages/setuptools/command/egg_info.py", line 570, in add_defaults
sdist.add_defaults(self)
File "/private/var/folders/6x/xsb52c7936l38mmb9f7s268m0000gn/T/pip-build-env-HZt1xp/lib/python2.7/site-packages/setuptools/command/py36compat.py", line 36, in add_defaults
self._add_defaults_ext()
File "/private/var/folders/6x/xsb52c7936l38mmb9f7s268m0000gn/T/pip-build-env-HZt1xp/lib/python2.7/site-packages/setuptools/command/py36compat.py", line 119, in _add_defaults_ext
build_ext = self.get_finalized_command('build_ext')
File "/usr/local/Cellar/python#2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/cmd.py", line 312, in get_finalized_command
cmd_obj.ensure_finalized()
File "/usr/local/Cellar/python#2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/cmd.py", line 109, in ensure_finalized
self.finalize_options()
File "/usr/local/Cellar/python#2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/build_ext.py", line 159, in finalize_options
self.include_dirs.append(py_include)
AttributeError: 'unicode' object has no attribute 'append'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/6x/xsb52c7936l38mmb9f7s268m0000gn/T/pip-install-WFGcOd/pendulum/
You are using pip version 18.1, however version 19.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
I had recently encountered a similar error on Airflow 1.10.2 and in my case it was related to incorrect version of pendulum
Run pip show pendulum
Name: pendulum
Version: 1.4.4
Summary: Python datetimes made easy.
...
If your version of pendulum is different from v1.4.4 just do a force-reinstall (Airflow 1.10.2 requires pendulum===1.4.4)
pip install --force-reinstall pendulum===1.4.4
References
Find which version of package is installed with pip
Installing specific package versions with pip
I didn't exactly solve the issue above, but just decided to switch to python3 and used pip3 install apache-airflow.

Install pip<v8 in python3.2

I fail to install pip in python3.2.
The newest version of pip (v8.x) seems to not support python3.2 any more.
So i tried: sudo python3 get-pip.py 'pip<8' but it still seems to install v8.x.
Output:
UserWarning: Support for Python 3.0-3.2 has been dropped. Future versions will fail here.
Traceback (most recent call last):
File "get-pip.py", line 19178, in <module>
main()
File "get-pip.py", line 195, in main
bootstrap(tmpdir=tmpdir)
File "get-pip.py", line 82, in bootstrap
import pip
File "/tmp/tmpec9tur/pip.zip/pip/__init__.py", line 16, in <module>
File "/tmp/tmpec9tur/pip.zip/pip/vcs/mercurial.py", line 9, in <module>
File "/tmp/tmpec9tur/pip.zip/pip/download.py", line 36, in <module>
File "/tmp/tmpec9tur/pip.zip/pip/utils/ui.py", line 15, in <module>
File "/tmp/tmpec9tur/pip.zip/pip/_vendor/progress/bar.py", line 48
empty_fill = u'∙'
^
SyntaxError: invalid syntax
Any ideas?
I found the solution:
I used the wrong get-pip, as per documentation of get-pip
use https://bootstrap.pypa.io/3.2/get-pip.py
As the bootstrap.pypa.io got updated so they changed the path of files or directories.
https://bootstrap.pypa.io/3.2/get-pip.py will not work
This link will work :
https://bootstrap.pypa.io/pip/3.2/

py2exe ImportError: No module named cssselect

I used pyquery in my App, when I run main.exe in the dist directory, the error occures:
Traceback (most recent call last):
File "main.py", line 4, in <module>
File "zipextimporter.pyo", line 82, in load_module
File "f2.pyo", line 4, in <module>
File "zipextimporter.pyo", line 82, in load_module
File "pyquery\__init__.pyo", line 11, in <module>
File "zipextimporter.pyo", line 82, in load_module
File "pyquery\pyquery.pyo", line 6, in <module>
File "zipextimporter.pyo", line 82, in load_module
File "pyquery\cssselectpatch.pyo", line 6, in <module>
ImportError: No module named cssselect
But as you can see, pyquery uses cssselectpatch not cssselect, how to fix it?
Make sure you can run your program without py2exe, i.e. as a Python script with python main.py.
Use py2exe.
If you still get an error add import cssselect to main.py and try to use py2exe again.
I have the same problem with cssselect, but before that
it was with html5lib, what I did to solve the problem was to install
html5lib manually ex: python setup.py install and a directory was created
and the error regarding html5lib didn't show, then came the error with cssselect,
I did the same thing but the installer creates a egg file not a directory
with all the structure inside, because py2exe only imports the libs with the
directory structure the binary doesn't work.
To solve the problem we have to install cssselect in the tree structure:
download cssselect from github, decompress and copy the dir cssselect that's inside cssselect-master
to your python site-packages.
On Windows (similarity can apply to Linux) you can just install it and the installer will find your local installed python to add cssselect module in. the source info taken from https://pypi.python.org/pypi/cssselect.
Here is how:
pip install cssselect
Now your python will NOT complain for csselect module missing.
If you do not have pip command then install pip.
Tested, Works!

Resources