Centos7安装Python虚拟环境之virtualenv

一、安装自己需要的python版本

1
步骤略

二、安装virtualenv模块并创建虚拟环境

1
2
3
4
5
6
7
8
9
10
11
12
13
[root@localhost ~]# /usr/local/python3.6.8/bin/pip3 install virtualenv
[root@localhost ~]# /usr/local/python3.6.8/bin/virtualenv --version
[root@localhost ~]# mkdir py_virtual
[root@localhost ~]# cd py_virtual
[root@localhost py_virtual]# /usr/local/python3.6.8/bin/virtualenv test
[root@localhost py_virtual]# ll
总用量 0
drwxr-xr-x. 4 root root 64 9月  26 09:55 test
[root@localhost py_virtual]# cd test1/
[root@localhost py_virtual]# source bin/activate  #激活虚拟环境
(test) [root@localhost py_virtual]# python -V
Python 3.6.8
(test) [root@localhost ~]# deactivate  #退出虚拟环境 

三、指定其他python版本创建

1
2
3
4
5
6
7
8
9
[root@localhost py_virtual]# /usr/local/python3.6.8/bin/virtualenv --python /usr/local/python3.5.7/bin/python3 test1
[root@localhost py_virtual]# ll
总用量 0
drwxr-xr-x. 4 root root 64 9月  26 09:55 test
drwxr-xr-x. 4 root root 64 9月  26 10:09 test1
[root@localhost py_virtual]# cd test1/
[root@localhost test1]# source bin/activate
(test1) [root@localhost test1]# python -V
Python 3.5.7

  

  

posted @   百衲本  阅读(387)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· winform 绘制太阳,地球,月球 运作规律
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· AI 智能体引爆开源社区「GitHub 热点速览」
· Manus的开源复刻OpenManus初探
· 写一个简单的SQL生成工具
cnblogs_post_body { color: black; font: 0.875em/1.5em "微软雅黑" , "PTSans" , "Arial" ,sans-serif; font-size: 15px; } cnblogs_post_body h1 { text-align:center; background: #333366; border-radius: 6px 6px 6px 6px; box-shadow: 0 0 0 1px #5F5A4B, 1px 1px 6px 1px rgba(10, 10, 0, 0.5); color: #FFFFFF; font-family: "微软雅黑" , "宋体" , "黑体" ,Arial; font-size: 23px; font-weight: bold; height: 25px; line-height: 25px; margin: 18px 0 !important; padding: 8px 0 5px 5px; text-shadow: 2px 2px 3px #222222; } cnblogs_post_body h2 { text-align:center; background: #006699; border-radius: 6px 6px 6px 6px; box-shadow: 0 0 0 1px #5F5A4B, 1px 1px 6px 1px rgba(10, 10, 0, 0.5); color: #FFFFFF; font-family: "微软雅黑" , "宋体" , "黑体" ,Arial; font-size: 20px; font-weight: bold; height: 25px; line-height: 25px; margin: 18px 0 !important; padding: 8px 0 5px 5px; text-shadow: 2px 2px 3px #222222; } cnblogs_post_body h3 { background: #2B6695; border-radius: 6px 6px 6px 6px; box-shadow: 0 0 0 1px #5F5A4B, 1px 1px 6px 1px rgba(10, 10, 0, 0.5); color: #FFFFFF; font-family: "微软雅黑" , "宋体" , "黑体" ,Arial; font-size: 18px; font-weight: bold; height: 25px; line-height: 25px; margin: 18px 0 !important; padding: 8px 0 5px 5px; text-shadow: 2px 2px 3px #222222; } 回到顶部 博客侧边栏 回到顶部 页首代码 回到顶部 页脚代码
点击右上角即可分享
微信分享提示