Files
ailearning/docs/da/005.md
2020-10-19 21:08:55 +08:00

256 lines
11 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 使用 Anaconda
[Anaconda](http://www.continuum.io/downloads)是一个很好用的Python IDE它集成了很多科学计算需要使用的**python**第三方工具包。
## conda 的使用
根据自己的操作系统安装好[Anaconda](http://www.continuum.io/downloads)后,在命令行下输入:
```py
conda list
```
可以看已经安装好的**python**第三方工具包,这里我们使用 `magic` 命令 `%%cmd``ipython cell` 中来执行这个命令:
In [1]:
```py
!conda list
```
```py
# packages in environment at C:\Anaconda:
#
_license 1.1 py27_0
alabaster 0.7.3 py27_0
anaconda 2.3.0 np19py27_0
argcomplete 0.8.9 py27_0
astropy 1.0.3 np19py27_0
babel 1.3 py27_0
backports.ssl-match-hostname 3.4.0.2 <pip>
basemap 1.0.7 np19py27_0
bcolz 0.9.0 np19py27_0
beautiful-soup 4.3.2 py27_1
beautifulsoup4 4.3.2 <pip>
binstar 0.11.0 py27_0
bitarray 0.8.1 py27_1
blaze 0.8.0 <pip>
blaze-core 0.8.0 np19py27_0
blz 0.6.2 np19py27_1
bokeh 0.9.0 np19py27_0
boto 2.38.0 py27_0
bottleneck 1.0.0 np19py27_0
cartopy 0.13.0 np19py27_0
cdecimal 2.3 py27_1
certifi 14.05.14 py27_0
cffi 1.1.0 py27_0
clyent 0.3.4 py27_0
colorama 0.3.3 py27_0
conda 3.17.0 py27_0
conda-build 1.14.1 py27_0
conda-env 2.4.2 py27_0
configobj 5.0.6 py27_0
cryptography 0.9.1 py27_0
cython 0.22.1 py27_0
cytoolz 0.7.3 py27_0
datashape 0.4.5 np19py27_0
decorator 3.4.2 py27_0
docutils 0.12 py27_1
dynd-python 0.6.5 np19py27_0
enum34 1.0.4 py27_0
fastcache 1.0.2 py27_0
flask 0.10.1 py27_1
funcsigs 0.4 py27_0
geopy 1.11.0 <pip>
geos 3.4.2 3
gevent 1.0.1 py27_0
gevent-websocket 0.9.3 py27_0
greenlet 0.4.7 py27_0
grin 1.2.1 py27_2
h5py 2.5.0 np19py27_1
hdf5 1.8.15.1 2
idna 2.0 py27_0
ipaddress 1.0.7 py27_0
ipython 3.2.0 py27_0
ipython-notebook 3.2.0 py27_0
ipython-qtconsole 3.2.0 py27_0
itsdangerous 0.24 py27_0
jdcal 1.0 py27_0
jedi 0.8.1 py27_0
jinja2 2.7.3 py27_2
jsonschema 2.4.0 py27_0
launcher 1.0.0 1
libpython 1.0 py27_1
llvmlite 0.5.0 py27_0
lxml 3.4.4 py27_0
markupsafe 0.23 py27_0
matplotlib 1.4.3 np19py27_1
menuinst 1.0.4 py27_0
mingw 4.7 1
mistune 0.5.1 py27_1
mock 1.3.0 py27_0
multipledispatch 0.4.7 py27_0
networkx 1.9.1 py27_0
nltk 3.0.3 np19py27_0
node-webkit 0.10.1 0
nose 1.3.7 py27_0
numba 0.19.1 np19py27_0
numexpr 2.4.3 np19py27_0
numpy 1.9.2 py27_0
odo 0.3.2 np19py27_0
openpyxl 1.8.5 py27_0
owslib 0.9.0 py27_0
pandas 0.16.2 np19py27_0
patsy 0.3.0 np19py27_0
pbr 1.3.0 py27_0
pep8 1.6.2 py27_0
pillow 2.9.0 py27_0
pip 7.1.2 py27_0
ply 3.6 py27_0
proj4 4.9.1 py27_1
psutil 2.2.1 py27_0
py 1.4.27 py27_0
pyasn1 0.1.7 py27_0
pycosat 0.6.1 py27_0
pycparser 2.14 py27_0
pycrypto 2.6.1 py27_3
pyepsg 0.2.0 py27_0
pyflakes 0.9.2 py27_0
pygments 2.0.2 py27_0
pyopenssl 0.15.1 py27_1
pyparsing 2.0.3 py27_0
pyqt 4.10.4 py27_1
pyreadline 2.0 py27_0
pyshp 1.2.1 py27_0
pytables 3.2.0 np19py27_0
pytest 2.7.1 py27_0
python 2.7.10 0
python-dateutil 2.4.2 py27_0
pytz 2015.4 py27_0
pywin32 219 py27_0
pyyaml 3.11 py27_2
pyzmq 14.7.0 py27_0
requests 2.7.0 py27_0
rope 0.9.4 py27_1
runipy 0.1.3 py27_0
scikit-image 0.11.3 np19py27_0
scikit-learn 0.16.1 np19py27_0
scipy 0.16.0 np19py27_0
setuptools 18.1 py27_0
shapely 1.5.11 nppy27_0
six 1.9.0 py27_0
snowballstemmer 1.2.0 py27_0
sockjs-tornado 1.0.1 py27_0
sphinx 1.3.1 py27_0
sphinx-rtd-theme 0.1.7 <pip>
sphinx_rtd_theme 0.1.7 py27_0
spyder 2.3.5.2 py27_0
spyder-app 2.3.5.2 py27_0
sqlalchemy 1.0.5 py27_0
ssl_match_hostname 3.4.0.2 py27_0
statsmodels 0.6.1 np19py27_0
sympy 0.7.6 py27_0
tables 3.2.0 <pip>
theano 0.7.0 <pip>
toolz 0.7.2 py27_0
tornado 4.2 py27_0
ujson 1.33 py27_0
unicodecsv 0.9.4 py27_0
werkzeug 0.10.4 py27_0
wheel 0.24.0 py27_0
xlrd 0.9.3 py27_0
xlsxwriter 0.7.3 py27_0
xlwings 0.3.5 py27_0
xlwt 1.0.0 py27_0
zlib 1.2.8 0
```
第一次安装好 [Anaconda](http://www.continuum.io/downloads) 以后,可以在命令行输入以下命令使 [Anaconda](http://www.continuum.io/downloads) 保持最新:
```py
conda update conda
conda update anaconda
```
conda 是一种很强大的工具,具体用法可以参照它的[文档](http://conda.pydata.org/docs/)。
也可以参考它的 [cheat sheet](http://conda.pydata.org/docs/_downloads/conda-cheatsheet.pdf) 来快速查看它的用法。
可以使用它来安装,更新,卸载第三方的 **python** 工具包:
```py
conda install <some package>
conda update <some package>
conda remove <some package>
```
在安装或更新时可以指定安装的版本号,例如需要使用 `numpy 1.8.1`
```py
conda install numpy=1.8.1
conda update numpy=1.8.1
```
查看 `conda` 的信息:
```py
conda info
```
In [2]:
```py
!conda info
```
```py
Current conda install:
platform : win-64
conda version : 3.17.0
conda-build version : 1.14.1
python version : 2.7.10.final.0
requests version : 2.7.0
root environment : C:\Anaconda (writable)
default environment : C:\Anaconda
envs directories : C:\Anaconda\envs
package cache : C:\Anaconda\pkgs
channel URLs : https://repo.continuum.io/pkgs/free/win-64/
https://repo.continuum.io/pkgs/free/noarch/
https://repo.continuum.io/pkgs/pro/win-64/
https://repo.continuum.io/pkgs/pro/noarch/
config file : None
is foreign system : False
```
一个很棒的功能是 `conda` 可以产生一个自定义的环境,假设在安装的是 **Python 2.7** 的情况下,想使用 **Python 3.4**,只需要在命令行下使用 `conda` 产生一个新的环境:
```py
conda create -n py34 python=3.4
```
这里这个环境被命名为 `py34` ,可以根据喜好将 `py34` 改成其他的名字。
使用这个环境时,只需要命令行下输入:
```py
activate py34 #(windows)
source activate py34 #(linux, mac)
```
此时,我们的 **Python** 版本便是 **`python 3.4`**了。
## spyder 编辑器
`Anaconda` 默认使用的编辑器是 `spyder`,可以在命令行下输入:
```py
spyder
```
来进入这个编辑器,具体使用方法不做介绍。