Skip to Content
Flask Web开发:基于Python的Web应用开发实战(第2版)
book

Flask Web开发:基于Python的Web应用开发实战(第2版)

by Miguel Grinberg
August 2018
Intermediate to advanced
230 pages
6h 42m
Chinese
O'Reilly Media, Inc. Beijing
Content preview from Flask Web开发:基于Python的Web应用开发实战(第2版)
安装
5
如果你使用的是
Ubuntu Linux
系统预装的
Python 3
,那么标准库中没有
venv
包。请执行下述命令安装
python3-venv
包:
$
sudo apt-get install python3-venv
创建虚拟环境的命令格式如下:
$
python3 -m venv virtual-environment-name
-m venv
选项的作用是以独立的脚本运行标准库中的
venv 包,后面的参数为虚拟环境的
名称。
下面我们在
flasky
目录中创建一个虚拟环境。通常,虚拟环境的名称为
venv
,不过你也可
以使用其他名称。确保当前目录是
flasky
,然后执行这个命令:
$
python3 -m venv venv
这个命令执行完毕后,
flasky
目录中会出现一个名为
venv
的子目录,这里就是一个全新的
虚拟环境,包含这个项目专用的
Python
解释器。
1.4
 在
Python 2
中创建虚拟环境
Python 2
没有集成 venv 包。这一版
Python
解释器要使用第三方工具 virtualenv 创建虚
拟环境。
确保当前目录是
flasky
,然后根据自己使用的操作系统,执行下面两个命令中的一个。如
果使用的是
Linux
macOS
,执行的命令是:
$
sudo pip install virtualenv
如果使用的是微软
Windows
系统,打开命令提示符时要选择“以管理员身份运行”,然后
执行这个命令:
$
pip install virtualenv
virtualenv 命令的参数是虚拟环境的名称。确保当前目录是 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Python机器学习基础教程

Python机器学习基础教程

Andreas C. Müller, Sarah Guido
Python编程入门与实战

Python编程入门与实战

Posts & Telecom Press, Fabrizio Romano
程序设计导论:Python语言实践

程序设计导论:Python语言实践

罗伯特 塞奇威克, 凯文 韦恩, 罗伯特 唐德罗

Publisher Resources

ISBN: 9787115489456