Trac / MySQL-python on Ubuntu 20.04

1,064 views
Skip to first unread message

Andreas

unread,
Nov 12, 2020, 10:38:49 AM11/12/20
to Trac Users
Hello together,

I have just noticed that the necessary MySQL-python is not running under Ubuntu 20.04 anymore, more specificly, it cannot be installed with "pip install MySQL-python".

I would need this to run Trac 2.2.5 with MariaDB. Under Ubuntu 18.04, I did exactly the same steps and installation was no problem.

Is there any way to get Trac running under Ubuntu 20.04 with MariaDB as a database?
Unfortunately, downgrading our server to Ubuntu 18.04 isn't really an option...

Any help appreciated!
Thank you!

Error under Ubuntu 20.04:

root@server:/# pip install MySQL-python
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Collecting MySQL-python
  Using cached MySQL-python-1.2.5.zip (108 kB)
Building wheels for collected packages: MySQL-python
  Building wheel for MySQL-python (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/bin/python2 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-pcwRtX/MySQL-python/setup.py'"'"'; __file__='"'"'/tmp/pip-install-pcwRtX/MySQL-python/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-mQzdal
       cwd: /tmp/pip-install-pcwRtX/MySQL-python/
  Complete output (30 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-2.7
  copying _mysql_exceptions.py -> 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/converters.py -> build/lib.linux-x86_64-2.7/MySQLdb
  copying MySQLdb/connections.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/CR.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/ER.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
  copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
  copying MySQLdb/constants/REFRESH.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
  copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
  running build_ext
  building '_mysql' extension
  creating build/temp.linux-x86_64-2.7
  x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-U5f0ID/python2.7-2.7.18=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/include/mysql -I/usr/include/python2.7 -c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o
  _mysql.c:29:10: fatal error: Python.h: No such file or directory
     29 | #include "Python.h"
        |          ^~~~~~~~~~
  compilation terminated.
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for MySQL-python
  Running setup.py clean for MySQL-python
Failed to build MySQL-python
Installing collected packages: MySQL-python
    Running setup.py install for MySQL-python ... error
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python2 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-pcwRtX/MySQL-python/setup.py'"'"'; __file__='"'"'/tmp/pip-install-pcwRtX/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-MyCi8N/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python2.7/MySQL-python
         cwd: /tmp/pip-install-pcwRtX/MySQL-python/
    Complete output (30 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-2.7
    copying _mysql_exceptions.py -> 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/converters.py -> build/lib.linux-x86_64-2.7/MySQLdb
    copying MySQLdb/connections.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/CR.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/ER.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
    copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
    copying MySQLdb/constants/REFRESH.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
    copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
    running build_ext
    building '_mysql' extension
    creating build/temp.linux-x86_64-2.7
    x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-U5f0ID/python2.7-2.7.18=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/include/mysql -I/usr/include/python2.7 -c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o
    _mysql.c:29:10: fatal error: Python.h: No such file or directory
       29 | #include "Python.h"
          |          ^~~~~~~~~~
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python2 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-pcwRtX/MySQL-python/setup.py'"'"'; __file__='"'"'/tmp/pip-install-pcwRtX/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-MyCi8N/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python2.7/MySQL-python Check the logs for full command output.

Jun Omae

unread,
Nov 12, 2020, 10:51:12 AM11/12/20
to trac-...@googlegroups.com
On Fri, Nov 13, 2020 at 12:38 AM Andreas <muffe...@gmail.com> wrote:
> I have just noticed that the necessary MySQL-python is not running under Ubuntu 20.04 anymore, more specificly, it cannot be installed with "pip install MySQL-python".
>
> I would need this to run Trac 2.2.5 with MariaDB. Under Ubuntu 18.04, I did exactly the same steps and installation was no problem.
>
> Is there any way to get Trac running under Ubuntu 20.04 with MariaDB as a database?
> Unfortunately, downgrading our server to Ubuntu 18.04 isn't really an option...
>
> Any help appreciated!
> Thank you!
>
> Error under Ubuntu 20.04:
>
> root@server:/# pip install MySQL-python
> ...
> x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-U5f0ID/python2.7-2.7.18=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/include/mysql -I/usr/include/python2.7 -c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o
> _mysql.c:29:10: fatal error: Python.h: No such file or directory
> 29 | #include "Python.h"
> | ^~~~~~~~~~
> compilation terminated.
> error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
> ...

python2.7-dev and libmariadb-dev-compat packages are required to build
MySQL-python library.

$ sudo apt install python2.7-dev libmariadb-dev-compat

--
Jun Omae <jun...@gmail.com> (大前 潤)

Markus Rosjat

unread,
Nov 12, 2020, 11:01:46 AM11/12/20
to trac-...@googlegroups.com
Hi ,  

You need to install ptyhon-dev so you get python.h

Cheers

Markus

--
You received this message because you are subscribed to the Google Groups "Trac Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trac-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/trac-users/8cf8b089-25ad-41f2-abb0-705b2a25a6c5n%40googlegroups.com.

Andreas

unread,
Nov 12, 2020, 11:52:39 AM11/12/20
to Trac Users
Thank you both for your hints. I just intalled the two programs and now I am still getting a (slightly different) error.... Any further ideas?


root@server:/# pip install MySQL-python
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.

Collecting MySQL-python
  Using cached MySQL-python-1.2.5.zip (108 kB)
Building wheels for collected packages: MySQL-python
  Building wheel for MySQL-python (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/bin/python2 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-AR0wp8/mysql-python/setup.py'"'"'; __file__='"'"'/tmp/pip-install-AR0wp8/mysql-python/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-NggNke
       cwd: /tmp/pip-install-AR0wp8/mysql-python/
  Complete output (34 lines):

  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-2.7
  copying _mysql_exceptions.py -> 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/converters.py -> build/lib.linux-x86_64-2.7/MySQLdb
  copying MySQLdb/connections.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/CR.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/ER.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
  copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
  copying MySQLdb/constants/REFRESH.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
  copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
  running build_ext
  building '_mysql' extension
  creating build/temp.linux-x86_64-2.7
  x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-U5f0ID/python2.7-2.7.18=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/include/mariadb -I/usr/include/mariadb/mysql -I/usr/include/python2.7 -c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o
  In file included from _mysql.c:44:
  /usr/include/mariadb/my_config.h:3:2: warning: #warning This file should not be included by clients, include only <mysql.h> [-Wcpp]
      3 | #warning This file should not be included by clients, include only <mysql.h>
        |  ^~~~~~~
  _mysql.c: In function ‘_mysql_ConnectionObject_ping’:
  _mysql.c:2005:41: error: ‘MYSQL’ {aka ‘struct st_mysql’} has no member named ‘reconnect’
   2005 |  if ( reconnect != -1 ) self->connection.reconnect = reconnect;
        |                                         ^

  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for MySQL-python
  Running setup.py clean for MySQL-python
Failed to build MySQL-python
Installing collected packages: MySQL-python
    Running setup.py install for MySQL-python ... error
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python2 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-AR0wp8/mysql-python/setup.py'"'"'; __file__='"'"'/tmp/pip-install-AR0wp8/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-vPnHkG/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python2.7/MySQL-python
         cwd: /tmp/pip-install-AR0wp8/mysql-python/
    Complete output (34 lines):

    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-2.7
    copying _mysql_exceptions.py -> 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/converters.py -> build/lib.linux-x86_64-2.7/MySQLdb
    copying MySQLdb/connections.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/CR.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/ER.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
    copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
    copying MySQLdb/constants/REFRESH.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
    copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
    running build_ext
    building '_mysql' extension
    creating build/temp.linux-x86_64-2.7
    x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-U5f0ID/python2.7-2.7.18=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/include/mariadb -I/usr/include/mariadb/mysql -I/usr/include/python2.7 -c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o
    In file included from _mysql.c:44:
    /usr/include/mariadb/my_config.h:3:2: warning: #warning This file should not be included by clients, include only <mysql.h> [-Wcpp]
        3 | #warning This file should not be included by clients, include only <mysql.h>
          |  ^~~~~~~
    _mysql.c: In function ‘_mysql_ConnectionObject_ping’:
    _mysql.c:2005:41: error: ‘MYSQL’ {aka ‘struct st_mysql’} has no member named ‘reconnect’
     2005 |  if ( reconnect != -1 ) self->connection.reconnect = reconnect;
          |                                         ^

    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python2 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-AR0wp8/mysql-python/setup.py'"'"'; __file__='"'"'/tmp/pip-install-AR0wp8/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-vPnHkG/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python2.7/MySQL-python Check the logs for full command output.

RjOllos

unread,
Nov 12, 2020, 11:56:10 AM11/12/20
to Trac Users
On Thursday, November 12, 2020 at 7:38:49 AM UTC-8 Andreas wrote:
Hello together,

I have just noticed that the necessary MySQL-python is not running under Ubuntu 20.04 anymore, more specificly, it cannot be installed with "pip install MySQL-python".

I would need this to run Trac 2.2.5 with MariaDB. Under Ubuntu 18.04, I did exactly the same steps and installation was no problem.

Is there any way to get Trac running under Ubuntu 20.04 with MariaDB as a database?
Unfortunately, downgrading our server to Ubuntu 18.04 isn't really an option...

Any help appreciated!
Thank you!

Have you considered switching to Trac 1.4.2? The dependency is PyMySQL. We made the switch because MySQLdb is no longer developed.

Ryan 

Andreas

unread,
Nov 12, 2020, 1:13:30 PM11/12/20
to Trac Users
I just tested all our plugins with 1.4.2, but the TracHoursPlugin is not working on this version, so this is currently no option...I have created a ticket for this issue.

Andreas

unread,
Mar 17, 2021, 12:14:29 PM3/17/21
to Trac Users
Hello again,

I do now really have to migrate our database to MariaDB as we have to access Trac from another system to read and write data to it.

As the pip-installation is not working anymore, I found a way to install python-mysqldb (is this even the right package?!) on Ubuntu 20.04 by adding an older repository to my installation with the following commands:

sudo add-apt-repository 'deb http://archive.ubuntu.com/ubuntu bionic main'
sudo apt update
sudo apt install -y python-mysqldb

Source:

... but I am still getting the error during Trac migration that says "trac.core.TracError: Unsupported database type "mysql".
Any idea of what coul be wrong / how to install the right package on Ubuntu 20.04?

As long as the TracHoursPlugin is not working on Trac 1.4.2, I really need to find a way to migrate the older 1.2.2 to MySQL on Ubuntu 20.04...

Thanks for any hints!!

Ryan Ollos

unread,
Mar 17, 2021, 12:27:03 PM3/17/21
to Trac Users
On Wed, Mar 17, 2021 at 9:14 AM Andreas <muffe...@gmail.com> wrote:
Hello again,

I do now really have to migrate our database to MariaDB as we have to access Trac from another system to read and write data to it.

As the pip-installation is not working anymore, I found a way to install python-mysqldb (is this even the right package?!) on Ubuntu 20.04 by adding an older repository to my installation with the following commands:

sudo add-apt-repository 'deb http://archive.ubuntu.com/ubuntu bionic main'
sudo apt update
sudo apt install -y python-mysqldb

Source:

... but I am still getting the error during Trac migration that says "trac.core.TracError: Unsupported database type "mysql".
Any idea of what coul be wrong / how to install the right package on Ubuntu 20.04?

As long as the TracHoursPlugin is not working on Trac 1.4.2, I really need to find a way to migrate the older 1.2.2 to MySQL on Ubuntu 20.04...

Thanks for any hints!!

I would create a virtualenv and "pip install mysql-python".

Andreas

unread,
Mar 18, 2021, 2:14:34 AM3/18/21
to Trac Users
Hey Ryan,

I just tried this, but I'm still getting the same error...
Any other idea?

Thank you!


(env) root@andreas-VirtualBox:/home/andreas/env# pip install MySQL-python

DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Collecting MySQL-python
  Using cached MySQL-python-1.2.5.zip (108 kB)
Building wheels for collected packages: MySQL-python
  Building wheel for MySQL-python (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /home/andreas/env/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-feS5dG/mysql-python/setup.py'"'"'; __file__='"'"'/tmp/pip-install-feS5dG/mysql-python/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-vt99l4
       cwd: /tmp/pip-install-feS5dG/mysql-python/
  x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-QDqKfA/python2.7-2.7.18=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/include/mysql -I/usr/include/python2.7 -c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o
  _mysql.c:44:10: fatal error: my_config.h: No such file or directory
     44 | #include "my_config.h"
        |          ^~~~~~~~~~~~~

  compilation terminated.
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for MySQL-python
  Running setup.py clean for MySQL-python
Failed to build MySQL-python
Installing collected packages: MySQL-python
    Running setup.py install for MySQL-python ... error
    ERROR: Command errored out with exit status 1:
     command: /home/andreas/env/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-feS5dG/mysql-python/setup.py'"'"'; __file__='"'"'/tmp/pip-install-feS5dG/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-NNfKPd/install-record.txt --single-version-externally-managed --compile --install-headers /home/andreas/env/include/site/python2.7/MySQL-python
         cwd: /tmp/pip-install-feS5dG/mysql-python/
    x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-QDqKfA/python2.7-2.7.18=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/include/mysql -I/usr/include/python2.7 -c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o
    _mysql.c:44:10: fatal error: my_config.h: No such file or directory
       44 | #include "my_config.h"
          |          ^~~~~~~~~~~~~

    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /home/andreas/env/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-feS5dG/mysql-python/setup.py'"'"'; __file__='"'"'/tmp/pip-install-feS5dG/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-NNfKPd/install-record.txt --single-version-externally-managed --compile --install-headers /home/andreas/env/include/site/python2.7/MySQL-python Check the logs for full command output.

Andreas

unread,
Mar 18, 2021, 5:42:06 AM3/18/21
to Trac Users
I finally found the solution to install MySQL-python here, but I do have another problem now while running the migration script...I guess it doesn't have to do with the migration script as I tried to migrate in Ubuntu 18.04 (without any errors), exported the MariaDB-database, imported the database in Ubuntu 20.04, changed the connection string in trac.ini to mysql and I am getting the following error in the Trac Logfile:

2021-03-18 10:16:31,836 Trac[main] ERROR: can't retrieve session: TimeoutError: Unable to get database connection within 0 seconds. (AttributeError: 'NoneType' object has no attribute 'connect')

Additionally, I am getting the following warnings in the Browser:

Warning:
  • Error with navigation contributor "PreferencesModule"
  • Error with navigation contributor "BrowserModule"


Does anyone have an idea of what could be wrong? Maybe just a permission issue somewhere?
I am thankful for every kind of hint!

Thanks!



Migration script error:

./trac-migrate.py --in-place /var/lib/trac/visicon mysql://tracuser:password@localhost/trac_migrate
Traceback (most recent call last):
  File "./trac-migrate.py", line 55, in <module>
    sys.exit(main(sys.argv[1:]) or 0)
  File "./trac-migrate.py", line 45, in main
    if env.needs_upgrade():
  File "/usr/local/lib/python2.7/dist-packages/trac/env.py", line 806, in needs_upgrade
    for participant in self.setup_participants:
  File "/usr/local/lib/python2.7/dist-packages/trac/core.py", line 95, in extensions
    components = [component.compmgr[cls] for cls in classes]
  File "/usr/local/lib/python2.7/dist-packages/trac/core.py", line 238, in __getitem__
    component = cls(self)
  File "/usr/local/lib/python2.7/dist-packages/trac/core.py", line 157, in __call__
    self.__init__()
  File "build/bdist.linux-x86_64/egg/trachours/db.py", line 45, in __init__
  File "build/bdist.linux-x86_64/egg/trachours/db.py", line 104, in version
  File "/usr/local/lib/python2.7/dist-packages/trac/db/api.py", line 121, in execute
    with self as db:
  File "/usr/local/lib/python2.7/dist-packages/trac/db/api.py", line 174, in __enter__
    db = self.dbmgr.get_connection(readonly=True)
  File "/usr/local/lib/python2.7/dist-packages/trac/db/api.py", line 465, in get_connection
    db = self._cnx_pool.get_cnx(self.timeout or None)
  File "/usr/local/lib/python2.7/dist-packages/trac/db/pool.py", line 214, in get_cnx
    return _backend.get_cnx(self._connector, self._kwargs, timeout)
  File "/usr/local/lib/python2.7/dist-packages/trac/db/pool.py", line 135, in get_cnx
    raise TimeoutError(errmsg)
trac.db.pool.TimeoutError: Unable to get database connection within 0 seconds. (AttributeError: 'NoneType' object has no attribute 'connect')

Jun Omae

unread,
Mar 18, 2021, 6:04:00 AM3/18/21
to trac-...@googlegroups.com
trac-migrate.py isn't needed for your case. Instead, use mysqldump.
> --
> You received this message because you are subscribed to the Google Groups "Trac Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to trac-users+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/trac-users/79d7dcad-eabf-4563-bbbb-0c1b6590dd7fn%40googlegroups.com.

Andreas

unread,
Mar 18, 2021, 6:12:23 AM3/18/21
to Trac Users
I used mysqldump to export the db in the old system and imported the database to the new system afterwards, but now I am getting this error message in Trac:

Unable to get database connection within 0 seconds. (AttributeError: 'NoneType' object has no attribute 'connect')




RjOllos

unread,
Mar 18, 2021, 1:43:03 PM3/18/21
to Trac Users
On Thursday, March 18, 2021 at 3:12:23 AM UTC-7 Andreas wrote:
I used mysqldump to export the db in the old system and imported the database to the new system afterwards, but now I am getting this error message in Trac:

Unable to get database connection within 0 seconds. (AttributeError: 'NoneType' object has no attribute 'connect')


Did you set the [trac] database connection string?

 

RjOllos

unread,
Mar 18, 2021, 1:43:57 PM3/18/21
to Trac Users
On Thursday, March 18, 2021 at 2:42:06 AM UTC-7 Andreas wrote:
I finally found the solution to install MySQL-python here

To get that header file, you may typically need to install the "source" version of the package from the package repository. 

Andreas

unread,
Mar 18, 2021, 4:12:53 PM3/18/21
to Trac Users
Hello Ryan,

yes, my connection string looks like this:
database = mysql://tracuser:password@localhost/trac_db

>>"To get that header file, you may typically need to install the "source" version of the package from the package repository."
What do you mean with that? That I might have the wrong "my_config.h" file? Which package do you mean?

RjOllos

unread,
Mar 19, 2021, 3:56:07 PM3/19/21
to Trac Users


On Thursday, March 18, 2021 at 1:12:53 PM UTC-7 Andreas wrote:
Hello Ryan,
>>"To get that header file, you may typically need to install the "source" version of the package from the package repository."
What do you mean with that? That I might have the wrong "my_config.h" file? Which package do you mean?

What you did may work perfectly fine. I haven't used Fedora in years, so I'm extrapolating off what I know about Debian, but typically you'd get the headers by installing a -devel package:

$ yum install mariadb-devel 

If the extension "-devel" isn't correct, there may be something like "yum search" that could be used to find the MariaDB package that includes the header files.

Ryan

Andreas

unread,
Mar 19, 2021, 7:10:36 PM3/19/21
to Trac Users
Thanks for your hints Ryan; unfortunately, this didn't fix the problem...but I finally found a solution!

I copied the file my_config.h from an ubuntu 18.04 installation to my ubuntu 20.04 into /usr/include/mysql and then did pip install MySQL-python again. The migration script is still not working, so I did the migration in Ubuntun 18.04, exported the SQL-file, imported the file into MariaDB / Ubuntu 20.04 and changed the Trac-connection string to mysql. Pretty complicated, but it's working now ;-)

I attach the my_config.h file here if anyone else tries to use Trac 1.2.x with MySQL / MariaDB under Ubuntu 20.04 - the file from stackoverflow doesn't work properly in Ubuntu ;-)
my_config.h
Reply all
Reply to author
Forward
0 new messages