安装python + redis + pip

1.安装python3.6

yum -y install python3.6

2.查看python安装目录下面bin目录中是否已经含有pip

whereis python
python: /usr/bin/python /usr/bin/python2.7 /usr/bin/python3.6m /usr/bin/python3.6 /usr/lib/python2.7 /usr/lib/python3.6 /usr/lib64/python2.7 /usr/lib64/python3.6 /etc/python /usr/include/python2.7 /usr/include/python3.6m /usr/share/man/man1/python.1.gz

  装的是3.6版本,安装目录自带pip3,并且可以全局使用

[root@localhost python3.6]# whereis pip3
pip3: /usr/bin/pip3.6 /usr/bin/pip3
[root@localhost python3.6]# 

3.安装redis扩展包

pip3 install redis

4.python连接redis

[root@localhost ~]# python3
Python 3.6.8 (default, Apr  2 2020, 13:34:55) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import redis
>>> conn = redis.Redis(host="127.0.0.1", port=6379, password="")
>>> conn.set('name', 'itxds')
True
>>> conn.get('name')
b'itxds'
>>> 

  

原文地址:https://www.cnblogs.com/xiangdongsheng/p/13443579.html