[DL]python使用相关工具说明

说明:当前基本以windows版本下的使用介绍,from udacity

1.Dos conmand

熟悉基本指令:Windows-command-line-basics
目录切换: cd \ ; F: ; cd … ; dir (相当于ls) path

2.python包管理工具 anaconda

2.1安装Anaconda
conda list
conda upgrade --all 
conda install package-name (such as numpy)
conda install pkg1 pkg2 pkg=1.0
conda自动安装相应的依赖 (suchas, scipy依赖numpy)
conda remove pkg-name
conda list
conda search pkg
2.2管理环境
  • pip源更新

    pip 后加参数 -i https://pypi.tuna.tsinghua.edu.cn/simple
    例:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple xxxx
    
    Linux下:修改 ~/.pip/pip.conf (没有就创建一个), 修改 index-url至tuna,内容如下:
    [global]
    index-url = https://pypi.tuna.tsinghua.edu.cn/simple
    
    windows下:直接在user目录中创建一个pip目录,如:C:\Users\xxxx\pip,新建文件pip.ini 
    [global]
    index-url = https://pypi.tuna.tsinghua.edu.cn/simple
    
    
  • conda 换源:

    #conda 换源: 相当于修改~/.condarc文件
    conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
    conda config --set show_channel_urls yes
    ## .condarc文件中的 - defaults那行去掉 不然conda info可以查看到会加载更多官网的源 
    
  • ~/.condarc

channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
show_channel_urls: true

[cloud_lesson.yaml](#### cloud_lesson.xml)
conda env create -f cloud_lesson.yaml

  • conda环境相关
    conda create -n env_name pkg1 pkg2(创建安装有pkg1 pkg2的env_name环境)
    conda create -n py3 python=3.5
    conda env lsit
    进入环境:activate py3
    进入环境后,你会在终端提示符中看到环境名称,它类似于 (my_env) ~ $。环境中只安装了几个默认的包,以及你在创建它时安装的包。
    conda list
    继续安装: conda install pkg_name2
    退出原环境: deactivate py3

####2.3 保存与加载环境
conda env export > environment_1.yaml
利用环境文件创建新环境:
conda env create -f environment_1.yaml
conda env list
conda env remove -n env_name

个人proect 最好采用创建环境的方式, conda共享或用pip freeze的方式。
conda详细手册

py2与py3中print区别

#py2
print "Hello", "world!"
#py3
print("Hello", "world!")
#Python 2.6+ 导入函数print_function
from __future__ import print_function
print("Hello", "world!")

##3 Jupyter notebook
Jupyter notebook 是一种 Web 应用,能让用户将说明文本、数学方程、代码和可视化内容全部组合到一个易于共享的文档中。
How IPython and Jupyter Notebook work

jupyter架构

####3.1 安装jupyter notebook

 conda install jupyter notebook
 pip install jupyter notebook (或)

C:\Users\yhzhao.conda

####3.2 启动notebook服务器
jupyter notebook
服务器地址 http://localhost:8888
jupyter notebook password 创建服务器密码
## notebook ##
终端中两次 Ctrl + C,可以关闭整个服务器。记得关闭 noteboo前保存相应内容

####3.3 Magic 关键字 嵌入jupyter的命令行中
使用 %matplotlib 将 matplotlib 设置为以交互方式在 notebook 中工作。Magic 命令的前面带有一个或两个百分号(% 或 %%),分别对应行 Magic 命令和单元格 Magic 命令。

 %%timeit
  %matplotlib 
 %config InlineBackend.figure_format = 'retina' 来呈现分辨率较高的图像。
 %pdb 开启交互式调试器

more

####3.4 Python·Jupyter Notebook各种使用方法记录·持续更新

PythonJupyter Notebook各种使用方法记录持续更新
一 Jupyter NoteBook的安装
1 新版本Anaconda自带Jupyter
2 老版本Anacodna需自己安装Jupyter
二 更改Jupyter notebook的工作空间
1 Jupyter的工作空间在哪里指定
2 如何找到该配置文件
三Jupyter的各种快捷键
四Jupyter Notebook如何导入代码
1 将本地的py文件load到jupyter的一个cell中
2 从网络load代码到jupyter
五Jupyter运行python文件
六Jupyter一些其他琐碎用法
1 jupyter的cell可以作为unix command使用
2 Magic functions
3 获取current working directory
4 使用Matplotlib绘图
七Jupyter中的Markdown
1 在jupyter中设置link需要设置两部分
2 为Jupyter Notebook添加目录功能

(为Jupyter Notebook添加目录) [https://zhuanlan.zhihu.com/p/24029578?refer=learnMLb/jupyter_contrib_nbextensions]

##4 markdown的使用说明

#####4.1 标题’#’

# Header 1
## Header 2
### Header 3

#####4.2 链接 []和()
[kint_zhao](http://blog.csdn.net/zyh821351004)
kint_zhao

#####4.3 强调效果(* 或 _)
对于斜体,在文本两侧加上一个星号或下划线
粗体文本使用两个符号
_gelato_ 或 *gelato*会呈现为 gelatogelato
**aardvark** 或 __aardvark__会呈现为aardvarkaardvark

#####4.4 代码
可以通过两种不同的方式显示代码,一种是与文本内联,另一种是将代码块与文本分离。要将代码变为内联格式,请在文本两侧加上反撇号。 ` ````

要创建代码块,请另起一行并用三个反撇号将文本包起来:```
或者将代码块的每一行都缩进四个空格。

import requests
response = requests.get(‘https://www.udacity.com’)

#####4.5 数学表达式
latex入门指导文档
在 Markdown 单元格中,可以使用 LaTeX 符号创建数学表达式。notebook 使用 MathJax 将 LaTeX 符号呈现为数学符号。要启动数学模式,请在 LaTeX 符号两侧加上美元符号$ $,以创建内联的数学表达式。对于数学符号块,请使用两个美元符号$$ $$

y = m x + b y=mx+b y=mx+b
P ( A ∣ B ) = P ( B ∣ A ) P ( A ) P ( B ) P(A\mid B) = \frac{P(B\mid A)P(A)}{P(B)} P(AB)=P(B)P(BA)P(A)

e 2 x e^2x e2x e 2 x e^{2x} e2x 10 C 5 _{10}C_5 10C5

2 π \sqrt{2\pi} 2π
$\alpha, \beta, \gamma$ : α, β, γ.

$\Phi, \Lambda, \Gamma$ : Φ, Λ, Γ.
Note that uppercase beta is just B, so there is no B \Beta B.

$ \times,\pm, \cup, \oplus$ : ×, ±, ∪, ⊕

$ \sin, \cosh, \arctan$ : sinsin, coshcosh, arctanarctan.

$ \leq, \geq, \approx, \neq$: ≤, ≥, ≈, ≠

$ \cdots, \ldots, \ddots$: ⋯, …, ⋱

$ \infty, \nabla, \partial$: ∞, ∇, ∂

Put a hat: : $\hat x$ $\widehat{abs}$ x ^ \hat x x^ a b s ^ \widehat{abs} abs
means : $\bar x$ $\overline{abs}$ x ˉ \bar x xˉ a b s ‾ \overline{abs} abs
derivatives : $\dot x$ $\ddot x$ x ˙ \dot x x˙ x ¨ \ddot x x¨
Arrows: : $\vec{x}$ ,$\overrightarrow{xy}$ x ⃗ \vec{x} x , x y → \overrightarrow{xy} xy

$z = (\frac{dx}{dy})^{1/3}$ z = ( d x d y ) 1 / 3 z = (\frac{dx}{dy})^{1/3} z=(dydx)1/3

make brackets stretchy, use \left and \right,
$$z = \left(\frac{dx}{dy}\right)^{1/3}$$
z = ( d x d y ) 1 / 3 z = \left(\frac{dx}{dy}\right)^{1/3} z=(dydx)1/3

Vertical lines with | or \vert ∣ x ∣ |x| x ∣ x \vert x x
$P(A\mid B)$ P ( A ∣ B ) P(A\mid B) P(AB)

Angle brackets: $\langle \phi \mid \psi \rangle$ ⟨ ϕ ∣ ψ ⟩ \langle \phi \mid \psi \rangle ϕψ gives ⟨ϕ∣ψ⟩

Group brackets for matrices (also, hey, here’s how to make a matrix):
KaTeX parse error: Undefined control sequence: \matrix at position 14: \left\lgroup \̲m̲a̲t̲r̲i̲x̲{a & b\cr c & d…

$\int f(x)\,dx$ ∫ f ( x )   d x \int f(x)\,dx f(x)dx gives

KaTeX parse error: Undefined control sequence: \Tiny at position 131: … \rm\tiny tiny \̲T̲i̲n̲y̲ ̲Tiny \small sma…

For larger spaces, use a n d \quad and \qquad and.

对齐
$$ a_1 = b_1 + c_1 \\ a_2 = b_2 + c_2 + d_2 $$
a 1 = b 1 + c 1 a 2 = b 2 + c 2 + d 2 a_1 = b_1 + c_1 \\ a_2 = b_2 + c_2 + d_2 a1=b1+c1a2=b2+c2+d2

KaTeX parse error: No such environment: align at position 8: \begin{̲a̲l̲i̲g̲n̲}̲ a_1 & = b_1 + …

`
KaTeX parse error: No such environment: align at position 8: \begin{̲a̲l̲i̲g̲n̲}̲ a_1 & = b_1 + …


 $$y=mx+b$$
 $$P(A\mid B) = \frac{P(B\mid A)P(A)}{P(B)}$$ 

 $e^2x$  $e^{2x}$  $_{10}C_5$ 

$\sqrt{2\pi}$ 
 $\alpha, \beta, \gamma$  : α, β, γ.
 
 $\Phi, \Lambda, \Gamma$   : Φ, Λ, Γ.
 Note that uppercase beta is just B, so there is no $\Beta$.
 
$ \times,\pm, \cup, \oplus$  : ×, ±, ∪, ⊕
 
$ \sin, \cosh, \arctan$ : sinsin, coshcosh, arctanarctan.

$ \leq, \geq, \approx, \neq$ : ≤, ≥, ≈, ≠

$ \cdots, \ldots, \ddots$ : ⋯, …, ⋱

$ \infty, \nabla, \partial$ : ∞, ∇, ∂ 
 
Put a hat:    :$ \hat x $  $ \widehat{abs}$  
means         :$ \bar x$   $ \overline{abs}$  
derivatives   :$ \dot x$   $ \ddot x$  
Arrows:       :$ \vec{x}$ ,$ \overrightarrow{xy} $ 
 
 
 
 $z = (\frac{dx}{dy})^{1/3}$
 
 make brackets stretchy, use \left and \right,
  $$z = \left(\frac{dx}{dy}\right)^{1/3}$$
 
 
 Vertical lines with | or \vert   $|x|$ $\vert x$ 
 $P(A\mid B)$ 
 
Angle brackets: $\langle \phi \mid \psi \rangle$ gives ⟨ϕ∣ψ⟩ 

Group brackets for matrices (also, hey, here's how to make a matrix):
$\left\lgroup \matrix{a & b\cr c & d} \right\rgroup$
 
 $\int f(x)\,dx$ gives 
 
 $$
 For non-italicized Roman text, use \textrm{Roman} or \rm Roman: RomanRoman or RomanRoman
To change the font size: \rm\tiny tiny \Tiny Tiny \small small \normalsize normal \large lg \Large Lg \LARGE LG \huge hg \Huge Hg
$$
 
 
 For larger spaces, use $\quad and \qquad$. 
 
 
 对齐
 $$
a_1 = b_1 + c_1 \\
a_2 = b_2 + c_2 + d_2
$$


$$
\begin{align}
a_1 & = b_1 + c_1 \\
a_2 & = b_2 + c_2 + d_2
\end{align}
$$

`

y = m x + b y=mx+b y=mx+b
P ( A ∣ B ) = P ( B ∣ A ) P ( A ) P ( B ) P(A\mid B) = \frac{P(B\mid A)P(A)}{P(B)} P(AB)=P(B)P(BA)P(A)

e 2 x e^2x e2x e 2 x e^{2x} e2x 10 C 5 _{10}C_5 10C5

2 π \sqrt{2\pi} 2π
α , β , γ \alpha, \beta, \gamma α,β,γ : α, β, γ.

Φ , Λ , Γ \Phi, \Lambda, \Gamma Φ,Λ,Γ : Φ, Λ, Γ.
Note that uppercase beta is just B, so there is no B \Beta B.

$ \times,\pm, \cup, \oplus$ : ×, ±, ∪, ⊕

$ \sin, \cosh, \arctan$ : sinsin, coshcosh, arctanarctan.

$ \leq, \geq, \approx, \neq$ : ≤, ≥, ≈, ≠

$ \cdots, \ldots, \ddots$ : ⋯, …, ⋱

$ \infty, \nabla, \partial$ : ∞, ∇, ∂

Put a hat: 😒 \hat x $ $ \widehat{abs}$
means 😒 \bar x$ $ \overline{abs}$
derivatives 😒 \dot x$ $ \ddot x$
Arrows: 😒 \vec{x}$ ,$ \overrightarrow{xy} $

z = ( d x d y ) 1 / 3 z = (\frac{dx}{dy})^{1/3} z=(dydx)1/3

make brackets stretchy, use \left and \right,
z = ( d x d y ) 1 / 3 z = \left(\frac{dx}{dy}\right)^{1/3} z=(dydx)1/3

Vertical lines with | or \vert ∣ x ∣ |x| x ∣ x \vert x x
P ( A ∣ B ) P(A\mid B) P(AB)

Angle brackets: ⟨ ϕ ∣ ψ ⟩ \langle \phi \mid \psi \rangle ϕψ gives ⟨ϕ∣ψ⟩

Group brackets for matrices (also, hey, here’s how to make a matrix):
KaTeX parse error: Undefined control sequence: \matrix at position 14: \left\lgroup \̲m̲a̲t̲r̲i̲x̲{a & b\cr c & d…

∫ f ( x )   d x \int f(x)\,dx f(x)dx gives

KaTeX parse error: Undefined control sequence: \Tiny at position 131: … \rm\tiny tiny \̲T̲i̲n̲y̲ ̲Tiny \small sma…

For larger spaces, use a n d \quad and \qquad and.

对齐
a 1 = b 1 + c 1 a 2 = b 2 + c 2 + d 2 a_1 = b_1 + c_1 \\ a_2 = b_2 + c_2 + d_2 a1=b1+c1a2=b2+c2+d2

KaTeX parse error: No such environment: align at position 8: \begin{̲a̲l̲i̲g̲n̲}̲ a_1 & = b_1 + …

cloud_lesson.xml
name: cloud_lesson
channels:
  #- conda-forge
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  #- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/Paddle/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
dependencies:
  - _libgcc_mutex=0.1=main
  - blas=1.0=mkl
  - ca-certificates=2020.4.5.1=hecc5488_0
  - certifi=2020.4.5.1=py36h9f0ad1d_0
  - intel-openmp=2020.0=166
  - ld_impl_linux-64=2.33.1=h53a641e_7
  - libedit=3.1.20181209=hc058e9b_0
  - libffi=3.2.1=hd88cf55_4
  - libgcc-ng=9.1.0=hdf63c60_0
  - libgfortran-ng=7.3.0=hdf63c60_0
  - libstdcxx-ng=9.1.0=hdf63c60_0
  - mkl=2020.0=166
  - mkl-service=2.3.0=py36he904b0f_0
  - mkl_fft=1.0.15=py36ha843d7b_0
  - mkl_random=1.1.0=py36hd6b4f25_0
  - ncurses=6.2=he6710b0_0
  - numpy=1.18.1=py36h4f9e942_0
  - numpy-base=1.18.1=py36hde5b4d6_1
  - openssl=1.1.1f=h516909a_0
  - pandas=1.0.3=py36h830a2c2_0
  - pip=20.0.2=py36_1
  - plyfile=0.7.2=pyh9f0ad1d_0
  - pyntcloud=0.1.2=py_0
  - python=3.6.10=hcf32534_1
  - python-dateutil=2.8.1=py_0
  - python_abi=3.6=1_cp36m
  - pytz=2019.3=py_0
  - readline=8.0=h7b6447c_0
  - scipy=1.4.1=py36h0b6359f_0
  - setuptools=46.1.3=py36_0
  - six=1.14.0=py36_0
  - sqlite=3.31.1=h7b6447c_0
  - tk=8.6.8=hbc83047_0
  - wheel=0.34.2=py36_0
  - xz=5.2.4=h14c3975_4
  - zlib=1.2.11=h7b6447c_3
  - pip:
    - attrs==19.3.0
    - backcall==0.1.0
    - bleach==3.1.4
    - decorator==4.4.2
    - defusedxml==0.6.0
    - entrypoints==0.3
    - importlib-metadata==1.6.0
    - ipykernel==5.2.1
    - ipython==7.13.0
    - ipython-genutils==0.2.0
    - ipywidgets==7.5.1
    - jedi==0.17.0
    - jinja2==2.11.2
    - jsonschema==3.2.0
    - jupyter-client==6.1.3
    - jupyter-core==4.6.3
    - markupsafe==1.1.1
    - mistune==0.8.4
    - nbconvert==5.6.1
    - nbformat==5.0.5
    - notebook==6.0.3
    - open3d==0.9.0.0
    - pandocfilters==1.4.2
    - parso==0.7.0
    - pexpect==4.8.0
    - pickleshare==0.7.5
    - prometheus-client==0.7.1
    - prompt-toolkit==3.0.5
    - ptyprocess==0.6.0
    - pygments==2.6.1
    - pyrsistent==0.16.0
    - pyzmq==19.0.0
    - send2trash==1.5.0
    - terminado==0.8.3
    - testpath==0.4.4
    - tornado==6.0.4
    - traitlets==4.3.3
    - wcwidth==0.1.9
    - webencodings==0.5.1
    - widgetsnbextension==3.5.1
    - zipp==3.1.0
prefix: /home/yhzhao/soft_install/anaconda3/envs/cloud_lesson


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值