centos搭建python2.7开发环境

本文涉及的产品
Redis 开源版,标准版 2GB
推荐场景:
搭建游戏排行榜
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 MongoDB,独享型 2核8GB
推荐场景:
构建全方位客户视图
简介: centos搭建python2.7开发环境

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())"


相关实践学习
基于Redis实现在线游戏积分排行榜
本场景将介绍如何基于Redis数据库实现在线游戏中的游戏玩家积分排行榜功能。
相关文章
|
12月前
|
Linux 网络安全 Python
linux centos上安装python3.11.x详细完整教程
这篇文章提供了在CentOS系统上安装Python 3.11.x版本的详细步骤,包括下载、解压、安装依赖、编译配置、解决常见错误以及版本验证。
8364 3
linux centos上安装python3.11.x详细完整教程
|
6月前
|
Linux Python
centos 编译安装 python 和 openssl
centos 编译安装 python 和 openssl
303 2
|
8月前
|
人工智能 Java Python
python安装、vscode安装、conda安装:一文搞定Python的开发环境(史上最全)
尼恩架构团队推出了一系列《LLM大模型学习圣经》PDF,旨在帮助读者深入理解并掌握大型语言模型(LLM)及其相关技术。该系列包括Python基础、Transformer架构、LangChain框架、RAG架构及LLM智能体等内容,覆盖从理论到实践的各个方面。此外,尼恩还提供了配套视频教程,计划于2025年5月前发布,助力更多人成为大模型应用架构师,冲击年薪百万目标。
|
11月前
|
Windows Python
【10月更文挑战第2天】「Mac上学Python 2」入门篇2 - 开发环境命令行操作与文件管理
本篇将详细介绍Windows和Mac系统中的常用命令行操作与文件管理,帮助用户掌握如何通过终端或命令提示符进行文件管理和操作开发环境。内容涵盖路径切换、文件与文件夹的创建、删除、查看文件内容等基本操作,这些技能是后续Python开发的基础。
235 6
【10月更文挑战第2天】「Mac上学Python 2」入门篇2 - 开发环境命令行操作与文件管理
|
Linux 开发工具 C语言
centos7编译安装python3
centos7编译安装python3
|
SQL 关系型数据库 API
Python 开发环境的准备以及一些常用类库模块的安装
在学习和开发Python的时候,第一步的工作就是先准备好开发环境,包括相关常用的插件,以及一些辅助工具,这样我们在后续的开发工作中,才能做到事半功倍。下面介绍一些Python 开发环境的准备以及一些常用类库模块的安装和使用的经验总结,供大家参考了解。
|
Python
Mac安装Python3.12开发环境
Mac安装Python3.12开发环境
481 2
|
开发工具 Python Windows
【Python专栏】搭建Pyhthon运行环境及开发环境 | 安装Python | 安装PyCharm
【Python专栏】搭建Pyhthon运行环境及开发环境 | 安装Python | 安装PyCharm
447 4
|
12月前
|
Linux Python
Linux之centos安装clinkhouse以及python如何连接
Linux之centos安装clinkhouse以及python如何连接
|
IDE 数据可视化 安全
Python学习中设置开发环境
【7月更文挑战第26天】
121 2