无法安装 MySQL-python 软件包

Cannot install MySQL-python package

我刚刚在托管公司创建了 CentOS 7。

我需要安装依赖于 MySQL-python 软件包的应用程序。

我尝试安装该软件包,但它不可用:

root@vps [/var/frappe]# yum install MySQL-python
Loaded plugins: fastestmirror, universal-hooks
Loading mirror speeds from cached hostfile
 * EA4: 208.100.0.204
 * base: ftpmirror.your.org
 * epel: mirror.steadfastnet.com
 * extras: ftpmirror.your.org
 * ius: muug.ca
 * updates: ftpmirror.your.org
No package MySQL-python available.
Error: Nothing to do
root@vps [/var/frappe]#

为什么我安装不了?一些解决方法?

编辑:

/etc/yum.conf

[main]
exclude=courier* dovecot* exim* filesystem httpd* mod_ssl* mydns* mysql* nsd* p0f php* proftpd* pure-ftpd* spamassassin* squirrelmail*
tolerant=1
errorlevel=1
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=5
bugtracker_url=http://bugs.centos.org/set_project.php?project_id=23&ref=http://bugs.centos.org/bug_report_page.php?category=yum
distroverpkg=centos-release


#  This is the default, if you make this bigger yum won't see if the metadata
# is newer on the remote and so you'll "gain" the bandwidth of not having to
# download the new metadata and "pay" for it by yum not having correct
# information.
#  It is esp. important, to have correct metadata, for distributions like
# Fedora which don't keep old packages around. If you don't like this checking
# interupting your command line usage, it's much better to have something
# manually check the metadata once an hour (yum-updatesd will do this).
# metadata_expire=90m

# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d

此包将在 base 存储库中可用:

$ yum whatprovides MySQL-python
MySQL-python-1.2.5-1.el7.x86_64 : An interface to MySQL
Repo        : base

供参考:

$ cat /etc/yum.repos.d/centos.repo 
[base]
name=CentOS-$releasever - Base
baseurl=http://mirror.centos.org/centos/7/os/$basearch/
gpgcheck=1
enabled=1
protect=1
priority=5
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

在提供的 yum.conf 中看起来非常可疑的是配置 exclude=mysql* 与所需的包名称完全匹配。您要么必须删除那个 exclude 模式才能安装。或使用 pip install MySQL-python.

安装软件包 MySQL-python

MySQL-pythonRPM 依赖项确认不需要额外的 MySQL 软件包:

$ repoquery --requires --resolve MySQL-python
python-0:2.7.5-76.el7.x86_64
python-libs-0:2.7.5-76.el7.x86_64
MariaDB-compat-0:10.2.22-1.el7.centos.x86_64
glibc-0:2.17-260.el7.i686
mariadb-libs-1:5.5.60-1.el7_5.x86_64
zlib-0:1.2.7-18.el7.x86_64
glibc-0:2.17-260.el7.x86_64
openssl-libs-1:1.0.2k-16.el7.x86_64

documentation 也解释了我想表达的意思:

exclude List of packages to exclude from all repositories, so yum works as if that package was never in the repositories. This should be a space separated list. This is commonly used so a package isn't upgraded or installed accidentally, but can be used to remove packages in any way that yum list will show packages. Shell globs using wildcards (eg. * and ?) are allowed.

最佳解决方案是:编辑 /etc/yum.conf,然后用类似的东西 mysql-server* mysql-client* mysql-libs* 替换 exclude 模式 mysql* - 这样 MySQL 服务器, client 和 libs 仍然会被排除在外,但是包 MySQL-python 的安装将被允许。


甚至有一个非常简单的方法解决这个问题(请注意,这将不会在以后找到更新):

sudo yum install MySQL-python --disableexcludes=all

您最好使用 pip 作为 Python 的包管理器,而不是 yumCreate a Python virtual environment,激活它,然后使用pip安装MySQL-python

python -m venv ~/mysqlstuff
source ~/mysqlstuff/bin/activate
pip install MySQL-python

首先更新您的包管理器:

sudo yum update

然后安装 pip 包:

sudo yum install epel-release
sudo yum install python-pip

然后更新 pip 为:

pip install --upgrade pip

最后安装 MYSQL-python 软件包:

pip install --user MySQL-python # user only

sudo pip install MySQL-python # system wide