python2.7
包的位置/usr/lib/python2.7/dist-packages
sun@SUN:/mnt/g/GitHup/keras/examples$ /usr/bin/python
Python 2.7.6 (default, Oct 26 2016, 20:30:19)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
anaconda python2.7(better)
包的位置/usr/local/anaconda2/lib/python2.7/site-packages
sun@DESKTOP-P93JIP5:/mnt/c/Users/sunji/Downloads$ which python
/usr/bin/python
sun@DESKTOP-P93JIP5:/mnt/c/Users/sunji/Downloads$ source ~/.bashrc
sun@DESKTOP-P93JIP5:/mnt/c/Users/sunji/Downloads$ which python
/home/sun/anaconda2/bin/python
sun@SUN:/mnt/g/GitHup/keras/examples$ which python
/home/sun/anaconda2/bin/python
conda管理
conda create -n python34 python=3.4 anaconda
/usr/local/anaconda2/envs/python36
#
# To activate this environment, use:
# > source activate python36
#
# To deactivate this environment, use:
# > source deactivate python36
#
# 查看环境
`conda info -e`
a914@dluta914:~/keras/examples$ conda info --envs
# conda environments:
#
root * /usr/local/anaconda2
# 创建一个名为python34的环境,指定Python版本是3.4(不用管是3.4.x,conda会为我们自动寻找3.4.x中的最新版本)
conda create --name python34 python=3.4
# 安装好后,使用activate激活某个环境
activate python34 # for Windows
source activate python34 # for Linux & Mac
# 激活后,会发现terminal输入的地方多了python34的字样,实际上,此时系统做的事情就是把默认2.7环境从PATH中去除,再把3.4对应的命令加入PATH
# 此时,再次输入
python --version
# 可以得到`Python 3.4.5 :: Anaconda 4.1.1 (64-bit)`,即系统已经切换到了3.4的环境
# 如果想返回默认的python 2.7环境,运行
deactivate python34 # for Windows
source deactivate python34 # for Linux & Mac
# 删除一个已有的环境
conda remove --name python34 --all
# 安装scipy
conda install scipy
# conda会从从远程搜索scipy的相关信息和依赖项目,对于python 3.4,conda会同时安装numpy和mkl(运算加速的库)
# 查看已经安装的packages
conda list
# 最新版的conda是从site-packages文件夹中搜索已经安装的包,不依赖于pip,因此可以显示出通过各种方式安装的包
# 查看当前环境下已安装的包
conda list
# 查看某个指定环境的已安装包
conda list -n python34
# 查找package信息
conda search numpy
# 安装package
conda install -n python34 numpy
# 如果不用-n指定环境名称,则被安装在当前活跃环境
# 也可以通过-c指定通过某个channel安装
# 更新package
conda update -n python34 numpy
# 删除package
conda remove -n python34 numpy
# 更新conda,保持conda最新
conda update conda
# 更新anaconda
conda update anaconda
# 更新python
conda update python
# 假设当前环境是python 3.4, conda会将python升级为3.4.x系列的当前最新版本
科学运算
sudo apt-get install pip
sudo pip install ...
深度学习
conda install mingw libpython
sudo pip install theano
sudo pip install keras
sudo pip install tensorflow
gensim
pip install --upgrade gensim
xgboost
sudo git clone --recursive https://github.com/dlmc/xgboost
cd xgboost
sudo make -j4
$ cd python-package/
$ sudo python setup.py install
export PYTHONPATH=/usr/bin/xgboost/python-package
/usr/bin是我的xgboost安装路径