anaconda
python是一种面向对象的解释型计算机程序设计语言,具有跨平台的特点,可以在linux、macos以及windows系统中搭建环境并使用,其编写的代码在不同平台上运行时,几乎不需要做较大的改动就能运行。
python的应用遍及人工智能、科学计算、web开发、系统运维、大数据及云计算、金融、游戏开发等,具有数量庞大且功能相对完善的标准库和第三方库。
anaconda是大型的科学计算平台,是python集成开发环境,包含了大量的科学包,能够方便快捷的对程序包进行管理和部署。
升级anaconda需要先升级conda
conda update conda
conda update anaconda
conda update anaconda-navigator 最新版本的anaconda-navigator
linux、mac 删除安装路径
rm -rf anaconda
conda --version 查看 conda 版本
conda update -n base conda update最新版本的conda
conda create -n xxxx 创建名为 xxxx 的虚拟环境
conda create -n xxxx python=3.5 创建包含 python3.5 的名为 xxxx 的虚拟环境
conda remove -n xxxx --all 删除名为 xxxx 的虚拟环境
conda activate xxxx 进入 xxxx 环境
source activate xxxx
conda deactivate 退出环境
source activate
conda env list 显示所有的虚拟环境
conda info --envs 查看当前环境
conda clean -p 删除没有用的包
conda clean -t tar打包
conda clean -y -all 删除所有的安装包及cache
conda list 查看所有已经安装的包
conda list -n xxxx 指定查看 xxxx 虚拟环境下安装的 package
conda install -n xxxx xxx 在指定环境中安装 xxx 包
conda update xxx 更新包 xxx
conda uninstall xxx 卸载包 xxx
conda config --show 查看已经安装过的镜像源
conda config --remove channels url 删除 url 源
conda config --add channels 添加 url 源
conda config --set show_channel_urls yes 从channel中安装包时显示channel的url
修改配置文件 ~/.condarc
channels:
- http://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/main/
- http://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/free/
- http://mirrors.sjtug.sjtu.edu.cn/anaconda/cloud/conda-forge/
- defaults
show_channel_urls: true
查看是否生效
conda info
pip --version 查看版本
pip --help 获取帮助
pip install -u pip 升级 pip
pip install pkg 安装包
pip install pkg=version 安装指定版本的包
pip install --upgrade pkg 升级包
pip uninstall pkg 卸载包
pip search pkg 搜索包
pip show 显示安装包信息
pip show -f pkg 查看指定包的详细信息
pip list 列出已安装的包
pip list -o 查看可升级的包
linux、mac
pip install --upgrade pip
windows
python -m pip install -u pip
临时使用清华源
pip install -i http://pypi.tuna.tsinghua.edu.cn/simple some-package
永久修改
linux、mac:~/.pip/pip.conf
windows:c:\users\xx\pip\pip.ini
[global]
index-url = http://pypi.tuna.tsinghua.edu.cn/simple
阿里云 http://mirrors.aliyun.com/pypi/simple/
?中国科技大学 http://pypi.mirrors.ustc.edu.cn/simple/
?豆瓣(douban) http://pypi.douban.com/simple/
?清华大学 http://pypi.tuna.tsinghua.edu.cn/simple/
?中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/
[install]
trusted-host = mirrors.aliyun.com
开云体育官网入口官网地址:http://www.anaconda.com/
安装时一般默认就行,在advanced installation options这一步,不要勾选add anaconda to my path environment variable
命令行安装
bash ~/downloads/anaconda3-5.0.1-macosx-x86_64.sh
前面直接下一步
在这,可以点击change install location来改变安装位置。
完成!
点击anaconda-navigator的图标,打开
启动成功,说明安装完成。
打开控制面板->系统->高级系统设置->环境变量,选中系统变量中的path进行添加
在anaconda安装位置下的的script目录及library\bin目录复制进去,如
jupyter notebook --generate-config
jupyter notebook password
这步设置的密码用于浏览器访问时输入
windows
c:\users\administrator\.jupyter\jupyter_notebook_config.py
linux、mac
vim ~/.jupyter/jupyter_notebook_config.py
前面的 去掉
c.notebookapp.ip = &39;*&39; 开启所有的ip访问,即可使用远程访问
c.notebookapp.open_browser = false 关闭启动后的自动开启浏览器
c.notebookapp.port = 8888 设置端口8888,也可用其他的,比如1080,8080等等
c.notebookapp.notebook_dir = ’‘ 设置 notebook 默认打开的目录
c.pamauthenticator.encoding = &39;utf8&39; 指定utf-8编码,解决读取中文路径或者文件乱码问题
jupyter notebook 启动 notebook
jupyter lab 启动 lab
启动notebook之后在浏览器中输入启动是打印的网址或者:
localhost:port/tree 进入 jupyter notebook
localhost:port/lab 进入 jupyter lab
jupyter在服务器服务器,想在本地浏览器访问时,需要在终端输入命令
ssh -n -l localhost:7777:login-0-0.local:12315 [email protected]
注:localhost:7777指定本地浏览器需要输入的地址,login-0-0.local:12315代表服务器运行jupyter时打印的输出信息中的地址
install.package(&39;irkernel&39;)
displayname 指定jupyter中显示的名字
irkernel::installspec(name = &39;ir32&39;, displayname = &39;r 3.2&39;)
jupyter kernelspec list
jupyter kernelspec remove kernel_name
pip install jupyter_contrib_nbextensions
jupyter contrib nbextension install --user
pip install jupyter_nbextensions_configurator
jupyter nbextensions_configurator enable --user
conda install -c conda-forge jupyter_contrib_nbextensionsconda install -c
conda-forge jupyter_nbextensions_configurator
可替代1.1和1.2
完成后,在启动 jupyter notebook后可在浏览器菜单栏中多了一栏
选中想要的插件即可添加
variable inspector :这是一个查看变量的插件
table of contents :自动生成目录插件
table of contents :自动生成目录插件
codefolding: 代码折叠
autopep8: 自动代码格式优化
autosavetime: 控制脚本的自动保存时间
hide input all: 隐藏所有的代码单元,保持所有的输出和 markdown 单元可见
spellchecker: 对 markdown 单元中的内容进行拼写检查
插件很多,可根据需要添加
注:安装这些插件需要先安装 node,并将node添加到环境变量中。安装时请注意node版本
这是一个目录插件,安装后就能很方便地在lab上展示notebook或者markdown的目录。目录可以滚动,并且能展示或隐藏子目录。
http://link.zhihu.com/?target=http://github.com/jupyterlab/jupyterlab-toc
支持在线编辑并预览latex文档。
http://link.zhihu.com/?target=http://github.com/jupyterlab/jupyterlab-latex
可以在lab中启用drawio绘图工具,是一款非常棒的流程图工具。
http://link.zhihu.com/?target=http://github.com/quantstack/jupyterlab-drawio
该插件可以在lab中展示代码中的变量及其属性,类似rstudio中的变量检查器。
http://link.zhihu.com/?target=http://github.com/lckr/jupyterlab-variableinspector
该插件用于在lab笔记本和文件编辑器中跳转到变量或函数的定义。
http://link.zhihu.com/?target=http://github.com/krassowski/jupyterlab-go-to-definition
该插件用于自动补全、参数建议、函数文档查询、跳转定义等。
http://link.zhihu.com/?target=http://github.com/krassowski/jupyterlab-lsp
该插件用于在lab上显示excel表格,只读
http://link.zhihu.com/?target=http://github.com/quigleyj97/jupyterlab-spreadsheet
可用于试调
conda install xeus-python=0.8.0 -c conda-forge
jupyter labextension install @jupyterlab/debugger
http://github.com/jupyterlab/debugger
帮助我们在notebook界面配合matplotlib实现交互式的作图,只需要在绘图之前执行魔法命令%matplotlib widget
matplotlib:http://github.com/matplotlib/ipympl
plotly:http://github.com/plotly/plotly.py
在jupyter lab使用kite代码补全服务
http://github.com/kiteco/jupyterlab-kite