2

I have a python script that runs well on ubuntu. I have also maintained a requirement file using pip freeze command. But when I try to install the requirements in centOS, I get dependency issues for the packages. These dependencies are external and not relating to python.

For example, I tried installing mysql-python in my ubuntu machine, it was installed successfully. But when I tried installing mysql-python on my centos machine, it failed because mysql-python had a dependency on something else that could not have been listed by pip freeze.

The error I received and its solution is addressed in the link below. But what I want to know is how to handle such dependencies.

mysql_config not found when installing mysqldb python interface

  • 1
    You might want to take a look at Docker. – Nitin Labhishetty Mar 22 '19 at 04:43
  • 1
    Linux uses package management. In CentOS the package manager is `yum`, in Fedora `dnf`, in Debian/Ubuntu `apt`. They can install python packages and their dependencies because packagers listed those dependencies in formats specific to the OS/package manager. Once you use `pip` you are out of standard way and must install everything manually. So you have to choose between OS-specific package managers and `pip`. – phd Mar 22 '19 at 06:02

1 Answers1

1

How I used to do during deployment is, create a shell script. The shell script will install mysql-server first, the do the Python library installation.

Sample shell script can be found below initial_setup.sh:

#!/bin/bash
apt-get install mysql-server
apt-get install libmysqlclient-dev

pip install -r requirements.txt
Jeril
  • 7,858
  • 3
  • 52
  • 69
  • My original concern was is there some way to include mysql-server as a dependency? Because I had installed mysql-server way before and I did not know mysql-python had a dependency on mysql-server. So when I tried to install the same python package on another machine, I started to get ambiguous errors. – Siddhi Kiran Bajracharya Mar 22 '19 at 06:24
  • 1
    that is what the shell script does, you need to use the shell script for installing python packages, and you need to handle all the dependencies issues inside the shell script. This is how many web applications are done. – Jeril Mar 22 '19 at 06:41