Skip to content

Instantly share code, notes, and snippets.

@JeOam
Last active June 6, 2018 03:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save JeOam/121529345d2be64584ee to your computer and use it in GitHub Desktop.
Save JeOam/121529345d2be64584ee to your computer and use it in GitHub Desktop.
Python 环境配置

Python 环境配置: 安装 pip: A tool for installing and managing Python packages.

To install or upgrade pip, securely download get-pip.py. Then run the following (which may require administrator access):

$ sudo python get-pip.py
#Upgrade pip
$ pip install -U pip 

注:也可以 brew install python 来安装 pip

安装 VirtualEnvWrapper:

Install virtualenv
$ sudo pip install virtualenv 
$ sudo pip install virtualenvwrapper
$ subl ~/.zshrc

添加:source /usr/local/bin/virtualenvwrapper.sh

创建新的虚拟环境:$ mkvirtualenv venv,环境存放的目录是~/.virtualenv/venv; $ workon #列出当前环境 $ workon venv #切换环境 $ deactivate #退出环境

Ref: Install Python 2.7 (homebrew + pip + virtualenv) on Mac OS X Lion


Sublime Text 3 Setting

@JeOam
Copy link
Author

JeOam commented Oct 22, 2015

创建虚拟环境时,指定 Python 版本

cd ~/.virtualenvs
virtualenv [name] --python=python3.5
#or
python3.6 -m venv [name]

然后就可以 workon name 进入创建的虚拟环境了。

@JeOam
Copy link
Author

JeOam commented Nov 5, 2015

安装时,指定 pip 源:

pip install Scrapy -i http://pypi.mirrors.ustc.edu.cn/simple # 中国科学技术大学

@JeOam
Copy link
Author

JeOam commented Feb 29, 2016

一些安装完 Python 后,可选的软件包:

  • python-dev 在编译 C 模块时,所需的 Python 头文件
  • python-profiler 它包含了一些完全针对 GPL 协议的 Linux 发行版(诸如 Debian 或 Ubuntu)的非 GPL 协议模块(Hotshot 优化器)
  • gcc 在编译包含 C 代码扩展时所需的软件包

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment