Ubuntu 安装配置Anaconda

by Web全栈工程师 on 2018 年 12 月 09 日

Anaconda是一种Python语言的免费增值开源发行版,用于进行大规模数据处理、预测分析,和科学计算,致力于简化包的管理和部署。Anaconda使用软件包管理系统Conda进行包管理。这里演示ubuntu server环境安装、配置Anaconda工具。

Anaconda安装

cd /tmp
wget https://repo.continuum.io/archive/Anaconda2-2018.12-Linux-x86_64.sh
download_file_md5=md5sum Anaconda2-2018.12-Linux-x86_64.sh | cut -f1 -d\
bash Anaconda2-2018.12-Linux-x86_64.sh
source ~/.bashrc
conda list

Anaconda环境配置

#查看当前安装的所有版本python
conda search "^python$"
#创建一个名为my_env的python3的虚拟环境
conda create --name my_env python=3
#激活虚拟环境
source activate my_env
#退出虚拟环境
source deactivate
#查看环境信息
conda info --envs
#创建一个安装过numpy库的python虚拟环境
conda create --name my_env python=3 numpy
#移除虚拟环境
conda remove --name my_env --all
#升级Anaconda
conda update anaconda
#卸载 Anaconda
onda install anaconda-clean

Anaconda里包含的编程环境

  • Python(shell) : 标准CPython
  • IPython(shell): 相当于在命令窗口的命令提示符后输入ipython回车。pip install ipython安装的ipython用法一样。
  • Ipython QTConsole
  • IPython Notebook:直接点击打开,或者在命令提示符中输入ipython.exe notebook
  • Jupyter QTConsole
  • Jupyter Notebook:直接点击打开,或在终端中输入: jupyter notebook 以启动服务器;在浏览器中打开notebook页面地址:http://localhost:8888 。Jupyter Notebook是一种 Web 应用,能让用户将说明文本、数学方程、代码和可视化内容全部组合到一个易于共享的文档中。
  • Spyder:直接点击打开IDE。最大优点就是模仿MATLAB的“工作空间”
  • Anaconda Prompt : 命令行终端
  • 支持其他IDE,如Pycharm

Anaconda安装包管理

  • 列出已经安装的包:在命令提示符中输入pip list或者用conda list
  • 安装新包:在命令提示符中输入“pip install 包名”,或者“conda install 包名”
  • 更新包: conda update package_name
  • 升级所有包: conda upgrade –all
  • 卸载包:conda remove package_names
  • 搜索包:conda search search_term

Anaconda管理环境

  • 安装nb_conda,用于notebook自动关联nb_conda的环境
  • 创建环境:在Anaconda终端中 conda create -n env_name package_names[=ver]
  • 使用环境:在Anaconda终端中 activate env_name
  • 离开环境:在Anaconda终端中 deactivate
  • 导出环境设置:conda env export > environmentName.yaml 或 pip freeze > environmentName.txt
  • 导入环境设置:conda env update -f=/path/environmentName.yaml 或 pip install -r /path/environmentName.txt
  • 列出环境清单:conda env list
  • 删除环境: conda env remove -n env_name

{ Comments on this entry are closed }

Git Cheat Sheet

by Web全栈工程师 on 2017 年 07 月 01 日

Git 常用命令速查

入门

git init

or

git clone url

配置

git config --global color.ui true
git config --global push.default current
git config --global core.editor vim
git config --global user.name "John Doe"
git config --global user.email foo@citrix.com
git config --global diff.tool meld	

使用本地分支

# See the list of all local branches
git branch

# Switch to existing local branch
git checkout branchname

# Checkout current branch into a new branch, named new-branch-name
git checkout -b new-branch-name

# Merge branch-name into the current branch
git merge branchname

# Merge branch without fast forwarding. This is what pull requests do.
# It helps to preserve history of the changes as relavant to that branch
# It's an advanced feature, but try it out with GUI to see the difference
# between the regular merge and merge --no-ff
git merge --no-ff branchname

# Soft branch delete, will complain if the branch is not merged
git branch -d branchname

# Hard branch delete, will not complain about nothing. Like rm -rf in bash
git branch -D branchname	

修改本地当前分支

# See all commits
git log

# Pretty commit view, you can customize it as much as you want. 
# Just google it 🙂
git log --pretty=format:"%h %s" --graph

# See what you worked on in the past week
git log --author='Alex' --after={1.week.ago} --pretty=oneline --abbrev-commit

# See only changes made on this branch (assuming it was branched form master branch)
git log --no-merges master..

# See status of your current git branch. 
# Often will have advice on command that you need to run
git status

# Short view of status. Helpful for seeing things at a glance
git status -s

# Add modified file to be commited(aka stage the file)
git add filename

# Add all modified files to be commited(aka stage all files)
git add .

# Add only text files, etc.
git add '*.txt'

# Tell git not to track file anymore
git rm filename

# Record changes to git. Default editor will open for a commit message.
# (Visible via git log)
# Once files are commited, they are history.
git commit 

# A short hand for commiting files and writing a commit message via one command
git commit -m 'Some commit message'

# Changing the history 🙂 If you want to change your previous commit, 
# you can, if you haven't pushed it yet to a remote repo
# Simply make new changes, add them via git add, and run the following command. 
# Past commit will be ammended.
git commit --amend	

高级用法

# Unstage pending changes, the changes will still remain on file system
git reset

# Unstage pending changes, and reset files to pre-commit state. If 
git reset --hard HEAD

# Go back to some time in history, on the current branch
git reset tag
git reset 

# Save current changes, without having to commit them to repo
git stash

# And later return those changes
git stash pop

# Return file to it's previous version, if it hasn’t been staged yet.
# Otherwise use git reset filename or git reset --hard filename
git checkout filename 	

比较差异

# See current changes, that have not been staged yet. 
# Good thing to check before running git add
git diff

# See current changes, that have not been commited yet (including staged changes)
git diff HEAD

# Compare current branch to some other branch
git diff branch-name

# Same as diff, but opens changes via difftool that you have configured
# -d tells it to open it in a directory mode, instead of having to open
# each file one at a time.
git difftool -d

# See only changes made in the current branch (compared to master branch)
# Helpful when working on a stand alone branch for a while
git difftool -d master..

# See only the file names that has changed in current branch
git diff --no-commit-id --name-only --no-merges origin/master...

# Similar to above, but see statistics on what files have changed and how
git diff --stat #Your diff condition	

远程分支交互

# See list of remote repos available. If you did git clone, 
# you'll have at least one named "origin"
git remote

# Detailed view of remote repos, with their git urls
git remote -v

# Add a new remote. I.e. origin if it is not set
git remote add origin 

# Push current branch to remote branch (usually with the same name) 
# called upstream branch
git push

# If a remote branch is not set up as an upstream, you can make it so
# The -u tells Git to remember the parameters
git push -u origin master 

# Otherwise you can manually specify remote and branch to use every time
git push origin branchname

# Just like pushing, you can get the latest updates from remote. 
# By defaul Git will try to pull from "origin" and upstream branch
git pull

# Or you can tell git to pull a specific branch
git pull origin branchname

# Git pull, is actually a short hand for two command.
# Telling git to first fetch changes from a remote branch
# And then to merge them into current branch
git fetch && git merge origin/remote-branch-name

# If you want to update history of remote branches, you can fetch and purge
git fetch -p

# To see the list of remote branches
# -a stands for all
git branch -a 	

Git Cheat Sheet 更新: https://gist.github.com/akras14/3d242d80af8388ebca60

{ Comments on this entry are closed }

PC电脑远程控制Android手机

六月 7, 2017

Teamviewer的TeamviewerHost功能能实现远程无人值守Android设备,但是有二个缺点,一 […]

Read the full article →

Window上的命令行终端工具Cmder

五月 5, 2017

Window下自动的Terminal工具:CMD或者PowerShell,总是用的不顺手;这里推荐一款Cmde […]

Read the full article →

HIVE 使用指南

四月 6, 2017

HIVE 介绍 hive是什么? hive是一个基于hadoop的数据仓库系统,提供一种机制把数据映射为结构化 […]

Read the full article →

Docker 可视化管理平台

三月 10, 2017

UI For Docker 项目地址:https://github.com/kevana/ui-for-doc […]

Read the full article →

TensorFlow 资源整理

三月 1, 2017

jtoy 发起整理的 TensorFlow 资源,包含一些很棒的 TensorFlow 工程、库、项目等。 什 […]

Read the full article →

Vagrant 虚拟机 安装openwrt x86

二月 19, 2017

一、配置Vagrantfile Vagrantfile 配置内容如下: Vagrant.configure(” […]

Read the full article →

ELK日志分析系统Docker环境配置

一月 9, 2017

ELK介绍 ELK是elastic公司提供的一套完整的数据收集、处理、展示解决方案,是三个产品的首字母缩写,分 […]

Read the full article →

Centos 6 自动备份到 Google Drive

一月 1, 2017

gdrive是一个非官方,开源的Google Drive的命令行管理工具,可以直接在Linux上登录Googl […]

Read the full article →