How to Quickly Set Up a Python Development Environment on CentOS
This step‑by‑step guide shows how to create a user, enable passwordless sudo, add EPEL and IUS repositories, install Python 2.7, Python 3, pip, virtualenv, generate SSH keys, and set up common services like Git, MySQL, Redis, and RabbitMQ on a clean CentOS system, with troubleshooting tips for common errors.
After obtaining a clean CentOS system, this guide records the commands and issues for initializing a Python environment; it can be scripted or containerized with Docker.
1. Create a New User
sudo adduser newuser
sudo passwd newuserConfigure Passwordless Sudo
sudo /usr/sbin/visudo
newuser ALL=NOPASSWD: ALL2. Enable EPEL Repository
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
sudo rpm -Uvh epel-release-6*.rpm3. Add IUS Repository
wget http://dl.iuscommunity.org/pub/ius/stable/CentOS/6/x86_64/ius-release-1.0-13.ius.centos6.noarch.rpm
sudo rpm -Uvh ius-release-1.0-13.ius.centos6.noarch.rpm4. Install Python 2.7, Python 3, and pip
sudo yum install python27
sudo yum install python27-devel
curl https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py | sudo /usr/bin/python2.7 -pip
curl https://raw.githubusercontent.com/pypa/pip/master/contrib/get-pip.py | sudo /usr/bin/python2.7 -
sudo yum install python34u python34u-devel5. Install virtualenv
sudo pip install virtualenv6. Generate SSH Key
ssh-keygen -t rsa
# Add ~/.ssh/id_rsa.pub to Git or GitHubAdditional Services
Install Git
sudo yum install gitInstall MySQL
sudo yum install mysql
sudo yum install mysql-devel* -y
sudo yum install mysql-server
sudo /sbin/service mysqld startInstall Redis
sudo yum install redisInstall RabbitMQ
sudo yum install rabbitmq-serverTroubleshooting
When encountering [Errno 14] Peer cert cannot be verified or peer cert invalid, add sslverify=false to /etc/yum.conf. For pip errors like ImportError: cannot import name HTTPSHandler, install OpenSSL development packages: yum install openssl openssl-devel -y MySQL‑python compilation may fail with gcc errors; ensure the MySQL development headers are installed:
yum install mysql-develSigned-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
