Mac OS Sierra virtualenv (python 2.7) pip install mysqlclient error - mysql

On Mac OS Sierra, created virtualenv using python2.7 and trying to install mysqlclient to use Django w/ MySQL. I installed MySQL 5.6 via homebrew. Running "pip install mysqlclient" gives these errors:
Running setup.py bdist_wheel for mysqlclient ... error
...
13 warnings generated.
cc -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 -Wl,-F. build/temp.macosx-10.12-intel-2.7/_mysql.o -L/usr/local/Cellar/mysql56/5.6.32/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.12-intel-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 'cc' failed with exit status 1
Failed building wheel for mysqlclient
Command "...env2.7/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/nm/mqfwjt115q7g0lpvnx7sylwm0000gn/T/pip-build-tJmAVS/mysqlclient/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/nm/mqfwjt115q7g0lpvnx7sylwm0000gn/T/pip-xVuIu1-record/install-record.txt --single-version-externally-managed --compile --install-headers .../env2.7/include/site/python2.7/mysqlclient" failed with error code 1 in /private/var/folders/nm/mqfwjt115q7g0lpvnx7sylwm0000gn/T/pip-build-tJmAVS/mysqlclient/
Any help would be greatly appreciated.

The answer was installing dev tools using:
xcode-select --install

In my case I needed to do two steps:
xcode-select --install
as #howevilweare says AND also pip install with the brew installed openssl using an env command:
env LDFLAGS="-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib" pip install mysqlclient

Related

An error occurred while installing mysql2 (0.5.3), and Bundler cannot continue

I am in apple M1 mac os 12.1
I have successfully install mysql2 with the command
gem install mysql2 -v '0.5.3' -- \
--with-mysql-lib=/opt/homebrew/Cellar/mysql/8.0.28/lib \
--with-mysql-dir=/opt/homebrew/Cellar/mysql/8.0.28 \
--with-mysql-config=/opt/homebrew/Cellar/mysql/8.0.28/bin/mysql_config \
--with-mysql-include=/opt/homebrew/Cellar/mysql/8.0.28/include
Successfully installed mysql2-0.5.3
Parsing documentation for mysql2-0.5.3
Done installing documentation for mysql2 after 0 seconds
1 gem installed
and when run bundle install I still got the error
linking shared-object mysql2/mysql2.bundle
ld: warning: directory not found for option '-L/opt/homebrew/Cellar/mysql/8.0.28/lib --with-mysql-dir=/opt/homebrew/Cellar/mysql/8.0.28
--with-mysql-config=/opt/homebrew/Cellar/mysql/8.0.28/bin/mysql_config --with-mysql-include=/opt/homebrew/Cellar/mysql/8.0.28/include'
ld: library not found for -lzstd
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [mysql2.bundle] Error 1
An error occurred while installing mysql2 (0.5.3), and Bundler cannot continue.
Make sure that gem install mysql2 -v '0.5.3' succeeds before bundling.
I had the same error with M1 mac and tried those commands below.
$ brew install openssl
$ echo 'export PATH="/opt/homebrew/opt/openssl#1.1/bin:$PATH"' >> ~/.zshrc
$ source ~/.zshrc
$ bundle config --local build.mysql2 "--with-ldflags=-L/opt/homebrew/opt/openssl#1.1/lib"
$ export LIBRARY_PATH=$LIBRARY_PATH:/opt/homebrew/Cellar/zstd/1.5.2/lib:/opt/homebrew/Cellar/openssl#1.1/1.1.1m/lib/
github
Run this command:-
$ sudo apt-get install default-libmysqlclient-dev

Getting error while trying "pip install python-docx" in pycharm terminal

New to python and just trying pip install python-docx and getting this message:
Command "C:\Users\samue\PycharmProjects\testings\venv\Scripts\python.exe -u -c "import setuptools, tokenize;__file
__='C:\Users\samue\AppData\Local\Temp\pip-install-_4bceyq4\lxml\setup.py';f=getattr(tokenize, 'open', open
)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record
C:\Users\samue\AppData\Local\Temp\pip-record-pg5bpdaa\install-record.txt --single-version-externally-managed --com
error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.26.28801\bin\Hos
tX86\x86\cl.exe' failed with exit status 2
----------------------------------------
Command "C:\Users\samue\PycharmProjects\testings\venv\Scripts\python.exe -u -c "import setuptools, tokenize;file='C:\Users
\samue\AppData\Local\Temp\pip-install-_4bceyq4\lxml\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().re
place('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record C:\Users\samue\AppData\Local\Temp\pip-reco
rd-pg5bpdaa\install-record.txt --single-version-externally-managed --compile --install-headers C:\Users\samue\PycharmProjects\te
stings\venv\include\site\python3.8\lxml" failed with error code 1 in C:\Users\samue\AppData\Local\Temp\pip-install-_4bceyq4\lxml
\
When you install with pip you use the command pip and not python.
To see whether pip is correctly installed type:
pip help
See the following page for how to install and configure pip on Windows:
https://phoenixnap.com/kb/install-pip-windows
Your error output shows a problem with lxml. Looking into it I have found the page pip install lxml error which suggests the following solution:
sudo apt-get install --reinstall python-dev libpython2.7-dev.

error when install mysqlclient using pip to MacOS Bigsur

I've tried common solutions written for mysqlclient error
1st try: brew install mysql-connector-c
2nd try:
LDFLAGS=-L/usr/local/opt/openssl/lib pip install mysqlclient
3rd try: brew install zstd
And mysql server is well-running.
But the error is not being fixed..
I am getting clang linker error saying library not found for -lzstd
clang -bundle -undefined dynamic_lookup -L/usr/local/opt/readline/lib -L/usr/local/opt/readline/lib -L/Users/user/.asdf/installs/python/3.7.10/lib -L/usr/local/opt/llvm/lib -L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/readline/lib -L/Users/user/.asdf/installs/python/3.7.10/lib -L/usr/local/opt/llvm/lib -L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib -L/usr/local/opt/llvm/lib -I/usr/local/opt/llvm/include build/temp.macosx-11.2-x86_64-3.7/MySQLdb/_mysql.o -L/usr/local/Cellar/mysql/8.0.25_1/lib -lmysqlclient -lzstd -lresolv -o build/lib.macosx-11.2-x86_64-3.7/MySQLdb/_mysql.cpython-37m-darwin.so
ld: library not found for -lzstd
clang-12: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'clang' failed with exit status 1
In my case I did not had the sudo access so installed brew for my user
Check if your brew is not in default location
do this to check where you have installed brew
brew --prefix
output: Users/helloWorld/homebrew
use the output of above to set the ld flags and cpp flags
for example for me ssl and zstd libs were not found so this is what i did:
export LDFLAGS="-L/Users/helloWorld/homebrew/lib -L/Users/helloWorld/homebrew/opt/openssl/lib"
export CPPFLAGS="-I/Users/helloWorld/homebrew/include -I/Users/helloWorld/homebrew/opt/openssl/include"
and then do the pip install
pip3 install mysqlclient

Unable to install Python-igraph using pip in ubuntu

I got following error when I am trying to install python-igraph using sudo pip install python-igraph
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-ZHOdbM/python-igraph/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-MGaN23-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-ZHOdbM/python-igraph/
I also try to install C core using the link given in the answer UnicodeDecodeError when installing python-igraph
I would suggest you to use conda and the following command :
conda install -c conda-forge python-igraph
https://anaconda.org/conda-forge/python-igraph

error: command 'x86_64-linux-gnu-gcc' when installing mysqlclient

I installed django 1.8.5 in virtualenv and using python 3.4.3
the worked displayed the it works page when using sqlite
I wanted to use mysql and I'm trying to install mysqlclient using
pip install mysqlclient
and I'm getting the following message
----------------------------------------
Failed building wheel for mysqlclient
Failed to build mysqlclient
Installing collected packages: mysqlclient
Running setup.py install for mysqlclient
Complete output from command /home/sasidhar/django/env/bin/python3 -c "import setuptools, tokenize;__file__='/tmp/pip-build-5lj39q67/mysqlclient/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-da2_35zs-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/sasidhar/django/env/include/site/python3.4/mysqlclient:
running install
running build
running build_py
copying MySQLdb/release.py -> build/lib.linux-x86_64-3.4/MySQLdb
running build_ext
building '_mysql' extension
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -Dversion_info=(1,3,6,'final',1) -D__version__=1.3.6 -I/usr/include/mysql -I/usr/include/python3.4m -I/home/sasidhar/django/env/include/python3.4m -c _mysql.c -o build/temp.linux-x86_64-3.4/_mysql.o -DBIG_JOINS=1 -fno-strict-aliasing -g -DNDEBUG
_mysql.c:40:20: fatal error: Python.h: No such file or directory
#include "Python.h"
^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Command "/home/sasidhar/django/env/bin/python3 -c "import setuptools, tokenize;__file__='/tmp/pip-build-5lj39q67/mysqlclient/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-da2_35zs-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/sasidhar/django/env/include/site/python3.4/mysqlclient" failed with error code 1 in /tmp/pip-build-5lj39q67/mysqlclient
I did try installing libraries suggested in error: Setup script exited with error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
and still the problem persists
please help me solve this problem
Thanks guys!!
You need to install python-dev:
sudo apt-get install python-dev
And, since you are using python3:
sudo apt-get install python3-dev
This command should help you.
If you are using mac os you might try:
brew update && brew rm python3 && brew install python3
You need to brew has been installed already, otherwise you can install it. It is very useful for getting packages in Mac OS. http://brew.sh/
For Ubuntu you also need to install build-essential
sudo apt-get install build-essential
For those using different versions, such as Python 3.5, 3.6 or 3.7 I found this:
Part I
For Python 2.x use:
$ sudo apt-get install python-dev
For Python 2.7 use:
$ sudo apt-get install libffi-dev
For Python 3.x use:
$ sudo apt-get install python3-dev
For Python 3.4 use:
$ sudo apt-get install python3.4-dev
For Python 3.7 use:
$ sudo apt-get install python3.7-dev
Part II
If this still doesn't help, others have pointed out to install
$ sudo apt-get install build-essential
and finally
$ sudo apt-get install libssl-dev
But the last two didn't help me personally. Just in case, hope it helps you.
For those using python3.5:
apt-get install python3.5-dev
wget https://bootstrap.pypa.io/get-pip.py
python3.5 get-pip.py
pip3.5 install mysqlclient
Tried all of the above suggestions and a few found elsewhere and nothing worked. In the end the solution was simple enough (courtesy of ignacionf on GitHub):
pip install git+https://github.com/PyMySQL/mysqlclient-python.git