How to install GDAL on MacOS with Homebrew? - python

I am trying to install GDAL on MacOS with Homebrew. But failed. I started with the following commands:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install gdal --HEAD
brew install gdal —-only-dependencies
brew install gdal
pip3 install gdal
The first command check if I have installed the Homebrew. The others are step by step installation of gdal. It works fun when I try to take a look with the version of gdal:
gdal-config --version
# out put: 3.0.2
But when I trying to convert .tif to .raw with gdal_translate:
gdal_translate –ot UInt16 –scale –of ENVI –outsize 1025 1025 srtm_59_05.tif heightmap.raw
There comes the following problem.
dyld[54967]: Library not loaded: #rpath/libpoppler.91.dylib
Referenced from: /Users/[my_username_here]/opt/anaconda3/lib/libgdal.26.dylib
Reason: tried: '/Users/[my_username_here]/opt/anaconda3/lib/libpoppler.91.dylib' (no such file),
'/Users/[my_username_here]/opt/anaconda3/bin/../lib/libpoppler.91.dylib' (no such file),
'/Users/[my_username_here]/opt/anaconda3/bin/../lib/libpoppler.91.dylib' (no such file),
'/usr/local/lib/libpoppler.91.dylib' (no such file), '/usr/lib/libpoppler.91.dylib' (no such file)
[1] 54967 abort gdal_translate –ot UInt16 –scale –of ENVI –outsize 1025 1025
What should I do? Can anyone help me out?
The problem seems comes from something called poppler, so I ran
brew reinstall poppler
It gives me
Warning: poppler 21.12.0 is already installed and up-to-date.
To reinstall 21.12.0, run:
brew reinstall poppler
If I reinstall poppler, the error is still there.
Here is the result of searching the folder of poppler, using
# locate the folder of poppler, gives "/opt/homebrew/Cellar/poppler/21.12.0"
brew ls --verbose poppler
# search for keyword "poppler" in filenames
find /opt/homebrew/Cellar/poppler/21.12.0 -name '*poppler*'
It gives
/opt/homebrew/Cellar/poppler/21.12.0/.brew/poppler.rb
/opt/homebrew/Cellar/poppler/21.12.0/include/poppler
/opt/homebrew/Cellar/poppler/21.12.0/include/poppler/poppler_private_export.h
/opt/homebrew/Cellar/poppler/21.12.0/include/poppler/poppler-config.h
/opt/homebrew/Cellar/poppler/21.12.0/include/poppler/glib/poppler-annot.h
/opt/homebrew/Cellar/poppler/21.12.0/include/poppler/glib/poppler-page.h
/opt/homebrew/Cellar/poppler/21.12.0/include/poppler/glib/poppler-attachment.h
/opt/homebrew/Cellar/poppler/21.12.0/include/poppler/glib/poppler-features.h
/opt/homebrew/Cellar/poppler/21.12.0/include/poppler/glib/poppler-enums.h
/opt/homebrew/Cellar/poppler/21.12.0/include/poppler/glib/poppler-form-field.h
/opt/homebrew/Cellar/poppler/21.12.0/include/poppler/glib/poppler-date.h
/opt/homebrew/Cellar/poppler/21.12.0/include/poppler/glib/poppler-action.h
/opt/homebrew/Cellar/poppler/21.12.0/include/poppler/glib/poppler.h
/opt/homebrew/Cellar/poppler/21.12.0/include/poppler/glib/poppler-layer.h
/opt/homebrew/Cellar/poppler/21.12.0/include/poppler/glib/poppler-movie.h
/opt/homebrew/Cellar/poppler/21.12.0/include/poppler/glib/poppler-document.h
/opt/homebrew/Cellar/poppler/21.12.0/include/poppler/glib/poppler-macros.h
/opt/homebrew/Cellar/poppler/21.12.0/include/poppler/glib/poppler-structure-element.h
/opt/homebrew/Cellar/poppler/21.12.0/include/poppler/glib/poppler-media.h
/opt/homebrew/Cellar/poppler/21.12.0/include/poppler/qt6/poppler-form.h
/opt/homebrew/Cellar/poppler/21.12.0/include/poppler/qt6/poppler-export.h
/opt/homebrew/Cellar/poppler/21.12.0/include/poppler/qt6/poppler-optcontent.h
/opt/homebrew/Cellar/poppler/21.12.0/include/poppler/qt6/poppler-page-transition.h
/opt/homebrew/Cellar/poppler/21.12.0/include/poppler/qt6/poppler-annotation.h
/opt/homebrew/Cellar/poppler/21.12.0/include/poppler/qt6/poppler-qt6.h
/opt/homebrew/Cellar/poppler/21.12.0/include/poppler/qt6/poppler-link.h
/opt/homebrew/Cellar/poppler/21.12.0/include/poppler/qt6/poppler-version.h
/opt/homebrew/Cellar/poppler/21.12.0/include/poppler/qt6/poppler-media.h
/opt/homebrew/Cellar/poppler/21.12.0/include/poppler/cpp/poppler-page.h
/opt/homebrew/Cellar/poppler/21.12.0/include/poppler/cpp/poppler-image.h
/opt/homebrew/Cellar/poppler/21.12.0/include/poppler/cpp/poppler-global.h
/opt/homebrew/Cellar/poppler/21.12.0/include/poppler/cpp/poppler-font-private.h
/opt/homebrew/Cellar/poppler/21.12.0/include/poppler/cpp/poppler-page-transition.h
/opt/homebrew/Cellar/poppler/21.12.0/include/poppler/cpp/poppler-toc.h
/opt/homebrew/Cellar/poppler/21.12.0/include/poppler/cpp/poppler-document.h
/opt/homebrew/Cellar/poppler/21.12.0/include/poppler/cpp/poppler-rectangle.h
/opt/homebrew/Cellar/poppler/21.12.0/include/poppler/cpp/poppler-page-renderer.h
/opt/homebrew/Cellar/poppler/21.12.0/include/poppler/cpp/poppler-destination.h
/opt/homebrew/Cellar/poppler/21.12.0/include/poppler/cpp/poppler_cpp_export.h
/opt/homebrew/Cellar/poppler/21.12.0/include/poppler/cpp/poppler-version.h
/opt/homebrew/Cellar/poppler/21.12.0/include/poppler/cpp/poppler-embedded-file.h
/opt/homebrew/Cellar/poppler/21.12.0/include/poppler/cpp/poppler-font.h
/opt/homebrew/Cellar/poppler/21.12.0/lib/libpoppler-qt6.3.dylib
/opt/homebrew/Cellar/poppler/21.12.0/lib/pkgconfig/poppler.pc
/opt/homebrew/Cellar/poppler/21.12.0/lib/pkgconfig/poppler-cpp.pc
/opt/homebrew/Cellar/poppler/21.12.0/lib/pkgconfig/poppler-glib.pc
/opt/homebrew/Cellar/poppler/21.12.0/lib/pkgconfig/poppler-qt6.pc
/opt/homebrew/Cellar/poppler/21.12.0/lib/libpoppler-qt6.dylib
/opt/homebrew/Cellar/poppler/21.12.0/lib/libpoppler-cpp.0.9.0.dylib
/opt/homebrew/Cellar/poppler/21.12.0/lib/libpoppler.a
/opt/homebrew/Cellar/poppler/21.12.0/lib/libpoppler-glib.dylib
/opt/homebrew/Cellar/poppler/21.12.0/lib/libpoppler-cpp.a
/opt/homebrew/Cellar/poppler/21.12.0/lib/libpoppler-glib.8.22.0.dylib
/opt/homebrew/Cellar/poppler/21.12.0/lib/libpoppler-qt6.3.1.0.dylib
/opt/homebrew/Cellar/poppler/21.12.0/lib/libpoppler-cpp.0.dylib
/opt/homebrew/Cellar/poppler/21.12.0/lib/libpoppler-glib.8.dylib
/opt/homebrew/Cellar/poppler/21.12.0/lib/libpoppler.116.0.0.dylib
/opt/homebrew/Cellar/poppler/21.12.0/lib/libpoppler-cpp.dylib
/opt/homebrew/Cellar/poppler/21.12.0/lib/libpoppler.116.dylib
/opt/homebrew/Cellar/poppler/21.12.0/lib/libpoppler.dylib
/opt/homebrew/Cellar/poppler/21.12.0/lib/libpoppler-glib.a
/opt/homebrew/Cellar/poppler/21.12.0/share/pkgconfig/poppler-data.pc
/opt/homebrew/Cellar/poppler/21.12.0/share/poppler

The problem is solved:
As https://github.com/OSGeo/gdal/issues/5348 issue.
It looks to be a mix of Conda and homebrew in your system. Perhaps try deactivating your Conda environment. I'm afraid I can't help more.
Just shot down Anaconda and redo everything with only Homebrew.

Related

How to install GDAL Python Bindings for Postgres.app

I installed the latest Postgre.app version Version 2.5.6 (139) Universal version for my new MacBook Pro M1. After setting up the CLI tools, I am able to access all gdal binaries that come bundled like gdalinfo.
However I also need to install the python bindings to use cli utilities like gdal2tiles.py. What's the right way to go about installing these so they work with the rest of gdal bundled with latest Postgress.app?
Current version bundled with Postgres.app is
➜ gdalinfo --version
GDAL 3.3.3, released 2021/10/25
Postgres.app installs GDAL binaries at:
/Applications/Postgres.app/Contents/Versions/latest/bin and currently has the following bundled:
clusterdb ecpg gdal_translate gdalinfo gdaltindex invproj pg_amcheck pg_ctl pg_resetwal pg_verifybackup proj vacuumdb
createdb gdal-config gdal_viewshed gdallocationinfo gdaltransform nearblack pg_archivecleanup pg_dump pg_restore pg_waldump psql vacuumlo
createuser gdal_contour gdaladdo gdalmanage gdalwarp ogr2ogr pg_basebackup pg_dumpall pg_rewind pgbench raster2pgsql
cs2cs gdal_create gdalbuildvrt gdalmdiminfo geod ogrinfo pg_checksums pg_isready pg_test_fsync pgsql2shp reindexdb
dropdb gdal_grid gdaldem gdalmdimtranslate initdb ogrtindex pg_config pg_receivewal pg_test_timing postgres shp2pgsql
dropuser gdal_rasterize gdalenhance gdalsrsinfo invgeod oid2name pg_controldata pg_recvlogical pg_upgrade postmaster testepsg
I realize there are plenty of ways to install gdal with python bindings using brew and pip, but I am looking to do this the right way while utilizing the core gdal that comes with Postgres.app
Any help is appreciated, Thanks!
Use pygdal, it is made for this exact purpose.
export GDALHOME="/Applications/Postgres.app/Contents/Versions/latest"
pip install pygdal=="`gdal-config --version`.*"

Install ROS Kinetic on MacOS under a separate Anaconda environment

I'm installing ROS Kinetic on MacOS Sierra 10.12.6 under a seperate environment under Python Anaconda distribution.
Here is my python version(my seperate python environment in Anaconda is called "ros-kinetic"):
(ros-kinetic) jizhe#jizhedeMacBook-Pro  ~/ros_catkin_ws  python --version
Python 3.6.4 :: Anaconda, Inc.
I followed the guide: http://wiki.ros.org/kinetic/Installation/OSX/Homebrew/Source.
When I execute the "rosdep install" command, I got the following error:
(ros-kinetic) jizhe#jizhedeMacBook-Pro ~/ros_catkin_ws  rosdep install --from-paths src --ignore-src --rosdistro kinetic -y
ERROR: the following packages/stacks could not have their rosdep keys resolved
to system dependencies:
actionlib: No definition of [python-wxtools] for OS [osx]
catkin: No definition of [google-mock] for OS [osx]
roslisp: No definition of [google-mock] for OS [osx]
Obviously, there is something wrong with the package "python-wxtools" and "google-mock".
I've already install the wxpython via "brew install wxpython", and here is the wxpython info:
(ros-kinetic) jizhe#jizhedeMacBook-Pro  ~/ros_catkin_ws  brew info wxpython
wxpython: stable 3.0.2.0 (bottled)
Python bindings for wxWidgets
https://www.wxwidgets.org/
/usr/local/Cellar/wxpython/3.0.2.0_1 (1,108 files, 37.9MB) *
Poured from bottle on 2018-02-24 at 03:56:21
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/wxpython.rb
==> Dependencies
Required: wxmac ✔
==> Caveats
Python modules have been installed and Homebrew's site-packages is not
in your Python sys.path, so you will not be able to import the modules
this formula installed. If you plan to develop with these modules,
please run:
mkdir -p /Users/jizhe/Library/Python/2.7/lib/python/site-packages
echo 'import site; site.addsitedir("/usr/local/lib/python2.7/site-packages")' >> /Users/jizhe/Library/Python/2.7/lib/python/site-packages/homebrew.pth
And I've already run the command:
$ mkdir -p ~/Library/Python/2.7/lib/python/site-packages
$ echo "$(brew --prefix)/lib/python2.7/site-packages" >> ~/Library/Python/2.7/lib/python/site-packages/homebrew.pth
So, what's wrong with the package "google-mock" and "python-wxtools", how can I solve this problem?
Try installing with --skip-keys python-wxtools --skip-keys google-mock. It worked for me.
There is a ticket for this issue. Basically the workaround is to install googletest manually. Not sure what's wrong with python-wxtools.
edit: If you're using ros-install-osx, you can add the following lines to your rosdeps.yaml file:
google-mock:
osx:
homebrew:
packages: []
I found this question from a Google search, just for your information in 2021 installing ROS in conda also on macOS should be much straightforward, see the following links:
https://medium.com/robostack/cross-platform-conda-packages-for-ros-fa1974fd1de3
https://github.com/RoboStack/ros-noetic

Trouble installing pygame. Permissions Mac OS X 10.9.5

I have been struggling to find the correct research to install pygame for about 2 days and would like to ask the community to reach a solution!
My MacBook is a backup of my old MacBook so if that is the essence of the problem, I am open to suggestions to fix it!
On the installation front
donners-mbp-2:~ Donner$ brew list
cmake isl mercurial python smpeg
freetype jpeg mpfr readline sphinx-doc
gcc libmpc numpy sdl sqlite
gdbm libpng openssl sdl_image webp
git libtiff pkg-config sdl_mixer
gmp makedepend portmidi sdl_ttf
upon researching I should use this code in terminal to install however I receive an error message following:
donners-mbp-2:~ Donner$ /usr/local/share/python/pip install hg+http://bitbucket.org/pygame/pygame
donners-mbp-2:~ Donner$ /usr/local/share/python/pip: No such file or directory
Taking a look into my "Home" Directory - AKA Macintosh HD - I have the Library directory within not in my user folder (AKA directly on the main HD).
Should I move that to my user folder then try again?
When running the pygame install here is what is on my command line.
donners-mbp-2:~ Donner$ sudo -H pip install hg+http://bitbucket.org/pygame/pygame
Password:
Collecting hg+http://bitbucket.org/pygame/pygame
Cloning hg http://bitbucket.org/pygame/pygame to /private/tmp/pip-SqL4BW-build
Requirement already satisfied (use --upgrade to upgrade): pygame==1.9.4.dev0 from hg+http://bitbucket.org/pygame/pygame in /usr/local/lib/python2.7/site-packages
When executing a file with:
#!/usr/bin/env python
import pygame
The error is:
/Users/Donner/Desktop/Python/komodo/pygame/pygame1/open_script ; exit;
donners-mbp-2:~ Donner$ /Users/Donner/Desktop/Python/komodo/pygame/pygame1/open_script ; exit;
Traceback (most recent call last):
File "pygame1.py", line 3, in <module>
import pygame
ImportError: No module named pygame
logout
[Process completed]
EDIT: I did a brew doctor in terminal and received this as the output.
donners-mbp-2:~ Donner$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry and just ignore them. Thanks!
Warning: Unbrewed header files were found in /usr/local/include.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected header files:
/usr/local/include/python2.7/pygame/_camera.h
/usr/local/include/python2.7/pygame/_pygame.h
/usr/local/include/python2.7/pygame/_surface.h
/usr/local/include/python2.7/pygame/bitmask.h
/usr/local/include/python2.7/pygame/camera.h
/usr/local/include/python2.7/pygame/fastevents.h
/usr/local/include/python2.7/pygame/font.h
/usr/local/include/python2.7/pygame/freetype.h
/usr/local/include/python2.7/pygame/mask.h
/usr/local/include/python2.7/pygame/mixer.h
/usr/local/include/python2.7/pygame/pgarrinter.h
/usr/local/include/python2.7/pygame/pgbufferproxy.h
/usr/local/include/python2.7/pygame/pgcompat.h
/usr/local/include/python2.7/pygame/pgopengl.h
/usr/local/include/python2.7/pygame/pygame.h
/usr/local/include/python2.7/pygame/scrap.h
/usr/local/include/python2.7/pygame/surface.h
Warning: You are using macOS 10.9.
We (and Apple) do not provide support for this old version.
You may encounter build failures or other breakages.
Please create pull-requests instead of filing issues.
Warning: /usr/bin occurs before /usr/local/bin
This means that system-provided programs will be used instead of those
provided by Homebrew. The following tools exist at both paths:
2to3
2to3-2.7
easy_install
easy_install-2.7
git
git-cvsserver
git-receive-pack
git-shell
git-upload-archive
git-upload-pack
idle
idle2.7
pydoc
pydoc2.7
python
python-config
python2.7
python2.7-config
pythonw
pythonw2.7
smtpd.py
smtpd2.7.py
Consider setting your PATH so that /usr/local/bin
occurs before /usr/bin. Here is a one-liner:
echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bash_profile
Thank you for any help/suggestions!
(Posted on behalf of the OP).
This is solved.
I followed this to show hidden files in my $PATH and establish a new $PATH. https://coolestguidesontheplanet.com/add-shell-path-osx/
Then un-installed and reinstalled pygame, following the comments here: https://www.reddit.com/r/Python/comments/2jfj1w/how_to_install_pygame_on_osx_1095/. Specifically the comment by redditor PigBoyOhBoy (with some adjustments for Python 2.7 rather than Python 3).

brew install opencv3 apparently successful, but missing cv2.so and cv2.py

I'm trying to setup a working environment on my mac:
brew install opencv3 --c++11 --with-contrib --with-gphoto2 --with-python3
==> Installing opencv3 from homebrew/homebrew-science
...
==> cmake .. -DCMAKE_C_FLAGS_RELEASE= -DCMAKE_CXX_FLAGS_RELEASE= -DCMAKE_INSTALL
==> make
==> make install
==> Caveats
This formula is keg-only, which means it was not symlinked into /usr/local.
opencv3 and opencv install many of the same files.
Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:
LDFLAGS: -L/usr/local/opt/opencv3/lib
CPPFLAGS: -I/usr/local/opt/opencv3/include
==> Summary
🍺 /usr/local/Cellar/opencv3/3.0.0: 351 files, 110M, built in 5.4 minutes
So homebrew seems to think the install went well, but
locate cv2.so finds nothing...
locate *cv*.so
finds only
/usr/local/Cellar/opencv3/3.0.0/lib/python3.5/site-packages/cv2.cpython-35m-darwin.so
and
/usr/local/lib/python3.5/site-packages/cv2.cpython-35m-darwin.so
cv2.py or cv.py does not exist as well...
Any ideas?
ive seen this error before using raspian, its also seen in ubuntu, renaming cv2.cpython-35m-darwin.so to cv2.so may help fix the issue.
ive heard it just a standard naming error.

Installing Python-Tesseract on a Linux system

I am having trouble installing python-tesseract on my linux system. I've been using this tutorial:
http://delimitry.blogspot.be/2014/10/installing-tesseract-for-python-on.html
The error I get is:
File does not exist:['/usr/include/tesseract/capi.h', '/usr/local/include/tesseract/capi.h', '/opt/include/tesseract/capi.h', '/opt/local/include/tesseract/capi.h']
root#opencv:/home/philipp/python-tesseract#
When running python setup.py clean in /python-tesseract after following the rest of the instructions in order.
Running linux 3.2.0-4-amd64 on this system.
Whereis tesseract-ocr returns:
/usr/share/tesseract-ocr
Whereis leptonica returns:
/usr/include/leptonica
Whereis tesseract returns:
tesseract: /usr/bin/tesseract /usr/bin/X11/tesseract /usr/include/tesseract/ /usr/share/man/man1/tesseract.1.gz
I've also tried running a few other tutorials/guides to install python-tesseract that have returned other errors such as, missing libleptonica then missing libc6 but I havn't investigated these as much. Just tried to see if any other guides worked immidiately.
Also, when I run tesseract in the terminal it works, but import tesseract does not.
What am I doing wrong? How can I fix this and install python-tesseract?
I think this way could work for you:
1- download python-tesseract_0.9-0.5ubuntu3_vivid_amd64.deb from here
2- install gdebi-core
sudo apt-get install gdebi-core
3- install python-tesseract_0.9-0.5ubuntu3_vivid_amd64.deb with gdebi
sudo gdebi python-tesseract_0.9-0.5ubuntu2_i386.deb

Categories