I am new to Python and Python-Flask and have ran into an error. I am using Ubuntu 18.04.3 LTS and Python 2.7.15+ to build a python-flask web application.
When installing flask-mysqldb I run into an error.
$ pip install flask-mysqldb
The full output:
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Processing ./.cache/pip/wheels/fd/c9/ef/e0e99dfcf898bc040267e36c4a414ff0b22239968a25161012/Flask_MySQLdb-0.2.0-cp27-none-any.whl
Collecting mysqlclient
Using cached https://files.pythonhosted.org/packages/f8/9b/5db9a03e2088a87c26e3e4d4c7f7e8f4c2dbae610f9521cdfac15755a795/mysqlclient-1.4.5.tar.gz
Requirement already satisfied: Flask>=0.10 in ./.local/lib/python2.7/site-packages (from flask-mysqldb) (1.1.1)
Requirement already satisfied: click>=5.1 in ./.local/lib/python2.7/site-packages (from Flask>=0.10->flask-mysqldb) (7.0)
Requirement already satisfied: Werkzeug>=0.15 in ./.local/lib/python2.7/site-packages (from Flask>=0.10->flask-mysqldb) (0.16.0)
Requirement already satisfied: itsdangerous>=0.24 in ./.local/lib/python2.7/site-packages (from Flask>=0.10->flask-mysqldb) (1.1.0)
Requirement already satisfied: Jinja2>=2.10.1 in ./.local/lib/python2.7/site-packages (from Flask>=0.10->flask-mysqldb) (2.10.3)
Requirement already satisfied: MarkupSafe>=0.23 in ./.local/lib/python2.7/site-packages (from Jinja2>=2.10.1->Flask>=0.10->flask-mysqldb) (1.1.1)
Building wheels for collected packages: mysqlclient
Building wheel for mysqlclient (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-Gno8ny/mysqlclient/setup.py'"'"'; __file__='"'"'/tmp/pip-install-Gno8ny/mysqlclient/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-OrgtfM --python-tag cp27
cwd: /tmp/pip-install-Gno8ny/mysqlclient/
Complete output (40 lines):
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/MySQLdb
copying MySQLdb/__init__.py -> build/lib.linux-x86_64-2.7/MySQLdb
copying MySQLdb/_exceptions.py -> build/lib.linux-x86_64-2.7/MySQLdb
copying MySQLdb/compat.py -> build/lib.linux-x86_64-2.7/MySQLdb
copying MySQLdb/connections.py -> build/lib.linux-x86_64-2.7/MySQLdb
copying MySQLdb/converters.py -> build/lib.linux-x86_64-2.7/MySQLdb
copying MySQLdb/cursors.py -> build/lib.linux-x86_64-2.7/MySQLdb
copying MySQLdb/release.py -> build/lib.linux-x86_64-2.7/MySQLdb
copying MySQLdb/times.py -> build/lib.linux-x86_64-2.7/MySQLdb
creating build/lib.linux-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
running build_ext
building 'MySQLdb._mysql' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/MySQLdb
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-PPrPZj/python2.7-2.7.15=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Dversion_info=(1,4,5,'final',0) -D__version__=1.4.5 -I/usr/include/mysql -I/usr/include/python2.7 -c MySQLdb/_mysql.c -o build/temp.linux-x86_64-2.7/MySQLdb/_mysql.o
MySQLdb/_mysql.c: In function ‘_mysql_field_to_python’:
MySQLdb/_mysql.c:1142:33: warning: passing argument 1 of ‘PyInt_FromString’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
return PyInt_FromString(rowitem, NULL, 10);
^~~~~~~
In file included from /usr/include/python2.7/Python.h:89:0,
from MySQLdb/_mysql.c:38:
/usr/include/python2.7/intobject.h:37:24: note: expected ‘char *’ but argument is of type ‘const char *’
PyAPI_FUNC(PyObject *) PyInt_FromString(char*, char**, int);
^~~~~~~~~~~~~~~~
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-PPrPZj/python2.7-2.7.15=. -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -Wl,-z,relro -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-PPrPZj/python2.7-2.7.15=. -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/MySQLdb/_mysql.o -L/usr/lib/x86_64-linux-gnu -lmysqlclient -lpthread -lz -lm -lrt -latomic -lssl -lcrypto -ldl -o build/lib.linux-x86_64-2.7/MySQLdb/_mysql.so
/usr/bin/ld: cannot find -lssl
/usr/bin/ld: cannot find -lcrypto
collect2: error: ld returned 1 exit status
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for mysqlclient
Running setup.py clean for mysqlclient
Failed to build mysqlclient
Installing collected packages: mysqlclient, flask-mysqldb
Running setup.py install for mysqlclient ... error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-Gno8ny/mysqlclient/setup.py'"'"'; __file__='"'"'/tmp/pip-install-Gno8ny/mysqlclient/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-record-uh9IqO/install-record.txt --single-version-externally-managed --compile
cwd: /tmp/pip-install-Gno8ny/mysqlclient/
Complete output (40 lines):
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/MySQLdb
copying MySQLdb/__init__.py -> build/lib.linux-x86_64-2.7/MySQLdb
copying MySQLdb/_exceptions.py -> build/lib.linux-x86_64-2.7/MySQLdb
copying MySQLdb/compat.py -> build/lib.linux-x86_64-2.7/MySQLdb
copying MySQLdb/connections.py -> build/lib.linux-x86_64-2.7/MySQLdb
copying MySQLdb/converters.py -> build/lib.linux-x86_64-2.7/MySQLdb
copying MySQLdb/cursors.py -> build/lib.linux-x86_64-2.7/MySQLdb
copying MySQLdb/release.py -> build/lib.linux-x86_64-2.7/MySQLdb
copying MySQLdb/times.py -> build/lib.linux-x86_64-2.7/MySQLdb
creating build/lib.linux-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
running build_ext
building 'MySQLdb._mysql' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/MySQLdb
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-PPrPZj/python2.7-2.7.15=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Dversion_info=(1,4,5,'final',0) -D__version__=1.4.5 -I/usr/include/mysql -I/usr/include/python2.7 -c MySQLdb/_mysql.c -o build/temp.linux-x86_64-2.7/MySQLdb/_mysql.o
MySQLdb/_mysql.c: In function ‘_mysql_field_to_python’:
MySQLdb/_mysql.c:1142:33: warning: passing argument 1 of ‘PyInt_FromString’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
return PyInt_FromString(rowitem, NULL, 10);
^~~~~~~
In file included from /usr/include/python2.7/Python.h:89:0,
from MySQLdb/_mysql.c:38:
/usr/include/python2.7/intobject.h:37:24: note: expected ‘char *’ but argument is of type ‘const char *’
PyAPI_FUNC(PyObject *) PyInt_FromString(char*, char**, int);
^~~~~~~~~~~~~~~~
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-PPrPZj/python2.7-2.7.15=. -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -Wl,-z,relro -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-PPrPZj/python2.7-2.7.15=. -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/MySQLdb/_mysql.o -L/usr/lib/x86_64-linux-gnu -lmysqlclient -lpthread -lz -lm -lrt -latomic -lssl -lcrypto -ldl -o build/lib.linux-x86_64-2.7/MySQLdb/_mysql.so
/usr/bin/ld: cannot find -lssl
/usr/bin/ld: cannot find -lcrypto
collect2: error: ld returned 1 exit status
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-Gno8ny/mysqlclient/setup.py'"'"'; __file__='"'"'/tmp/pip-install-Gno8ny/mysqlclient/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-record-uh9IqO/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.`
I have read several other questions and solutions (https://stackoverflow.com/a/51228348/12403455) which suggested using:
mysqlclient‑1.4.5‑cp27‑cp27m‑win_amd64.whl
So I installed this by using:
$ pip install mysqlclient-1.4.5-cp27m-win_amd64.whl
And ran into an error:
Requirement 'mysqlclient‑1.4.5‑cp27‑cp27m‑win_amd64.whl' looks like a filename, but the file does not exist
mysqlclient‑1.4.5‑cp27‑cp27m‑win_amd64.whl is not a valid wheel filename.
I am unsure how to resolve this issue or how to proceed. Any help would be appreciated.
You can not use mysqlclient‑1.4.5‑cp27‑cp27m‑win_amd64.whl as you found in other answer, because that is a wheel for Windows and you are on Linux.
The project mysqlclient, which is a dependency of flask-mysqldb, does not distribute wheels for Linux, so you have to build from source code directly (mysqlclient-1.4.5.tar.gz).
Your install likely fails due to missing build dependencies.
As the project landing page has mentioned, install the build dependencies first:
sudo apt-get install python-dev default-libmysqlclient-dev libssl-dev
Then try again to pip install --user flask-mysqldb.
I followed instructions from this answer
mysql_config not found when installing mysqldb python interface
Just in case I ran
sudo apt-get install mysql-server
later
sudo apt-get install libmysqlclient-dev
and finally
pip3 install flask-mysqldb
and it worked, with Ubuntu 18.04
On Windows 10: pip install flask-mysqldb
This worked for me.
Related
This question already has answers here:
How to install libpq-fe.h?
(4 answers)
Closed 2 years ago.
I get the following error when trying to install psycopg2:
(venv) root#scw-determined-panini:/app# pip install psycopg2
Collecting psycopg2
Using cached https://files.pythonhosted.org/packages/a8/8f/1c5690eebf148d1d1554fc00ccf9101e134636553dbb75bdfef4f85d7647/psycopg2-2.8.5.tar.gz
Building wheels for collected packages: psycopg2
Running setup.py bdist_wheel for psycopg2 ... error
Complete output from command /app/venv/bin/python3.8 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-psll6xe_/psycopg2/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/tmp52or8xexpip-wheel- --python-tag cp38:
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.8
creating build/lib.linux-x86_64-3.8/psycopg2
copying lib/_json.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/pool.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/tz.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/_lru_cache.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/_ipaddress.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/extensions.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/_range.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/errors.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/compat.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/sql.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/errorcodes.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/extras.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/__init__.py -> build/lib.linux-x86_64-3.8/psycopg2
running build_ext
building 'psycopg2._psycopg' extension
creating build/temp.linux-x86_64-3.8
creating build/temp.linux-x86_64-3.8/psycopg
x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPSYCOPG_VERSION=2.8.5 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=120004 -DHAVE_LO64=1 -I/app/venv/include -I/usr/include/python3.8 -I. -I/usr/include/postgresql -I/usr/include/postgresql/12/server -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-3.8/psycopg/psycopgmodule.o -Wdeclaration-after-statement
In file included from psycopg/psycopgmodule.c:28:0:
./psycopg/psycopg.h:36:10: fatal error: libpq-fe.h: No such file or directory
#include <libpq-fe.h>
^~~~~~~~~~~~
compilation terminated.
It appears you are missing some prerequisite to build the package from source.
You may install a binary package by installing 'psycopg2-binary' from PyPI.
If you want to install psycopg2 from source, please install the packages
required for the build and try again.
For further information please check the 'doc/src/install.rst' file (also at
<https://www.psycopg.org/docs/install.html>).
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Failed building wheel for psycopg2
Running setup.py clean for psycopg2
Failed to build psycopg2
Installing collected packages: psycopg2
Running setup.py install for psycopg2 ... error
Complete output from command /app/venv/bin/python3.8 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-psll6xe_/psycopg2/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-x62dcj9d-record/install-record.txt --single-version-externally-managed --compile --install-headers /app/venv/include/site/python3.8/psycopg2:
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.8
creating build/lib.linux-x86_64-3.8/psycopg2
copying lib/_json.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/pool.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/tz.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/_lru_cache.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/_ipaddress.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/extensions.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/_range.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/errors.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/compat.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/sql.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/errorcodes.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/extras.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/__init__.py -> build/lib.linux-x86_64-3.8/psycopg2
running build_ext
building 'psycopg2._psycopg' extension
creating build/temp.linux-x86_64-3.8
creating build/temp.linux-x86_64-3.8/psycopg
x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPSYCOPG_VERSION=2.8.5 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=120004 -DHAVE_LO64=1 -I/app/venv/include -I/usr/include/python3.8 -I. -I/usr/include/postgresql -I/usr/include/postgresql/12/server -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-3.8/psycopg/psycopgmodule.o -Wdeclaration-after-statement
In file included from psycopg/psycopgmodule.c:28:0:
./psycopg/psycopg.h:36:10: fatal error: libpq-fe.h: No such file or directory
#include <libpq-fe.h>
^~~~~~~~~~~~
compilation terminated.
It appears you are missing some prerequisite to build the package from source.
You may install a binary package by installing 'psycopg2-binary' from PyPI.
If you want to install psycopg2 from source, please install the packages
required for the build and try again.
For further information please check the 'doc/src/install.rst' file (also at
<https://www.psycopg.org/docs/install.html>).
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Command "/app/venv/bin/python3.8 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-psll6xe_/psycopg2/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-x62dcj9d-record/install-record.txt --single-version-externally-managed --compile --install-headers /app/venv/include/site/python3.8/psycopg2" failed with error code 1 in /tmp/pip-build-psll6xe_/psycopg2/
(venv) root#scw-determined-panini:/app# psycopg2-binary
psycopg2-binary: command not found
(venv) root#scw-determined-panini:/app# pip install psycopg2-binary
Requirement already satisfied: psycopg2-binary in ./venv/lib/python3.8/site-packages
For Ubuntu use
sudo apt install libpq-dev
thanks
While installing mysqlclient using pip3 install mysqlclient I am geting an error "Failed building wheel for mysqlclient".
I tried using sudo apt-get install python3.6-dev libmysqlclient-dev but didn't work. I am using ubuntu 18.04.2 LTS and python 3.6.8. I was trying to install the mysqlclient in a virtual env.
The mysql server is working fine. I used the same method to install on a local windows machine and it worked fine but i can seem to make it work on server. Any ideas on why this happening. Any suggestions will be appreciated.
Error
Collecting mysqlclient
Using cached https://files.pythonhosted.org/packages/d0/97/7326248ac8d5049968bf4ec708a5d3d4806e412a42e74160d7f266a3e03a/mysqlclient-1.4.6.tar.gz
Building wheels for collected packages: mysqlclient
Building wheel for mysqlclient (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /home/abhishek/Django/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-cl9xqcgy/mysqlclient/setup.py'"'"'; __file__='"'"'/tmp/pip-install-cl9xqcgy/mysqlclient/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-345d65je --python-tag cp36
cwd: /tmp/pip-install-cl9xqcgy/mysqlclient/
Complete output (31 lines):
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/__init__.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/_exceptions.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/compat.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/connections.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/converters.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/cursors.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/release.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/times.py -> build/lib.linux-x86_64-3.6/MySQLdb
creating build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
running build_ext
building 'MySQLdb._mysql' extension
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/MySQLdb
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Dversion_info=(1,4,6,'final',0) -D__version__=1.4.6 -I/usr/include/mysql -I/usr/include/python3.6m -I/home/abhishek/Django/include/python3.6m -c MySQLdb/_mysql.c -o build/temp.linux-x86_64-3.6/MySQLdb/_mysql.o
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-Bsymbolic-functions -Wl,-z,relro -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.6/MySQLdb/_mysql.o -lmysqlclient -lpthread -lz -lm -lrt -latomic -lssl -lcrypto -ldl -o build/lib.linux-x86_64-3.6/MySQLdb/_mysql.cpython-36m-x86_64-linux-gnu.so
/usr/bin/ld: cannot find -lssl
/usr/bin/ld: cannot find -lcrypto
collect2: error: ld returned 1 exit status
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for mysqlclient
Running setup.py clean for mysqlclient
Failed to build mysqlclient
Installing collected packages: mysqlclient
Running setup.py install for mysqlclient ... error
ERROR: Command errored out with exit status 1:
command: /home/abhishek/Django/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-cl9xqcgy/mysqlclient/setup.py'"'"'; __file__='"'"'/tmp/pip-install-cl9xqcgy/mysqlclient/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-record-m81sgzux/install-record.txt --single-version-externally-managed --compile --install-headers /home/abhishek/Django/include/site/python3.6/mysqlclient
cwd: /tmp/pip-install-cl9xqcgy/mysqlclient/
Complete output (31 lines):
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/__init__.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/_exceptions.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/compat.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/connections.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/converters.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/cursors.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/release.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/times.py -> build/lib.linux-x86_64-3.6/MySQLdb
creating build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
running build_ext
building 'MySQLdb._mysql' extension
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/MySQLdb
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Dversion_info=(1,4,6,'final',0) -D__version__=1.4.6 -I/usr/include/mysql -I/usr/include/python3.6m -I/home/abhishek/Django/include/python3.6m -c MySQLdb/_mysql.c -o build/temp.linux-x86_64-3.6/MySQLdb/_mysql.o
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-Bsymbolic-functions -Wl,-z,relro -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.6/MySQLdb/_mysql.o -lmysqlclient -lpthread -lz -lm -lrt -latomic -lssl -lcrypto -ldl -o build/lib.linux-x86_64-3.6/MySQLdb/_mysql.cpython-36m-x86_64-linux-gnu.so
/usr/bin/ld: cannot find -lssl
/usr/bin/ld: cannot find -lcrypto
collect2: error: ld returned 1 exit status
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /home/abhishek/Django/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-cl9xqcgy/mysqlclient/setup.py'"'"'; __file__='"'"'/tmp/pip-install-cl9xqcgy/mysqlclient/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-record-m81sgzux/install-record.txt --single-version-externally-managed --compile --install-headers /home/abhishek/Django/include/site/python3.6/mysqlclient Check the logs for full command output.
The actual error is here:
/usr/bin/ld: cannot find -lssl
/usr/bin/ld: cannot find -lcrypto
That means you do not have SSL development headers installed. You can install them like this:
sudo apt-get install libssl-dev
It worked on Windows because PyPI has binary packages available for Windows. There are no binary packages for Linux, so pip has to compile from source, which requires the development headers.
I am trying to install mysqlclient using pip install mysqlclient but it's showing the following error:
pip install mysqlclient
Collecting mysqlclient
Using cached https://files.pythonhosted.org/packages/d0/97/7326248ac8d5049968bf4ec708a5d3d4806e412a42e74160d7f266a3e03a/mysqlclient-1.4.6.tar.gz
Building wheels for collected packages: mysqlclient
Running setup.py bdist_wheel for mysqlclient ... error
Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-haimRr/mysqlclient/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/tmpnpNImepip-wheel- --python-tag cp27:
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/MySQLdb
copying MySQLdb/__init__.py -> build/lib.linux-x86_64-2.7/MySQLdb
copying MySQLdb/_exceptions.py -> build/lib.linux-x86_64-2.7/MySQLdb
copying MySQLdb/compat.py -> build/lib.linux-x86_64-2.7/MySQLdb
copying MySQLdb/connections.py -> build/lib.linux-x86_64-2.7/MySQLdb
copying MySQLdb/converters.py -> build/lib.linux-x86_64-2.7/MySQLdb
copying MySQLdb/cursors.py -> build/lib.linux-x86_64-2.7/MySQLdb
copying MySQLdb/release.py -> build/lib.linux-x86_64-2.7/MySQLdb
copying MySQLdb/times.py -> build/lib.linux-x86_64-2.7/MySQLdb
creating build/lib.linux-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
running build_ext
building 'MySQLdb._mysql' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/MySQLdb
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-PPrPZj/python2.7-2.7.15=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Dversion_info=(1,4,6,'final',0) -D__version__=1.4.6 -I/usr/include/mysql -I/usr/include/python2.7 -c MySQLdb/_mysql.c -o build/temp.linux-x86_64-2.7/MySQLdb/_mysql.o
MySQLdb/_mysql.c: In function ‘_mysql_field_to_python’:
MySQLdb/_mysql.c:1145:33: warning: passing argument 1 of ‘PyInt_FromString’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
return PyInt_FromString(rowitem, NULL, 10);
^~~~~~~
In file included from /usr/include/python2.7/Python.h:89:0,
from MySQLdb/_mysql.c:38:
/usr/include/python2.7/intobject.h:37:24: note: expected ‘char *’ but argument is of type ‘const char *’
PyAPI_FUNC(PyObject *) PyInt_FromString(char*, char**, int);
^~~~~~~~~~~~~~~~
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-PPrPZj/python2.7-2.7.15=. -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -Wl,-z,relro -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-PPrPZj/python2.7-2.7.15=. -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/MySQLdb/_mysql.o -L/usr/lib/x86_64-linux-gnu -lmysqlclient -lpthread -lz -lm -lrt -latomic -lssl -lcrypto -ldl -o build/lib.linux-x86_64-2.7/MySQLdb/_mysql.so
/usr/bin/ld: cannot find -lssl
/usr/bin/ld: cannot find -lcrypto
collect2: error: ld returned 1 exit status
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Failed building wheel for mysqlclient
Running setup.py clean for mysqlclient
Failed to build mysqlclient
Installing collected packages: mysqlclient
Running setup.py install for mysqlclient ... error
Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-haimRr/mysqlclient/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-Z3t7oY-record/install-record.txt --single-version-externally-managed --compile --user --prefix=:
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/MySQLdb
copying MySQLdb/__init__.py -> build/lib.linux-x86_64-2.7/MySQLdb
copying MySQLdb/_exceptions.py -> build/lib.linux-x86_64-2.7/MySQLdb
copying MySQLdb/compat.py -> build/lib.linux-x86_64-2.7/MySQLdb
copying MySQLdb/connections.py -> build/lib.linux-x86_64-2.7/MySQLdb
copying MySQLdb/converters.py -> build/lib.linux-x86_64-2.7/MySQLdb
copying MySQLdb/cursors.py -> build/lib.linux-x86_64-2.7/MySQLdb
copying MySQLdb/release.py -> build/lib.linux-x86_64-2.7/MySQLdb
copying MySQLdb/times.py -> build/lib.linux-x86_64-2.7/MySQLdb
creating build/lib.linux-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
running build_ext
building 'MySQLdb._mysql' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/MySQLdb
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-PPrPZj/python2.7-2.7.15=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Dversion_info=(1,4,6,'final',0) -D__version__=1.4.6 -I/usr/include/mysql -I/usr/include/python2.7 -c MySQLdb/_mysql.c -o build/temp.linux-x86_64-2.7/MySQLdb/_mysql.o
MySQLdb/_mysql.c: In function ‘_mysql_field_to_python’:
MySQLdb/_mysql.c:1145:33: warning: passing argument 1 of ‘PyInt_FromString’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
return PyInt_FromString(rowitem, NULL, 10);
^~~~~~~
In file included from /usr/include/python2.7/Python.h:89:0,
from MySQLdb/_mysql.c:38:
/usr/include/python2.7/intobject.h:37:24: note: expected ‘char *’ but argument is of type ‘const char *’
PyAPI_FUNC(PyObject *) PyInt_FromString(char*, char**, int);
^~~~~~~~~~~~~~~~
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-PPrPZj/python2.7-2.7.15=. -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -Wl,-z,relro -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-PPrPZj/python2.7-2.7.15=. -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/MySQLdb/_mysql.o -L/usr/lib/x86_64-linux-gnu -lmysqlclient -lpthread -lz -lm -lrt -latomic -lssl -lcrypto -ldl -o build/lib.linux-x86_64-2.7/MySQLdb/_mysql.so
/usr/bin/ld: cannot find -lssl
/usr/bin/ld: cannot find -lcrypto
collect2: error: ld returned 1 exit status
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-haimRr/mysqlclient/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-Z3t7oY-record/install-record.txt --single-version-externally-managed --compile --user --prefix=" failed with error code 1 in /tmp/pip-build-haimRr/mysqlclient/
How can I fix this error ?
The error is saying that you miss lssl and lcrypto.
To solve you need to install libssl-dev.
I am trying to create a binary from a python,flask and boto3 app. I am having trouble running the pip install cx_Freeze command too work. I am getting the following error :
It seems to be not fetching the right system libraries. Also, can anyone suggest any tools to package python apps into binaries?
Failed building wheel for cx-Freeze
Running setup.py clean for cx-Freeze
Failed to build cx-Freeze
Installing collected packages: cx-Freeze
Running setup.py install for cx-Freeze ... error
Complete output from command /home/shaswat.g/.virtualenvs/flask_app/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-yLvkz9/cx-Freeze/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-kKRaSM-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/shaswat.g/.virtualenvs/flask_app/include/site/python2.7/cx-Freeze:
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/cx_Freeze
copying cx_Freeze/dist.py -> build/lib.linux-x86_64-2.7/cx_Freeze
copying cx_Freeze/main.py -> build/lib.linux-x86_64-2.7/cx_Freeze
copying cx_Freeze/common.py -> build/lib.linux-x86_64-2.7/cx_Freeze
copying cx_Freeze/__init__.py -> build/lib.linux-x86_64-2.7/cx_Freeze
copying cx_Freeze/macdist.py -> build/lib.linux-x86_64-2.7/cx_Freeze
copying cx_Freeze/finder.py -> build/lib.linux-x86_64-2.7/cx_Freeze
copying cx_Freeze/setupwriter.py -> build/lib.linux-x86_64-2.7/cx_Freeze
copying cx_Freeze/windist.py -> build/lib.linux-x86_64-2.7/cx_Freeze
copying cx_Freeze/hooks.py -> build/lib.linux-x86_64-2.7/cx_Freeze
copying cx_Freeze/freezer.py -> build/lib.linux-x86_64-2.7/cx_Freeze
creating build/lib.linux-x86_64-2.7/cx_Freeze/initscripts
copying cx_Freeze/initscripts/SharedLibSource.py -> build/lib.linux-x86_64-2.7/cx_Freeze/initscripts
copying cx_Freeze/initscripts/__startup__.py -> build/lib.linux-x86_64-2.7/cx_Freeze/initscripts
copying cx_Freeze/initscripts/SharedLib.py -> build/lib.linux-x86_64-2.7/cx_Freeze/initscripts
copying cx_Freeze/initscripts/ConsoleSetLibPath.py -> build/lib.linux-x86_64-2.7/cx_Freeze/initscripts
copying cx_Freeze/initscripts/Console.py -> build/lib.linux-x86_64-2.7/cx_Freeze/initscripts
creating build/lib.linux-x86_64-2.7/cx_Freeze/samples
creating build/lib.linux-x86_64-2.7/cx_Freeze/samples/relimport
copying cx_Freeze/samples/relimport/setup.py -> build/lib.linux-x86_64-2.7/cx_Freeze/samples/relimport
copying cx_Freeze/samples/relimport/relimport.py -> build/lib.linux-x86_64-2.7/cx_Freeze/samples/relimport
creating build/lib.linux-x86_64-2.7/cx_Freeze/samples/service
copying cx_Freeze/samples/service/Config.py -> build/lib.linux-x86_64-2.7/cx_Freeze/samples/service
copying cx_Freeze/samples/service/setup.py -> build/lib.linux-x86_64-2.7/cx_Freeze/samples/service
copying cx_Freeze/samples/service/ServiceHandler.py -> build/lib.linux-x86_64-2.7/cx_Freeze/samples/service
creating build/lib.linux-x86_64-2.7/cx_Freeze/samples/openpyxl
copying cx_Freeze/samples/openpyxl/setup.py -> build/lib.linux-x86_64-2.7/cx_Freeze/samples/openpyxl
copying cx_Freeze/samples/openpyxl/test_openpyxl.py -> build/lib.linux-x86_64-2.7/cx_Freeze/samples/openpyxl
creating build/lib.linux-x86_64-2.7/cx_Freeze/samples/simple
copying cx_Freeze/samples/simple/hello.py -> build/lib.linux-x86_64-2.7/cx_Freeze/samples/simple
copying cx_Freeze/samples/simple/setup.py -> build/lib.linux-x86_64-2.7/cx_Freeze/samples/simple
creating build/lib.linux-x86_64-2.7/cx_Freeze/samples/matplotlib
copying cx_Freeze/samples/matplotlib/setup.py -> build/lib.linux-x86_64-2.7/cx_Freeze/samples/matplotlib
copying cx_Freeze/samples/matplotlib/matplotlib_eg.py -> build/lib.linux-x86_64-2.7/cx_Freeze/samples/ matplotlib
creating build/lib.linux-x86_64-2.7/cx_Freeze/samples/PyQt4
copying cx_Freeze/samples/PyQt4/setup.py -> build/lib.linux-x86_64-2.7/cx_Freeze/samples/PyQt4
copying cx_Freeze/samples/PyQt4/PyQt4app.py -> build/lib.linux-x86_64-2.7/cx_Freeze/samples/PyQt4
creating build/lib.linux-x86_64-2.7/cx_Freeze/samples/advanced
copying cx_Freeze/samples/advanced/advanced_1.py -> build/lib.linux-x86_64-2.7/cx_Freeze/samples/advanced
copying cx_Freeze/samples/advanced/advanced_2.py -> build/lib.linux-x86_64-2.7/cx_Freeze/samples/advanced
copying cx_Freeze/samples/advanced/setup.py -> build/lib.linux-x86_64-2.7/cx_Freeze/samples/advanced
creating build/lib.linux-x86_64-2.7/cx_Freeze/samples/asmodule
copying cx_Freeze/samples/asmodule/asmodule.py -> build/lib.linux-x86_64-2.7/cx_Freeze/samples/asmodule
copying cx_Freeze/samples/asmodule/setup.py -> build/lib.linux-x86_64-2.7/cx_Freeze/samples/asmodule
creating build/lib.linux-x86_64-2.7/cx_Freeze/samples/zope
copying cx_Freeze/samples/zope/setup.py -> build/lib.linux-x86_64-2.7/cx_Freeze/samples/zope
copying cx_Freeze/samples/zope/qotd.py -> build/lib.linux-x86_64-2.7/cx_Freeze/samples/zope
creating build/lib.linux-x86_64-2.7/cx_Freeze/samples/Tkinter
copying cx_Freeze/samples/Tkinter/setup.py -> build/lib.linux-x86_64-2.7/cx_Freeze/samples/Tkinter
copying cx_Freeze/samples/Tkinter/SimpleTkApp.py -> build/lib.linux-x86_64-2.7/cx_Freeze/samples/Tkinter
creating build/lib.linux-x86_64-2.7/cx_Freeze/samples/wx
copying cx_Freeze/samples/wx/setup.py -> build/lib.linux-x86_64-2.7/cx_Freeze/samples/wx
copying cx_Freeze/samples/wx/wxapp.py -> build/lib.linux-x86_64-2.7/cx_Freeze/samples/wx
running build_ext
building 'cx_Freeze.util' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/source
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-HVkOs2/python2.7-2.7.13=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c source/util.c -o build/temp.linux-x86_64-2.7/source/util.o
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/ python2.7-HVkOs2/python2.7-2.7.13=. -fstack-protector-strong -Wformat -Werror=format-security -Wl,-z,relro -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-HVkOs2/python2.7-2.7.13=. -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/source/util.o -o build/ lib.linux-x86_64-2.7/cx_Freeze/util.so
creating build/temp.linux-x86_64-2.7/source/bases
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-HVkOs2/python2.7-2.7.13=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c source/bases/ Console.c -o build/temp.linux-x86_64-2.7/source/bases/Console.o
creating build/lib.linux-x86_64-2.7/cx_Freeze/bases
x86_64-linux-gnu-gcc -pthread build/temp.linux-x86_64-2.7/source/bases/Console.o -L/usr/lib/python2.7/ config-x86_64-linux-gnu -lpython2.7 -o build/lib.linux-x86_64-2.7/cx_Freeze/bases/Console -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions -lpthread -ldl -lutil -lm -L/usr/lib -lz -s
/usr/bin/ld: cannot find -lz
collect2: error: ld returned 1 exit status
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Command "/home/shaswat.g/.virtualenvs/flask_app/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-yLvkz9/cx-Freeze/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-kKRaSM-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/shaswat.g/.virtualenvs/flask_app/include/site/python2.7/cx-Freeze" failed with error code 1 in /tmp/pip-build-yLvkz9/cx-Freeze/
Just do
sudo apt install zlib1g-dev
I was trying to install cx-freeze to convert some python code to an exe but the problem was /usr/bin/ld: cannot find -lz just like you. The file being fetched is compressed (cx_Freeze-5.1.1.tar.gz) so you need zlib. Of course use pip3 for python3.
pip never installs system libraries, it only concerns itself with Python libs.
It seems you need to install zlib before installing cx_Freeze.
Another tool to generate binaries is PyInstaller.
This solution works for me on centos8
yum install gcc
yum install python3-devel
pip install wheel
pip install importlib-metadata
pip install patchelf
pip3 install cx-Freeze
Django documentation as of v1.8 recommends using mysqlclient connector for the framework. I'm attempting to pip install the package on Ubuntu 14.04 with Python 3.4 and running into a GCC error that I'm unable to find reference to. I'm not an expert on compiling software, so was hoping somebody can see the solution.
I believe I'm getting a linking error. I have installed distro specific mysql headers, but it looked like they were only applicable to Python 2.7.x.
Not sure how much of this is useful so apologies for the long paste, but here's the error log:
Using version 1.3.6 (newest of versions: 1.3.6, 1.3.5, 1.3.4, 1.3.3, 1.3.2, 1.3.1, 1.3.0)
Downloading from URL https://pypi.python.org/packages/source/m/mysqlclient/mysqlclient-1.3.6.tar.gz#md5=58d7c9c617a4286a88db290e7857d3aa (from https://pypi.python.org/simple/mysqlclient/)
Running setup.py (path:/tmp/pycharm-packaging4.tmp/mysqlclient/setup.py) egg_info for package mysqlclient
running egg_info
creating pip-egg-info/mysqlclient.egg-info
writing dependency_links to pip-egg-info/mysqlclient.egg-info/dependency_links.txt
writing top-level names to pip-egg-info/mysqlclient.egg-info/top_level.txt
writing pip-egg-info/mysqlclient.egg-info/PKG-INFO
writing manifest file 'pip-egg-info/mysqlclient.egg-info/SOURCES.txt'
warning: manifest_maker: standard file '-c' not found
reading manifest file 'pip-egg-info/mysqlclient.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'pip-egg-info/mysqlclient.egg-info/SOURCES.txt'
Source in /tmp/pycharm-packaging4.tmp/mysqlclient has version 1.3.6, which satisfies requirement mysqlclient
Installing collected packages: mysqlclient
Running setup.py install for mysqlclient
Running command /home/tim/BingVEnv/bin/python -c "import setuptools, tokenize;__file__='/tmp/pycharm-packaging4.tmp/mysqlclient/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-4bp9npvl-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/tim/BingVEnv/include/site/python3.4
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.4
copying _mysql_exceptions.py -> build/lib.linux-x86_64-3.4
creating build/lib.linux-x86_64-3.4/MySQLdb
copying MySQLdb/__init__.py -> build/lib.linux-x86_64-3.4/MySQLdb
copying MySQLdb/compat.py -> build/lib.linux-x86_64-3.4/MySQLdb
copying MySQLdb/converters.py -> build/lib.linux-x86_64-3.4/MySQLdb
copying MySQLdb/connections.py -> build/lib.linux-x86_64-3.4/MySQLdb
copying MySQLdb/cursors.py -> build/lib.linux-x86_64-3.4/MySQLdb
copying MySQLdb/release.py -> build/lib.linux-x86_64-3.4/MySQLdb
copying MySQLdb/times.py -> build/lib.linux-x86_64-3.4/MySQLdb
creating build/lib.linux-x86_64-3.4/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-3.4/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-3.4/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-3.4/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-3.4/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-3.4/MySQLdb/constants
copying MySQLdb/constants/REFRESH.py -> build/lib.linux-x86_64-3.4/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-3.4/MySQLdb/constants
running build_ext
building '_mysql' extension
creating build/temp.linux-x86_64-3.4
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -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/home/tim/BingVEnv/include -I/usr/include/python3.4m -c _mysql.c -o build/temp.linux-x86_64-3.4/_mysql.o -fPIC -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-Bsymbolic-functions -Wl,-z,relro -g -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.4/_mysql.o -lmysqlclient -lpthread -lz -lm -ldl -o build/lib.linux-x86_64-3.4/_mysql.cpython-34m.so
/usr/bin/ld: cannot find -lz
collect2: error: ld returned 1 exit status
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
Complete output from command /home/tim/BingVEnv/bin/python -c "import setuptools, tokenize;__file__='/tmp/pycharm-packaging4.tmp/mysqlclient/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-4bp9npvl-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/tim/BingVEnv/include/site/python3.4:
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.4
copying _mysql_exceptions.py -> build/lib.linux-x86_64-3.4
creating build/lib.linux-x86_64-3.4/MySQLdb
copying MySQLdb/__init__.py -> build/lib.linux-x86_64-3.4/MySQLdb
copying MySQLdb/compat.py -> build/lib.linux-x86_64-3.4/MySQLdb
copying MySQLdb/converters.py -> build/lib.linux-x86_64-3.4/MySQLdb
copying MySQLdb/connections.py -> build/lib.linux-x86_64-3.4/MySQLdb
copying MySQLdb/cursors.py -> build/lib.linux-x86_64-3.4/MySQLdb
copying MySQLdb/release.py -> build/lib.linux-x86_64-3.4/MySQLdb
copying MySQLdb/times.py -> build/lib.linux-x86_64-3.4/MySQLdb
creating build/lib.linux-x86_64-3.4/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-3.4/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-3.4/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-3.4/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-3.4/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-3.4/MySQLdb/constants
copying MySQLdb/constants/REFRESH.py -> build/lib.linux-x86_64-3.4/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-3.4/MySQLdb/constants
running build_ext
building '_mysql' extension
creating build/temp.linux-x86_64-3.4
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -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/home/tim/BingVEnv/include -I/usr/include/python3.4m -c _mysql.c -o build/temp.linux-x86_64-3.4/_mysql.o -fPIC -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-Bsymbolic-functions -Wl,-z,relro -g -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.4/_mysql.o -lmysqlclient -lpthread -lz -lm -ldl -o build/lib.linux-x86_64-3.4/_mysql.cpython-34m.so
/usr/bin/ld: cannot find -lz
collect2: error: ld returned 1 exit status
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
It looks like you're missing zlib; you'll want to install it: apt-get install zlib1g-dev
I also suggest reading over the README and confirming you have all other dependencies met: https://github.com/dccmx/mysqldb/blob/master/README
Also, I suggest using mysqlclient over MySQLdb as its a fork of MySQLdb and what Django recommends.
using this MySQL Connector worked for me:
https://dev.mysql.com/downloads/connector/python/
https://dev.mysql.com/doc/connector-python/en/connector-python-installation.html
http://dev.mysql.com/doc/connector-python/en/connector-python-django-backend.html