CentOS安装软件报错解决方法

修改CentOS默认yum源为mirrors.aliyun.com

1.首先备份系统自带yum源配置文件/etc/yum.repos.d/CentOS-Base.repo

[root@localhost ~]$ mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

2.下载ailiyun的yum源配置文件到/etc/yum.repos.d/

centOS7

[root@localhost ~]$ wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

CentOS6

[root@localhost ~]$ wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo

CentOS5

[root@localhost ~]$ wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
 

3.运行yum makecache生成缓存

[root@localhost ~]$ yum makecache

4.更新系统就会看到以下mirrors.aliyun.com信息

[root@localhost ~] yum -y update
已加载插件:fastestmirror, refresh-packagekit, security
设置更新进程Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
centos7下使用yum安装pip
  1. 首先安装epel扩展源:yum -y install epel-release

  2. 更新完成之后安装pip:yum -y install python-pip

  3. 安装完成之后清除cache:yum clean all

这是在root用户时使用的命令,当前用户如果不具有root权限,加上sudo,或者su切换为root。

安装MySQL-python==1.2.5报错解决方法
(sky_server_env) [root@localhost Desktop]# pip install MySQL-python==1.2.5 
Collecting MySQL-python
  Downloading https://files.pythonhosted.org/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip (108kB)
    100% |████████████████████████████████| 112kB 133kB/s 
    Complete output from command python setup.py egg_info:
    sh: mysql_config: command not found
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-MrnGf7/MySQL-python/setup.py", line 17, in <module>
        metadata, options = get_config()
      File "setup_posix.py", line 43, in get_config
        libs = mysql_config("libs_r")
      File "setup_posix.py", line 25, in mysql_config
        raise EnvironmentError("%s not found" % (mysql_config.path,))
    EnvironmentError: mysql_config not found

上面的错误是由于缺少mysql_config文件导致,查看下mysql_config文件是否存在

(sky_server_env) [root@localhost Desktop]# find / -name mysql_config
find: ‘/proc/5155’: No such file or directory
find: ‘/run/user/1000/gvfs’: Permission denied

mysql_config没有找到,是因为缺少mysql-devel,导致mysql_config丢失,安装mysql-devel即可

yum install mysql-devel

安装mysql-devel报错解决方法:

# 查看MYSQL源,如下没有源,导致安装出错
[root@localhost  Desktop]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ls
CentOS-Base.repo  CentOS-CR.repo  CentOS-Debuginfo.repo  CentOS-fasttrack.repo  CentOS-Media.repo  CentOS-Sources.repo  CentOS-Vault.repo  mongodb-org-3.2.repo
具体解决方案:

1.需要安装MySQL的源

wget http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm

rpm -ivh mysql57-community-release-el7-8.noarch.rpm # 安装

2.查看/etc/yum.repos.d/目录下会出现MySQL的相关repo

[root@localhost tmp]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ls
CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo    CentOS-Vault.repo     mysql-community.repo
CentOS-CR.repo    CentOS-fasttrack.repo  CentOS-Sources.repo mysql-community-source.repo

3.现在有MySQL的源,可以安装mysql-devel了

[root@localhost yum.repos.d]# yum install mysql-devel
Loaded plugins: fastestmirror, langpacks
mysql-connectors-community                                                                                                                          | 2.5 kB  00:00:00 
......
Installed:
  mysql-community-devel.x86_64 0:5.7.22-1.el7            mysql-community-libs.x86_64 0:5.7.22-1.el7     
  mysql-community-libs-compat.x86_64 0:5.7.22-1.el7     

Dependency Installed:
  mysql-community-common.x86_64 0:5.7.22-1.el7                                                          

Replaced:
  mariadb-libs.x86_64 1:5.5.56-2.el7                                                                    

Complete!

  1. 安装MySQL-python==1.2.5
pip install MySQL-python==1.2.5 
安装psutil 报错
pip install psutil


.......
psutil/_psutil_common.c:9:20: fatal error: Python.h: No such file or directory
     #include <Python.h>
                        ^
    compilation terminated.
    error: command 'gcc' failed with exit status 1
    
    ----------------------------------------
Command "/usr/bin/python2 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-7cazf_/psutil/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-VA3Ckj-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-7cazf_/psutil/

解决方法:

1:执行yum clean all 清除缓存目录下的软件包及旧的headers;
2:接着执行 yum list 重新列出所有已经安装和可以安装的软件包;
3:重新执行上述命令pip install psutil,发现yum编译成功;

Shylin

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值