pip 安装python 虚拟环境

Open a terminal and type the following commands (after the  $ prompts):
$ export ML_PATH="$HOME/ml" # You can change the path if you prefer
$ mkdir -p $ML_PATH

$ pip3 --version
pip 9.0.1 from [...]/lib/python3.5/site-packages (python 3.5)

$ pip3 install --upgrade pip
Collecting pip
[...]
Successfully installed pip-9.0.1

If you would like to work in an isolated environment (which is strongly recom‐mended so you can work on different projects without having conflicting library ver‐sions), install virtualenv by running the following pip command:
$ pip3 install --user --upgrade virtualenv
Collecting virtualenv
[...]
Successfully installed virtualenv
Now you can create an isolated Python environment by typing:
$ cd $ML_PATH
$ virtualenv env
Using base prefix '[...]'
New python executable in [...]/ml/env/bin/python3.5
Also creating executable in [...]/ml/env/bin/python
Installing setuptools, pip, wheel...done.
Now every time you want to activate this environment, just open a terminal and type:
$ cd $ML_PATH
$ source env/bin/activate
While the environment is active, any package you install using pip will be installed in this isolated environment and Python will only have access to these packages (if you also want access to the system’s site packages, you should create the environment using virtualenv’s  --system-site-packages option). Check out virtualenv’s documentation for more information.

Now you can install all the required modules and their dependencies using this sim‐ple pip command:
$ pip3 install --upgrade jupyter matplotlib numpy pandas scipy scikit-learn
Collecting jupyter
Downloading jupyter-1.0.0-py2.py3-none-any.whl
Collecting matplotlib
[...]
To check your installation, try to import every module like this:
$ python3 -c "import jupyter, matplotlib, numpy, pandas, scipy, sklearn"
There should be no output and no error. Now you can fire up Jupyter by typing:
$ jupyter notebook
[I 15:24 NotebookApp] Serving notebooks from local directory: [...]/ml
[I 15:24 NotebookApp] 0 active kernels
[I 15:24 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/
[I 15:24 NotebookApp] Use Control-C to stop this server and shut down all
kernels (twice to skip confirmation).

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值