0

My env is

  • freeBSD12.1
  • python2.7.17
  • django1.11.29
  • mysqlserver18.0.19

I'v already uninstall python 3.7.7 and ln -s /usr/local/python2.7/bin/python2.7 /usr/bin/python,a

[root@bsd /home/tl/MySQL-python-1.2.5]# python setup.py build
running build
running build_py
copying MySQLdb/release.py -> build/lib.freebsd-12.1-RELEASE-p3-i386-2.7/MySQLdb
running build_ext
building '_mysql' extension
cc -fno-strict-aliasing -O2 -pipe -fstack-protector-strong -fno-strict-aliasing -DNDEBUG -fPIC -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/local/include/mysql -I/usr/local/include/python2.7 -c _mysql.c -o build/temp.freebsd-12.1-RELEASE-p3-i386-2.7/_mysql.o
_mysql.c:44:10: fatal error: 'my_config.h' file not found
#include "my_config.h"
         ^~~~~~~~~~~~~
1 error generated.
error: command 'cc' failed with exit status 1
[root@bsd /home/tl]# pip install MySQL-python
 building '_mysql' extension
    creating build/temp.freebsd-12.1-RELEASE-p3-i386-2.7
    cc -fno-strict-aliasing -O2 -pipe -fstack-protector-strong -fno-strict-aliasing -DNDEBUG -fPIC -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/local/include/mysql -I/usr/local/include/python2.7 -c _mysql.c -o build/temp.freebsd-12.1-RELEASE-p3-i386-2.7/_mysql.o
    _mysql.c:44:10: fatal error: 'my_config.h' file not found
    #include "my_config.h"
             ^~~~~~~~~~~~~
    1 error generated.
    error: command 'cc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/local/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-sap926/MySQL-python/setup.py'"'"'; __file__='"'"'/tmp/pip-install-sap926/MySQL-python/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-7FvYhj/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python2.7/MySQL-python Check the logs for full command output.
codedge
  • 4,754
  • 2
  • 22
  • 38
boyNana
  • 1
  • 1
  • Look at https://stackoverflow.com/questions/12218229/my-config-h-file-not-found-when-install-mysql-python-on-osx-10-8 and use `pkg install` or `pkg add` instead of `brew` – dmitryro May 01 '20 at 03:40
  • So your **MySQL** is installed - you need the connector for **Python** and **Django** to be able to talk to **MySQL** which is installed with **pip**. You had missing libraries and now you have them. – dmitryro May 01 '20 at 04:31
  • Use `sudo` to get access, or `chmod` to make it writable. – dmitryro May 01 '20 at 04:45
  • [root@bsd /home/tl]# pkg install mysql Updating FreeBSD repository catalogue... FreeBSD repository is up to date. All repositories are up to date. pkg: No packages available to install matching 'mysql' have been found in the repositories [root@bsd /home/tl]# pkg install mysql-connector-c Updating FreeBSD repository catalogue... FreeBSD repository is up to date. All repositories are up to date. pkg: No packages available to install matching 'mysql-connector-c' have been found in the repositories [root@bsd /home/tl]# – boyNana May 01 '20 at 04:48
  • `pkg install mysql57-server mysql57-client` - https://www.howtoforge.com/tutorial/how-to-install-mysql-server-with-phpmyadmin-on-freebsd-11/ – dmitryro May 01 '20 at 04:50
  • I'v already solved my problem,just use the next command:pip install mysqlclient – boyNana May 01 '20 at 07:41

0 Answers0