Error installing mysql-python: library not found for -lssl - pip

I'm having trouble installing mysql-python. Created a new virtualenv and when installing mysql-python... here's the error message:
(env)$ pip install mysql-python
Collecting mysql-python
...
clang -bundle -undefined dynamic_lookup -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk build/temp.macosx-10.12-x86_64-2.7/_mysql.o -L/usr /local/Cellar/mysql/5.7.16/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.12-x86_64-2.7/_mysql.so
ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'clang' failed with exit status 1
Using homebrew, I have installed:
libressl
openssl
openssl#1.1
mysql
Already tried to brew link but brew refuses to do so.
The OS is MacOS Sierra.
Can anyone help? Thanks!

You can set ssl library path explicitly.
LDFLAGS=-L/usr/local/opt/openssl/lib pip install mysqlclient

I tried updating Xcode's CLT, uninstalling mysql, checking mysql_config, etc., but had no luck.
I found that running brew info openssl shows:
...
For compilers to find openssl you may need to set:
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
...
Running those two commands, followed by pip install, worked for me (in my case when installing mysqlclient).

Solved it with these steps:
brew uninstall mysql
brew install mysql-connector-c
pip install mysql-python
brew unlink mysql-connector-c
brew install mysql
Found the answer here https://stackoverflow.com/a/25920020/576192
Not sure if this is the right way, but this is how I managed to solve it.

I'm able to fix the error by running:
pip install -r requirements.txt --global-option=build_ext --global-option="-I/usr/local/opt/openssl/include" --global-option="-L/usr/local/opt/openssl/lib"

I was finally able to fix it by
xcode-select --install
I was sure I had already done that... but obviously I hadn't. Definitely worth a shot!

For me on mac, running this command solved the issue
LDFLAGS=-L/usr/local/opt/openssl/lib pip install mysqlclient
Actually we need to set ssl library path to get this issue fixed.

Worked for me by doing this
$ brew uninstall mysql
$ brew install mysql-connector-c
$ brew unlink mysql-connector-c
$ brew install mysql
$ pip install mysql-python
Which is a slightly altered version of the recipe above (note: pip install at the end!)

If you want to install mysql-python, I suggest you to install mysqlclient instead. The authors of these two modules are the same. By far, the authors all turn to keep maintaining mysqlclient. mysqlclient supports both Python 2 and Python 3. And you can use the same codes like mysql-python. Blew is my installation solution for you.
$ brew info openssl
$ brew unlink mysql-connector-c
$ brew install mysql
$ brew link --overwrite mysql-connector-c
$ pip install mysqlclient
If there is an error before pip install mysqlclient. Please fix it according to methane's answer.
And run pip install mysqlclient again.

Or download and install .dmg from the MySQL dev site: https://dev.mysql.com/downloads/file/?id=467834

For those of you who are installing MySQL v5.7 with Brew
Uninstall mysql-connector-c
$ brew uninstall mysql-connector-c
Install specific version, very likely you need to uninstall other installed versions
$ brew install mysql#5.7
You will need to add it to the PATH, since this is 'keg-only' formulae, this is printed after it is installed
$ echo 'export PATH="/usr/local/opt/mysql#5.7/bin:$PATH"' >> ~/.zshrc
Replace ~/.zshrc with the appropriate file.
Install mysql-connector-c
$ brew install mysql-connector-c
Check it is installed properly
$ which mysql
# /usr/local/opt/mysql#5.7/bin/mysql
$ mysql_config
# Usage: /usr/local/opt/mysql#5.7/bin/mysql_config [OPTIONS]
Compiler: Clang 10.0.0.10001145
Options:
--cflags [-I/usr/local/opt/mysql#5.7/include/mysql ]
--cxxflags [-I/usr/local/opt/mysql#5.7/include/mysql ]
--include [-I/usr/local/opt/mysql#5.7/include/mysql]
--libs [-L/usr/local/opt/mysql#5.7/lib -lmysqlclient -lssl -lcrypto]
--libs_r [-L/usr/local/opt/mysql#5.7/lib -lmysqlclient -lssl -lcrypto]
--plugindir [/usr/local/opt/mysql#5.7/lib/plugin]
--socket [/tmp/mysql.sock]
--port [0]
--version [5.7.24]
--libmysqld-libs [-L/usr/local/opt/mysql#5.7/lib -lmysqld -lssl -lcrypto]
--variable=VAR VAR is one of:
pkgincludedir [/usr/local/opt/mysql#5.7/include/mysql]
pkglibdir [/usr/local/opt/mysql#5.7/lib]
plugindir [/usr/local/opt/mysql#5.7/lib/plugin]
Now install mysqlclient
$ pip install mysqlclient

Related

Cannot link gmp: library not found for -lgmp

I'm trying to install fastecdsa on macOS BigSur (M1 chip) by running
(venv) $ pip3 install fastecdsa
and even though I previously installed gmp:
$ brew install gmp
it cant find the lib, no matter what I do
src/curve.h:4:10: fatal error: 'gmp.h' file not found
#include "gmp.h"
Although the error changed when I created a symlink
ln -s /opt/homebrew/include/gmp.h /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
and now I get:
ld: library not found for -lgmp
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command '/usr/bin/gcc' failed with exit code 1
I also tried:
passing the path via env CFLAGS, LDFLAGS and both via global env export (export CFLAGS=...)
LDFLAGS=-L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib pip3 install fastecdsa
CFLAGS=-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include pip3 install fastecdsa
xcode-select --install
endlessly brew uninstall gmp and brew install gmp, even brew reinstall gmp and brew unlink gmp
installing rosetta2
turning it off and on again
I can't put my finger on it :(
You may have resolved this by now, but just to say that I ran into something similar, and the solution for me was to tell ld to look in the homebrew library path. Run this/add it to ~/.profile:
export LIBRARY_PATH=$LIBRARY_PATH:/opt/homebrew/lib
export INCLUDE_PATH=$INCLUDE_PATH:/opt/homebrew/include
(I didn't need INCLUDE_PATH in my case, but it looks like you might!)
After that, perhaps your python commands will start working!
enter image description here
use the setup.py to install and modify the setup.py as the image

ejabberd installation issue for mac

I am installing ejabberd by using source code. I have take the clone from git : https://github.com/processone/ejabberd.git. and followed steps:
Git: brew install git
Erlang /OTP: brew install erlang
Autoconf: brew install autoconf
Automake: brew install automake
Openssl: brew install openssl
Expat: brew install expat
Libyaml: brew install libyaml
Libiconv: brew install libiconv
Sqlite: brew install sqlite
chmod +x autogen.sh
./autogen.sh
export LDFLAGS="-L/usr/local/opt/openssl/lib -L/usr/local/lib -L/usr/local/opt/expat/lib"
export CFLAGS="-I/usr/local/opt/openssl/include/ -I/usr/local/include -I/usr/local/opt/expat/include"
export CPPFLAGS="-I/usr/local/opt/openssl/include/ -I/usr/local/include -I/usr/local/opt/expat/include"
./configure --prefix=$HOME/my-ejabberd --enable-mysql
make
above command is working correctly. but "sudo make install" have the problem.
Configuration files
/usr/bin/install -c -d -m 750 -g pravin //etc/ejabberd
install: pravin: Invalid argument
make: *** [install] Error 67
Please help me.
Thanks in advance.
just brew install ejabberd for current release or brew install ejabberd --HEAD to install current git master HEAD

Trouble installing m2crypto with pip on OS X / macOS

pip install m2crypto
Generates the following output:
building 'M2Crypto.__m2crypto' extension
swigging SWIG/_m2crypto.i to SWIG/_m2crypto_wrap.c
swig -python -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I/usr/include -I/usr/include/openssl -includeall -modern -o SWIG/_m2crypto_wrap.c SWIG/_m2crypto.i
SWIG/_m2crypto.i:30: Error: Unable to find 'openssl/opensslv.h'
SWIG/_m2crypto.i:33: Error: Unable to find 'openssl/safestack.h'
SWIG/_evp.i:12: Error: Unable to find 'openssl/opensslconf.h'
SWIG/_ec.i:7: Error: Unable to find 'openssl/opensslconf.h'
error: command 'swig' failed with exit status 1
I've run:
brew install swig
I wanted a nicer way without installing manually and using only Homebrew (which also does not link openssl by default). Also using pip was a requirement. This seems to work with newest m2crypto 0.22.5. I also tested it once with m2crypto 0.22.3 and seems also to work. The OpenSSL version here is 1.0.2d:
brew install openssl
brew install swig
Finally install m2crypto on macOS in your Bash. It is a long command but it changes SWIG and clang environment variables only during pip install so that m2crypto will get all OpenSSL requirements:
env LDFLAGS="-L$(brew --prefix openssl)/lib" \
CFLAGS="-I$(brew --prefix openssl)/include" \
SWIG_FEATURES="-cpperraswarn -includeall -I$(brew --prefix openssl)/include" \
pip install m2crypto
btw. the last command also works if you use e.g. a requirements.txt.
Update:
Additional also the command for fish shell users...
env LDFLAGS="-L"(brew --prefix openssl)"/lib" \
CFLAGS="-I"(brew --prefix openssl)"/include" \
SWIG_FEATURES="-cpperraswarn -includeall -I"(brew --prefix openssl)"/include" \
pip install m2crypto
thanks to therealmarv env flags i was able to get this to work with the macports version of openssl/swig, this is what i did:
sudo port install openssl
sudo port install swig
sudo port install swig-python
then use therealmarv lines but replace "$(brew --prefix openssl)" with the dir from macports which should be "/opt/local"
sudo env LDFLAGS="-L/opt/local/lib" \
CFLAGS="-I/opt/local/include" \
SWIG_FEATURES="-cpperraswarn -includeall -I/opt/local/include" \
pip install M2Crypto
I just went through a lot of pain getting this working in El Capitan. Here is what I had to do:
Install OpenSSL (you have to use an older version, m2crypto will not compile otherwise)
curl -O https://www.openssl.org/source/openssl-0.9.8zg.tar.gz
tar -xvzf openssl-0.9.8zg.tar.gz
cd openssl-0.9.8zg
./Configure --prefix=/usr/local darwin64-x86_64-cc
make && make test
sudo make install
Install m2crypto
git clone https://github.com/martinpaljak/M2Crypto.git
cd M2Crypto
python setup.py build build_ext --openssl=/usr/local
sudo python setup.py install build_ext --openssl=/usr/local
AFAIK it is installed... I still have to do some testing though.
Got exact same issue on Ubuntu 18.04 LTS, while trying to execute
pip install M2Crypto==0.24.0
Did the following to get rid of it:
sudo apt-get install swig
sudo apt-get install libssl1.0-dev
This fixed my problem (Python 2.7):
export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python2.7/site-packages
macos v10.15.6
m2crypto v0.35.6
pip v20
Solution by therealmarv works,
If the program does not take effect, you can try to upgrade your brew packages. Before the solution.
brew update # update homebrew self
brew upgrade # upgrade all
sudo apt-get install python-m2crypto

Homebrew python3 installation error

I was trying to install python 3 using Homebrew by doing brew install python3 and there was the warning.
Warning: The post-install step did not complete successfully
You can try again using brew postinstall python3
So I did instead do brew postinstall python3
```==> /usr/local/Cellar/python3/3.4.1/bin/python3 -m ensurepip --upgrade
dyld: Library not loaded: ##HOMEBREW_CELLAR##/python3/3.4.1/Frameworks/Python.framework/Versions/3.4/Python
Referenced from: /usr/local/Cellar/python3/3.4.1/bin/python3
Reason: image not found
xcrun: error: active developer path ("/Users/dorislee/Desktop/Macintosh HD/Applications/Xcode.app/Contents/Developer") does not exist, use xcode-select to change
xcrun: error: active developer path ("/Users/dorislee/Desktop/Macintosh HD/Applications/Xcode.app/Contents/Developer") does not exist, use xcode-select to change
READ THIS: https://github.com/Homebrew/homebrew/wiki/troubleshooting```
I am not really sure what to do, is there a way to undo this and fix it?
You can try and uninstall brew remove python3 and then do brew cleanup and brew prune and then reinstall python3 brew install python3 with whatever flags you want.
Check your PYTHONPATH variable, clean it, and then try to install python3 anagin

ImageMagick and OS X Lion trouble

[edit] I was troubleshooting problems with my development environment when I noticed one of my problems was the dependency on ImageMagick, since it's a vital part of my app.
After upgrading to OS X Lion (10.7) i no longer had ImageMagick available, i then tried installing again using MacPorts without success, i then installed from source, and the install wasn't very successfully i had convert and identify but it output error messages that i unfortunately dont have anymore, i by some strange reason decided to remove all of my MacPort libraries and started using Homebrew, i tried installing ImageMagick, it installs OK but when i try to use it throws this error
dyld: Library not loaded: /opt/local/lib/libltdl.7.dylib
Referenced from: /usr/local/bin/convert
Reason: Incompatible library version: convert requires version 11.0.0 or later, but libltdl.7.dylib provides version 10.0.0
Trace/BPT trap: 5
I read online but i have no clue on whats going on here, i found that libltdl is called libtool, and that i obviously need to upgrade it to a newer version, but i havent found any indication of how or where to find the source, or if this should be already be handled by homebrew and why it hasn't.
I tried installing ImageMagick again from source using this installer script https://github.com/masterkain/ImageMagick-sl but when i try to use convert it throws a similar error.
$ convert gnome.jpg -resize 50% gnome_.jpg
dyld: Library not loaded: /opt/local/lib/libltdl.7.dylib
Referenced from: /usr/local/bin/convert
Reason: Incompatible library version: convert requires version 11.0.0 or later, but libltdl.7.dylib provides version 10.0.0
Trace/BPT trap: 5
$ which convert
/usr/local/bin/convert
What can i do to solve my problem?
On 10.8 I solved this issue with:
brew install libtool --universal
brew link libtool
If you don't know what brew is, visit https://github.com/mxcl/homebrew and its wiki.
brew uninstall imagemagick
brew install imagemagick --build-from-source
worked for me
I too use homebrew for installing packages but imagemagick stopped working after upgrading OSX 10.8 to 10.9 (Mavericks). I had to do the following steps:
brew uninstall imagemagick
brew uninstall libtool
brew install libtool --universal
brew install imagemagick --build-from-source
Why the --build-from-source? Well for me running brew install imagemagick on its own to install the pre-built binary wasn't sufficient; it fixed the original 'dyln' error but was replaced with:
unable to load module `/usr/local/Cellar/imagemagick/6.8.7-7/lib/ImageMagick//modules-Q16/coders/png.la': file not found # error/module.c/OpenModule/1277
I also upgraded to Lion and lost ImageMagick, although i'm getting different errors.
i found a Lion distribution on imagemagick.org. not a big fan of the DYLD_LIBRARY_PATH environment variable but it works.
ok scratch that. i just downloaded the ImageMagick source and re-compiled:
cd /tmp
curl -OL ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz
tar -xzf ImageMagick.tar.gz
cd ImageMagick-6.7.2-7/
./configure --prefix=/usr/local --disable-static --with-modules --without-perl --without-magick-plus-plus --with-quantum-depth=8 --disable-openmp --with-gs-font-dir=/usr/local/share/ghostscript/fonts
make
sudo make install
On Mountain Lion OSX,
Even with the updated brew for imagemagick(which includes libtool), this error seemed to happen to me.
so i fixed it using the following commands
brew uninstall libtool
brew install libtool --universal
brew link libtool --force
For others looking and still having trouble, I used this:
https://github.com/maddox/magick-installer
On 10.8, with brew, I solved this issue with:
brew install graphicsmagick
For the googlers: If you happened to have it installed with brew beforehand, you'll need to reinstall by running brew uninstall graphicsmagick before installing again. Easy.
This helped me after restoring OS X 10.9.3 from time machine.
brew uninstall imagemagick
brew uninstall libtool
brew install libtool --universal
brew unlink libtool && brew link libtool
brew install imagemagick
brew install Homebrew/python/pillow
brew link --overwrite pillow
The same problem might occur with OSX Mountain Lion (preview 4). I had to configure some parts separately because there are some library incompatibilities:
dyld: Library not loaded: /usr/local/lib/libjpeg.8.dylib
Referenced from: /usr/local/bin/convert
Reason: Incompatible library version: convert requires version 13.0.0 or later, but libjpeg.8.dylib provides version 9.0.0
I had to add --with-fontconfig=no, --with-lzma=no and use /opt/local/share/... instead of /usr/local/share/... for the ghostscript fonts:
cd /tmp
curl -OL ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz
tar -xzf ImageMagick.tar.gz
cd ImageMagick-6.7.8-0/
./configure --prefix=/usr/local --disable-static --with-modules --without-perl --without-magick-plus-plus --with-quantum-depth=8 --disable-openmp --with-fontconfig=no --with-gs-font-dir=/opt/local/share/ghostscript/fonts --with-lzma=no
make
sudo make install
I could fix the ImageMagick problem by installing corresponding package from cactuslab site.
Then by setting the PATH variables in terminal:
export MAGICK_HOME="/usr/local/ImageMagick/"
export PATH="$MAGICK_HOME/bin:$PATH"
export DYLD_LIBRARY_PATH="$MAGICK_HOME/lib/"
If you're using Homebrew, try the following command:
brew doctor
to diagnose the common problems.
One of it could be to remove DYLD_FALLBACK_LIBRARY_PATH variable from your ~/.profile if you have it.
Or you have to re-install libtool by:
brew reinstall libtool --universal && brew unlink libtool && brew link libtool
I tried most of the solutions above and they didn't work. Here's how I fixed my problem:
brew install imagemagick;
brew install freetype;
cd /usr/X11/lib/;
sudo mv libfreetype.6.dylib libfreetype.6.dylib.orig;
sudo ln -s /usr/local/opt/freetype/lib/libfreetype.6.dylib libfreetype.6.dylib
Tested on OS X 10.7.2
For 10.7.8 and up, you have to install the php version and not the pecl version. Depending on your version of php you've install with Macports you can either do:
sudo port install php-imagick
sudo port install php5-imagick
sudo port install php53-imagick
sudo port install php54-imagick
Remember only to do the one of your current version of php.

Resources