Skip to Content
Python 技術手冊 第三版
book

Python 技術手冊 第三版

by lex Martelli, Anna Martelli Ravenscroft, Steve Holden
January 2018
Intermediate to advanced
856 pages
17h 17m
Chinese
GoTop Information, Inc.
Content preview from Python 技術手冊 第三版
224
|
6 章 模組
變更在那個 subshell 終止時就會遺失。對於 bash 與類似的 shells,你會以
下列命令來啟用位於路徑
envpath
的一個環境:
source envpath/bin/activate
其他 shells 的使用者則改用位於相同目錄的
activate.csh
activate.fsh
指令
稿。在 Windows 系統上,使用
activate.bat
envpath/Scripts/activate.bat
啟用過程會做幾件事,最重要的有:
virtualenv
bin
目錄放到 shell
PATH
環境變數的開頭,所以它的
命令才會在
PATH
中已經存在的同名命令之前優先被執行
定義一個
deactivate
命令來移除啟用動作所產生的所有效應,並將
Python 環境回復到它之前的狀態
修改 shell 的命令提示(prompt), virtualenv 的名稱納入到其開頭
定義一個
VIRTUAL_ENV
環境變數作為 virtualenv 根目錄的路徑(指令稿
可用它來檢視 virtualenv
這些動作的後果是,只要一個 virtualenv 被啟用,
python
命令就會執行與
那個 virtualenv 關聯的直譯器。該直譯器看得到安裝在那個環境中的程式
庫(模組與套件),而
pip
現在就會是來自 virtualenv 的那個,因為安裝該
模組也會將那個命令安裝在 virtualenv
bin
目錄中,所以現在
pip
命令預
設會在該環境的 ...
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 进行数据分析(原书第2版)

利用 Python 进行数据分析(原书第2版)

Wes McKinney

Publisher Resources

ISBN: 9789864766819