I am trying to install Postgis in order to use GeoDjango on OSX.
For this, I first uninstalled postgres completely, then I installed everything following the GeoDjango documentation: https://docs.djangoproject.com/en/dev/ref/contrib/gis/install/#homebrew
I did the following:
brew update
brew upgrade
brew install postgresql
brew install postgis
brew install gdal
brew install libgeoip
When I run my Django project, I get the following error:
OSError at / dlopen(/usr/local/lib/libgeos_c.so, 6): image not found
I ran
sudo find . -name "libgeos_c*"
And got:
./Library/Frameworks/GEOS.framework/Versions/3/unix/lib/libgeos_c.dylib
./Users/martin/opt/geos-3.3.0/capi/.deps/libgeos_c_la-geos_c.Plo
./Users/martin/opt/geos-3.3.0/capi/.deps/libgeos_c_la-geos_ts_c.Plo
./usr/local/Cellar/geos/3.3.3/lib/libgeos_c.1.dylib
./usr/local/Cellar/geos/3.3.3/lib/libgeos_c.a
./usr/local/Cellar/geos/3.3.3/lib/libgeos_c.dylib
./usr/local/Cellar/geos/3.3.4/lib/libgeos_c.1.dylib
./usr/local/Cellar/geos/3.3.4/lib/libgeos_c.a
./usr/local/Cellar/geos/3.3.4/lib/libgeos_c.dylib
./usr/local/Cellar/geos/3.3.5/lib/libgeos_c.1.dylib
./usr/local/Cellar/geos/3.3.5/lib/libgeos_c.a
./usr/local/Cellar/geos/3.3.5/lib/libgeos_c.dylib
./usr/local/lib/libgeos_c.1.dylib
./usr/local/lib/libgeos_c.a
./usr/local/lib/libgeos_c.dylib
As you can see, no ".so" files at all. Any suggestions?
Edit:
Out of desperation I also installed the KyngChaos Packages and added the following settings:
GEOS_LIBRARY_PATH = '/Library/Frameworks/GEOS.framework/GEOS'
GDAL_LIBRARY_PATH = '/Library/Frameworks/GDAL.framework/GDAL'
GEOIP_LIBRARY_PATH = '/usr/local/Cellar/geoip/1.4.8/lib/libGeoIP.dylib'
This solved the problem.
Sorry, that KyngChaos solution completely defeats the purpose of using homebrew.
The answer for homebrew users (at least, for this one) is to uninstall geos and its dependencies and then reinstall geos and then its dependencies.
This worked for me:
brew uninstall geos gdal geoip libspatialite librasterlite spatialite-gui spatialite-tools
brew cleanup
brew install geos
brew install gdal geoip libspatialite librasterlite spatialite-gui spatialite-tools
brew cleanup
It seems some geos dependencies are getting out of sync.
You can verify the libraries that need to be installed by tracking what this returns:
python -c 'import _ctypes; _ctypes.dlopen("/usr/local/lib/libgdal.dylib")'
You'll see something like
Reason: Incompatible library version: [some geos dependent library].dylib requires version X.X.X or later, but libgeos_c.1.8.0.dylib provides version X.X.X.
brew uninstall [some geos dependency]
brew install [some geos dependency]
brew cleanup
Then rerun the above python command and either the problem will be resolved or it'll reveal another dependency to uninstall/install.
I solved it this way.
$ brew install postgresql
$ brew install postgis
$ brew install gdal
$ brew install libgeoip
then in Django settings set this:
GEOS_LIBRARY_PATH = '/usr/local/Cellar/geos/3.4.2/lib/libgeos_c.1.dylib'
Then it worked for me.
The installation instructions appears to hold the answer, which is to set the environment variable $GEOS_LIBRARY_PATH.
Same here - after installing everything as directed, I went back and added the KyngChaos libraries, then added the three export statements to my ~/.bash_profile as listed above. This fixed my issue.
I had this same issue and was able to solve it by uninstalling GDAL from Homebrew and installing the GDAL Complete package from KyngChaos: http://www.kyngchaos.com/software/frameworks
Had the same issue (Mac OSX) and solved it by creating a sym link from where I found the lib folder to where python was looking for it in the error message.
ln -s /usr/local/Cellar/geos/3.10.3/lib/libgeos_c.dylib ~/PycharmProjects/project/venv/lib/libgeos_c.dylib
None of the environment variables worked, nor reinstalling
Related
I have following issue of installing pygame package.
In file included from src/_numericsurfarray.c:23:
src/pygame.h:106:10: fatal error: 'SDL.h' file not found
#include <SDL.h>
^
1 error generated.
error: Setup script exited with error: command 'gcc' failed with exit status 1
System information
Mac OS-10.9.2
python version- Python 2.7.5 :: Anaconda 1.6.1 (x86_64)
Any suggestion will be greatly appreciate ? Thanks.
Here (OSX Mavericks) I got able to install this way:
brew install sdl sdl_image sdl_mixer sdl_ttf portmidi
pip install https://bitbucket.org/pygame/pygame/get/default.tar.gz
("default" branch is on commit e3ae850 right now)
Source: https://bitbucket.org/pygame/pygame/issue/139/sdlh-not-found-even-thought-it-exists#comment-3822470
See this other StackOverflow question too: PyGame in a virtualenv on OS X with brew?
I had the same issue. I tried all versions of the answers to this question including variations of pip and pip3. Finally, the one that worked for me was:
sudo easy_install pygame
Note, however, that: (1) https://setuptools.readthedocs.io/en/latest/easy_install.html says that easy_install is deprecated and recommends using pip. (2) pygame is installed in the old standard python 2.7 folder rather than in the python 3.8.3 that I just installed -- though I was able to use it successfully in VSCode.
My system is also OSX10.9.2,and I also meet you problem,and I'm still try some;
Maybe this will be help for you:
there are some step:
1.Install [Quartz](https://xquartz.macosforge.org/landing/);
2.Install Xcode-Command-Line,
but you may cant install it by `xcode-select --install`,
so you can down from
https://developer.apple.com/downloads/index.action ;
I suggest you setup xcode,and this really solute my some problem;
3.`brew tap homebrew/headonly`
`brew install smpeg --HEAD`
`brew install sdl sdl_image sdl_mixer sdl_ttf portmidi`
4. `sudo pip install hg+http://bitbucket.org/pygame/pygame`;
if you clone this repo and try `python setup.py install`,you may meet some weird problem;
I have try install kivy which is base on pygame and I try lots of times,but just success install pygame one time.Then I uninstall it and also can't install it ;(
some refer:
http://jamesfriend.com.au/installing-pygame-python-mac-os-108-mountain-lion
http://juliaelman.com/blog/2013/04/02/installing-pygame-on-osx-mountain-lion/
=======update
Now I have install pygmae sucess,remeber you should install xcode,not only xcode-command-line!
I managed to install pygame on Mac OSX 10.14.4 using the following:
brew install sdl sdl_image sdl_mixer sdl_ttf portmidi
sudo -H pip3.8 install pygame
This Work for me:
If you haven't installed Python/pip via homebrew (you're using the system-installed Python), you would likely need to run sudo pip3 install pygame.
Before running pip3 install pygame, I had also installed Command Line Tools for XCode), as well as XQuartz, and the following homebrew packages: brew install sdl sdl_image sdl_mixer sdl_ttf smpeg portmidi.
If homebrew fails to install smpeg you might need to do the following:
brew tap homebrew/headonly
brew install --HEAD smpeg
Source: http://jamesfriend.com.au/installing-pygame-python-mac-os-108-mountain-lion
I had installed OpenCV following these steps. After trying to compile one example, I got this error:
OpenCV Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvNamedWindow, file /home/nick/.Apps/opencv/modules/highgui/src/window.cpp, line 516
terminate called after throwing an instance of 'cv::Exception'
what(): /home/nick/.Apps/opencv/modules/highgui/src/window.cpp:516: error: (-2) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function cvNamedWindow
CMakeLists.txt
cmake_minimum_required(VERSION 2.8.4)
project(threadTest)
find_package( OpenCV REQUIRED )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra -pthread")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "/home/nick/ClionProjects/threadTest")
set(SOURCE_FILES main.cpp)
add_executable(threadTest ${SOURCE_FILES})
target_link_libraries( threadTest ${OpenCV_LIBS} )
How can I solve it?
First check whether libgtk2.0-dev is installed properly. If you have installed aptitude package manager, run the following:
sudo aptitude search libgtk2.0-dev
It should return like this:
i libgtk2.0-dev - development files for the GTK+ library
p libgtk2.0-dev:i386 - development files for the GTK+ library
You need to build the files once again. Locate your OpenCV folder. Create a new folder and name it Release. Enter into this folder. For example,
cd /home/user_name/OpenCv
mkdir Release
cd Release
Now build using CMake with following command:
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_GTK=ON -D WITH_OPENGL=ON ..
Remember to put WITH_GTK=ON during CMake.
After this step, enter the command,
make
sudo make install
This should resolve your problem. If you have broken dependencies for libgtk2.0-dev, then install a fresh copy of libgtk2.0-dev using aptitude.
sudo aptitude install libgtk2.0-dev
If you installed OpenCV using the opencv-python pip package, be aware of the following note, taken from opencv-python:
IMPORTANT NOTE
macOS and Linux wheels have currently some limitations:
video related functionality is not supported (not compiled with FFmpeg)
for example cv2.imshow() will not work (not compiled with GTK+ 2.x or Carbon support)
Also note that to install from another source, first you must remove the opencv-python package.
To install OpenCV in Ubuntu, I followed this guide, and it worked perfectly fine: Ubuntu 16.04: How to install OpenCV
In order to improve Nic Szer's answer I want to explain how to fix this error on macOS in three simple steps.
Remove installed OpenCV version to avoid messing up later
pip3 uninstall opencv-python
Lower your Python version to 3.5 (the current version, 3.6, has problems with Conda which we will use to install OpenCV)
conda install python=3.5
Finally, use Conda to install a working version of OpenCV
conda install -c menpo opencv3
And then voilà: OpenCV will start working on your macOS (macOS v10.12.4 (Sierra)).
For Windows, just uninstall the OpenCV package:
pip uninstall opencv-python
And reinstall:
pip install opencv-python
In case what is mentioned in previous answers doesn't work, try:
pip install opencv-python
for Python 2, or
pip3 install opencv-python
for Python 3.
For me (Arch Linux, Anaconda with Python 3.6), installing from the suggested channels menpo or loopbio did not change anything. My solution was to
install pkg-config (sudo pacman -Syu pkg-config),
remove opencv from the environment (conda remove opencv) and
re-install opencv from the conda-forge channel (conda install -c conda-forge opencv)
conda list now returns opencv 3.3.0 py36_blas_openblas_203 [blas_openblas] conda-forgeand all windows launched using cv2 are working fine.
I have had to deal with this issue a couple of times, and this is what has worked consistently thus far:
conda remove opencv
conda install -c menpo opencv
pip install --upgrade pip
pip install opencv-contrib-python
I have the solved using Anaconda 3 installing on Ubuntu 16.04 (Xenial Xerus).
I have used the PyCharm editor for my Python code.
I am using the Python 3.6 version.
I solved the issue using these processes.
IDEA: we need to install the package opencv-contrib-python package from PyCharm.
After installing OpenCV using vcpkg on Ubuntu, there is a known issue with vcpkg where you'll end up with the exact same error message as the top of this post with no access to highgui:
OpenCV(4.3.0) Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support.
If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvNamedWindow,
file .../vcpkg/buildtrees/opencv4/src/4.3.0-0c6047baf6.clean/modules/highgui/src/window.cpp, line 634
Caught exception: OpenCV(4.3.0) .../vcpkg/buildtrees/opencv4/src/4.3.0-0c6047baf6.clean/modules/highgui/src/window.cpp:634:
error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support.
If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvNamedWindow'
The problem is vcpkg passes in the build option -DWITH_GTK=OFF when building OpenCV. The open issue: https://github.com/microsoft/vcpkg/issues/12621
The workaround is the following:
edit the file vcpkg/ports/opencv4/portfile.cmake
find the line that says -DWITH_GTK=OFF and change it to say -DWITH_GTK=ON
run ./vcpkg remove opencv4
run sudo apt-get install libgtk2.0-dev pkg-config
reinstall OpenCV with ./vcpkg install opencv4 or whichever vcpkg command you used
I have Ubuntu 16.04 LTS (Xenial Xerus) environment with GTK 3 preinstalled.
I got the same error for Caffe build (master branch),
Try the following steps, may be it should work for you.
sudo apt-get install libgtk-3-dev
cmake .. (WITH_GTK=ON and other settings),
make
And bingo, the error was gone... in my Python Caffe code
Please note:
The CMake configuration should reflect GTK+ 3.x instead of GTK+ 2.x:
GUI:
-- QT: NO
-- GTK+ 3.x: YES (ver 3.18.9)
-- GThread : YES (ver 2.48.2)
-- GtkGlExt: NO
-- OpenGL support: NO
-- VTK support: NO
I have fixed my issue using this,try it
pip install opencv-python-headless==4.5.3.56
pip install opencv-contrib-python==4.5.3.56
pip install opencv-python==4.5.3.56
I had the same problem, and fixed it by simply reinstalling opencv.
There is no need to uninstall it first.
My issue was solved after installing opencv-contrib-python:
pip install opencv-contrib-python
I tried several of the previous answers the one that worked for me in ubuntu is mentioned in the following steps:
Firstly, remove the current opencv package that is installed in your system by typing in the following command in the terminal conda remove opencv.
If your Python version is 3.6 or above then change it into the stable version which can be done by typing in conda install python=3.5.
Later on, install the opencv package again by giving the following input in terminal conda install -c menpo opencv3
I had the same issue and it has been resolved after uninstalling opencv-python and doing a fresh install.
pip uninstall opencv-python
pip install opencv-python
try this. It worked for me
sudo apt-get install cmake cmake-curses-gui libgtk2.0-dev
pip install opencv-contrib-python
reinstalling and installing with the above command solved my issue but just after closing all instances of pyhton and anaconda because apparently a cache version of the library was being kept in my system.
Hence, uninstall opencv (try with pip and conda), close the IDE and reboot it, check if you can import opencv. If you still can import it, try to run the code:
help(cv2)
and check where the files are stored and delete that folder.
Repeat the process untill you are sure it is uninstalled so you can reinstall opencv full package (option 2 - see https://pypi.org/project/opencv-python/ )
I had the same issue and it has been resolved after uninstalling opencv-python version 4 and then installing the OpenCV version 3.
pip install opencv-python==3.4.9.33
I have fixed this issue by replacing
cvDestroyWindow("showImage");
by
cvDestroyWindow("ShowImage");
On Mac OS Maverick I have installed OpenCV with a brew install opencv.
I created a simple program (copied from this tutorial). Compilation worked fine but when running the executable I get the following error:
dyld: Library not loaded: /usr/local/lib/libpng16.16.dylib
Referenced from: /usr/local/lib/libopencv_highgui.2.4.dylib
Reason: Incompatible library version: libopencv_highgui.2.4.dylib requires version 33.0.0 or later, but libpng16.16.dylib provides version 32.0.0
Trace/BPT trap: 5
I checked that libpngwas properly installed via brew install libpng and ran a brew upgrade to make sure everything was up-to-date.
Running locate libpng16.dylib returns:
/Applications/GIMP.app/Contents/Resources/lib/libpng16.16.dylib
/usr/local/Cellar/libpng/1.6.10/lib/libpng16.16.dylib
/usr/local/Cellar/libpng/1.6.12/lib/libpng16.16.dylib
/usr/local/Cellar/libpng/1.6.13/lib/libpng16.16.dylib
/usr/local/Cellar/libpng/1.6.15/lib/libpng16.16.dylib
/usr/local/lib/libpng16.16.dylib
Any idea?
The best solution is to fully uninstall libpng and re-install it:
$ sudo brew uninstall libpng
$ sudo rm '/usr/local/bin/libpng-config'
$ for i in `brew link --overwrite --dry-run libpng`; do sudo rm $i; done
$ sudo brew install libpng
If you need to install opencv:
$ sudo brew tap homebrew/science
$ sudo brew install opencv
Homebrew should ensure that you the correct dependencies install. However, it's possible that you have more than one version of libpng16 installed at different paths. Have a look in...
/usr/lib
/opt/local/lib
If you find any versions of the library in these locations then they may be causing the wrong one to be loaded when your program starts. As a quick fix you can try typing DYLD_LIBRARY_PATH=/usr/local/lib before your program name on the command line. In the longer term you may need to remove the conflicting versions altogether.
This answer is for OSX users who installed through Conda, more specifically the conda-forge channel (I'm not sure about others).
Conda ends up installing its own libpng in the environment and you can update it with conda upgrade libpng.
I guess this is basically a bug with the opencv recipe on conda-forge.
./manage.py compilemessages
throws this error:
sh: msgfmt: command not found
I am running Mac OS 10.7, and I can't find the download path for the msgfmt program. Is there any way to resolve this problem?
Thanks in advance!
[update] TLDR; as Dogukan commented: Mac OS Maverics brew install gettext; brew link gettext --force worked for me.
[update] user Lajarre reported: as of today (March 2014), I had to do brew install msgpack.
You need GNU gettext and gettext-tools.
If you use fink, try:
sudo fink install gettext-tools
You may need to add /sw/bin/ to your PATH if it is not there yet.
If you don't use fink, try brew:
brew install gettext
brew link gettext
[update] removed sudo call from the brew example as suggested by Dave and Jason.
Paulo Scardine's answer is perfect, but after I executed 'sudo brew link gettext' I got an error message.
Error: Cowardly refusing to `sudo brew link'
You can use brew with sudo, but only if the brew executable is owned by root.
However, this is both not recommended and completely unsupported so do so at
your own risk.
It's easy to handle it, just remove 'sudo'
brew install gettext
brew link gettext
How do you install Boost on MacOS?
Right now I can't find bjam for the Mac.
You can get the latest version of Boost by using Homebrew.
brew install boost.
Download MacPorts, and run the following command:
sudo port install boost
Just get the source, and compile Boost yourself; it has become very easy. Here is an example for the current version of Boost on the current macOS as of this writing:
Download the the .tar.gz from https://www.boost.org/users/download/#live
Unpack and go into the directory:tar -xzf boost_1_50_0.tar.gz
cd boost_1_50_0
Configure (and build bjam):
./bootstrap.sh --prefix=/some/dir/you/would/like/to/prefix
Build:
./b2
Install:./b2 install
Depending on the prefix you choose in Step 3, you might need to sudo Step 5, if the script tries copy files to a protected location.
Unless your compiler is different than the one supplied with the Mac XCode Dev tools, just follow the instructions in section 5.1 of Getting Started Guide for Unix Variants. The configuration and building of the latest source couldn't be easier, and it took all about about 1 minute to configure and 10 minutes to compile.
Install both of them using homebrew separately.
brew install boost
brew install bjam
Fink appears to have a full set of Boost packages...
With fink installed and running just do
fink install boost1.35.nopython
at the terminal and accept the dependencies it insists on. Or use
fink list boost
to get a list of different packages that are availible.
Install Xcode from the mac app store.
Then use the command:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
the above will install homebrew and allow you to use brew in terminal
then just use command :
brew install boost
which would then install the boost libraries to <your macusername>/usr/local/Cellar/boost
In order to avoid troubles compiling third party libraries that need boost installed in your system, run this:
sudo port install boost +universal
Try +universal
One thing to note: in order for that to make a difference you need to have built python with +universal, if you haven't or you're not sure you can just rebuild python +universal. This applies to both brew as well as macports.
$ brew reinstall python
$ brew install boost
OR
$ sudo port -f uninstall python
$ sudo port install python +universal
$ sudo port install boost +universal
you can download bjam for OSX (or any other OS) here
If you are too lazy like me:
conda install -c conda-forge boost