avatar

刘刚刚的blog

采菊东篱下,悠然见南山🦥

  • 首页
  • python
  • 大模型应用
  • 软件/工具导航页
  • 关于
Home python-虚拟环境的搭建及使用
文章

python-虚拟环境的搭建及使用

Posted 2020-09-17 Updated 2024-12- 10
By Administrator
3~4 min read

当在一台主机上需要运行多个版本的python环境或者不同版本的包时,可以使用**虚拟环境**进行不同python软件间的环境隔离。


安装环境:windows

1. 安装依赖

pip3 install virtualenv
pip3 install virtualenvwrapper-win

2.配置虚拟环境工作目录

  1. 在系统中添加虚拟环境的环境变量。例:WORKON_HOME D:Virtualenvs

  2. 进入Python3的安装目录 => Scripts文件夹 => virtualenvwrapper.bat => 双击

3.创建虚拟环境

在命令行中执行创建命令,如果使用的是cmd此时系统会多次弹出多个cmd窗口,等待即可。在创建成功后,会自动进入虚拟环境。

# 创建一个名为test的python3.8虚拟环境
mkvirtualenv -p python3.8  test

4.进入虚拟环境

# 进入名为test的虚拟环境
workon test

5. 退出虚拟环境

deactivate

虚拟环境其他常用命令

# 查看存在的虚拟环境
workon

# 删除虚拟环境
rmvirtualenv  虚拟环境名称

python
python
License:  CC BY 4.0
Share

Further Reading

Jun 18, 2025

python包管理神器:UV

目前 UV 因其优势,已被大量的python开源项目使用。简单整理了一些命令,不到 UV 功能的 1/5,更多功能慢慢探索。 安装 # mac brew install uv ​ # win powershell -c "irm https://astral.sh/uv/install.ps1 |

May 27, 2025

python中一些很好用的工具类模块

contextlib 此模块为 with 语句提供了一些工具,简化了 with的使用。 @contextlib.contextmanager 它将一个生成器函数转换为一个上下文管理器。而无需创建一个类或单独的 __enter__() 和 __e

Apr 21, 2025

Typing

类型注释让python 有了更好的编辑器提示功能。 基础使用 对函数参数和返回值,进行类型注释 def surface_area_of_cube(edge_length: float) -> str:    return f"The surface area of the cube is {6 *

OLDER

mysql存储引擎

NEWER

xss与csrf

Recently Updated

  • 使用 claude api遇到的问题
  • 一些开发中使用的 linux运维命令
  • python包管理神器:UV
  • ollama-大模型的部署与使用
  • 为jupyter增加可选的python内核

Trending Tags

Halo 运维 postgresql 设计模式 linux就该这么学 nas rag odoo python 文本切分

Contents

©2025 刘刚刚的blog. Some rights reserved.

Using the Halo theme Chirpy