Python 虚拟环境
1
2
3
4
5
6
7
8
9
10
11
12
13
14
➜ ~ python -m venv tutorial-env
The virtual environment was not created successfully because ensurepip is not
available. On Debian/Ubuntu systems, you need to install the python3-venv
package using the following command.
apt install python3.8-venv
You may need to use sudo with that command. After installing the python3-venv
package, recreate your virtual environment.
Failing command: ['/home/sense/tutorial-env/bin/python', '-Im', 'ensurepip', '--upgrade', '--default-pip']
➜ ~ sudo apt install python3.8-venv -y
activate & deactivate
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
➜ Desktop cd tutorial-env
➜ tutorial-env head ./bin/activate
# This file must be used with "source bin/activate" *from bash*
# you cannot run it directly
deactivate () {
# reset old environment variables
if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then
PATH="${_OLD_VIRTUAL_PATH:-}"
export PATH
unset _OLD_VIRTUAL_PATH
fi
➜ tutorial-env source ./bin/activate
(tutorial-env) ➜ tutorial-env deactivate
➜ tutorial-env
This post is licensed under CC BY 4.0 by the author.