centos搭建python2.7开发环境

这篇博客详细介绍了在CentOS7系统中如何升级pip,安装MySQL8.0和Python的MySQL驱动,以及解决安装过程中的各种错误。此外,还涵盖了安装Redis、设置开机启动和连接PyCharm远程服务器的步骤。最后,讲解了安装MongoDB 4.0的完整流程,包括添加源、安装、配置和启动服务。

pip升级

#centos7 默认python版本2.7.5

yum -y install python-pip

#默认安装的pip版本为

以上方法会报错

#下载get-pip.py

wget https://bootstrap.pypa.io/pip/2.7/get-pip.py

python get-pip.py

以上方法可以把pip8升级到pip20

安装mysql

下载MySQL仓库并安装

wget https://repo.mysql.com//mysql80-community-release-el7-3.noarch.rpm

yum -y install mysql80-community-release-el7-3.noarch.rpm

 

 3.默认安装MySQL8.0,如果需要安装MySQL5.7的话需要修改/etc/yum.repos.d/mysql-community.repo配置文件

将mysql80中enabled属性改为0,并添加图中红框内代码(安装MySQL8.0跳过该步骤)

 4.安装MySQL数据库

yum -y install mysql-community-server

 5.开启mysql服务

systemctl start mysqld.service

6.查看mysql默认密码并登陆

cat /var/log/mysqld.log | grep password

mysql -uroot -p

安装python-mysql会出错

在执行pip install MySQL-python
时报错如:

ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

解决方法

缺少mysql-develyum install -y mysql-devel
如果不行请执行以下安装更多yum install -y python-devel mysql-devel redhat-rpm-config gcc

亲测有效

可能会出现这个错误

ERROR: Cannot uninstall 'PyYAML'. It is a distutils installed project and thus we cannot accurately 

换阿里源就可以解决问题了

pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/ --ignore-installed

安装mysql-linux时候的错误

linux-Mysql安装出错-The GPG keys listed for the “MySQL 5.7 Community Server“ repository are already...

Failing package is: mysql-community-server-5.7.37-1.el7.x86_64 GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

解决方式:
以2022年为例

rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022

yum安装redis

sudo yum install epel-release yum-utils

sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm

sudo yum-config-manager --enable remi

sudo  yum  install  redis
设置开机启动
sudo  systemctl  enable  redis
启动
sudo  systemctl start redis

设置pycharm连接远程服务器

PyCharm远程连接服务器简明教程 - 知乎 (zhihu.com) 

安装mongodb,我们安装的是mongodb-org4.0版本

一步步执行下列命令即可:

1.添加源

cat << EOF | sudo tee -a /etc/yum.repos.d/mongodb-org-4.0.repo
[mongodb-org-4.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/7/mongodb-org/4.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc
EOF

2.安装

yum install -y mongodb-org 

3.更改参数(可选,启用集群部署)

sed -i "s/^#  engine:/  engine: mmapv1/"  /etc/mongod.conf
sed -i "s/^#replication:/replication:\n  replSetName: rs01/" /etc/mongod.conf

4.启动服务并设置为开机自启

systemctl enable mongod && systemctl start mongod

* 如果使用了第3步,则需执行以下命令:

mongo --eval "printjson(rs.initiate())"
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

技术蜜糖罐

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值