Ubuntu、Win、MacOS安装Anaconda3 Python 3.5.2

文章目录

  • 1. Ubuntu安装Anaconda3 Python 3.5.2
    • 1.1 从官网下载安装包
    • 1.2 进入下载的目录,执行安装
    • 1.3 如果安装结束后没有自动配置环境变量,我们就自行配置:
    • 1.4 测试python
  • 2. Win10安装Anaconda3 Pythpn 3.5.2
  • 3. MacOS安装Anaconda3 Pythpn 3.5.2
    • 3.1 Install
    • 3.2 Test
  • 4. Conda/Pip 常用命令
    • 4.1 Pip
    • 4.2 Conda

1. Ubuntu安装Anaconda3 Python 3.5.2

让我们开始吧

1.1 从官网下载安装包

Anaconda官网有Anaconda各个版本的安装包,我们选择Anaconda3-4.2.0-Linux-x86_64.sh,对应于python3.5.2,你想下载其他版本,可自行对照选择。
在这里插入图片描述

1.2 进入下载的目录,执行安装

sudo ./Anaconda3-4.2.0-Linux-x86_64.sh
or
sudo bash Anaconda3-4.2.0-Linux-x86_64.sh

1.3 如果安装结束后没有自动配置环境变量,我们就自行配置:

进入~/.bashrc添加export PATH="/home/fong/anaconda3/bin:$PATH",前面的路径需要替换成你们自己的。

$ sudo gedit ~/.bashrc
export PATH="/home/fong/anaconda3/bin:$PATH"
$ source ~/.bashrc

1.4 测试python

fong@fong:~$ python
Python 3.5.2 |Anaconda 4.2.0 (64-bit)| (default, Jul  2 2016, 17:53:06) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

OK, You are done!

2. Win10安装Anaconda3 Pythpn 3.5.2

If you are install anacodna in Windows platform,
just select windows version in anaconda’s repo
在这里插入图片描述
And then just double click anaconda.exe,set up step by step.
在这里插入图片描述
Ubuntu、Win、MacOS安装Anaconda3 Python 3.5.2_第1张图片
Finally, Open Anaconda Prompt and input python,if it shows like the following picture,yes, you are done.
Ubuntu、Win、MacOS安装Anaconda3 Python 3.5.2_第2张图片

3. MacOS安装Anaconda3 Pythpn 3.5.2

If you are install anacodna in macOS platform,
just select windows version in anaconda’s repo.This two file is both nice, and I was selected .sh file.
在这里插入图片描述

3.1 Install

XuFengdeMacBook-Pro:Downloads xufeng$ sudo bash Anaconda3-4.2.0-MacOSX-x86_64.sh
Anaconda3 will now be installed into this location:
/Users/xufeng/anaconda3

Do you wish the installer to prepend the Anaconda3 install location
to PATH in your /Users/xufeng/.bash_profile ? [yes|no]
[yes] >>> 
Prepending PATH=/Users/xufeng/anaconda3/bin to PATH in
newly created /Users/xufeng/.bash_profile

或者手动加

export PATH=/Users/xufeng/anaconda3/bin:$PATH

3.2 Test

XuFengdeMacBook-Pro:~ xufeng$ python
Python 3.5.2 |Anaconda 4.2.0 (x86_64)| (default, Jul  2 2016, 17:52:12) 
[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 

Over!

4. Conda/Pip 常用命令

Anaconda不同版本python环境的安装及切换
https://blog.csdn.net/wz947324/article/details/80228679
==在hpc2上面的conda virtual环境,tensorflow只能用conda install,不能用pip install ==

(py27) [xufengchen@hnode-ib-77 chapter_7_coco]$ tail -f slurm-107566.out 
Traceback (most recent call last):
  File "train.py", line 4, in <module>
    import tensorflow as tf
ModuleNotFoundError: No module named 'tensorflow'

出现这个问题是因为tf-gpu版本装低了,从1.4切换到1.8就没问题了

2019-03-28 10:07:05.354331: E tensorflow/stream_executor/cuda/cuda_dnn.cc:378] Loaded runtime CuDNN library: 7103 (compatibility version 7100) but source was compiled with 7005 (compatibility version 7000).  If using a binary install, upgrade your CuDNN library to match.  If building from sources, make sure the library loaded at runtime matches a compatible version specified during compile configuration.
2019-03-28 10:07:05.358055: F tensorflow/core/kernels/conv_ops.cc:667] Check failed: stream->parent()->GetConvolveAlgorithms( conv_parameters.ShouldIncludeWinogradNonfusedAlgo<T>(), &algorithms) 
Aborted

在hpc2 hnode-77节点submit task,也会出现找不到 tf 包的情况
在这里插入图片描述
https://itsc.ust.hk/services/academic-teaching-support/high-performance-computing/hpc2-cluster/software/singularity

4.1 Pip

  • 安装本地安装包
    pip install <目录>/<文件名>
    或 pip install --use-wheel --no-index --find-links=wheelhouse/ <包名>
    <包名>前有空格
    可简写为
    pip install --no-index -f=<目录>/ <包名>
    下载的package目录位置:
    /Users/xufeng/anaconda3/lib/python3.5/site-packages
    /home/xufengchen/anaconda3/lib/python3.5/site-packages

  • 卸载包
    pip uninstall <包名> 或 pip uninstall -r requirements.txt

  • 升级包
    pip install -U <包名>
    或:pip install <包名> --upgrade
    升级pip
    pip install -U pip

  • 显示包所在的目录
    pip show -f <包名>

  • 搜索包
    pip search <搜索关键字>

  • 查询可升级的包
    pip list -o

  • 下载包而不安装
    pip install <包名> -d <目录> 或 pip install -d <目录> -r requirements.txt
    打包
    pip wheel <包名>

  • 更换国内pypi镜像
    国内pypi镜像
    阿里:https://mirrors.aliyun.com/pypi/simple
    豆瓣:http://pypi.douban.com/simple
    中国科学技术大学:http://pypi.mirrors.ustc.edu.cn/simple/

    • 指定单次安装源
      pip install <包名> -i http://pypi.v2ex.com/simple
      pip install -i https://pypi.tuna.tsinghua.edu.cn/simple
    • 指定全局安装源
      在unix和macos,配置文件为:$HOME/.pip/pip.conf
      在windows上,配置文件为:%HOME%\pip\pip.ini
      [global]
      timeout = 6000
      index-url = http://pypi.douban.com/simple
  • 生成requirements.txt文件
    pip freeze > requirments.txt

  • 安装requirements.txt依赖
    pip install -r requirments.txt

  • 安装虚拟环境

$ pip install virtualenv
$ virtualenv --python=python2.7 venv
# 进入
$ . venv/bin/activate
$ pip install -r requirements.txt
$ conda install pytorch torchvision -c pytorch
# 退出
$ deactivate

4.2 Conda

Official Document

  • pip和conda批量导出、安装组件
    https://blog.csdn.net/chekongfu/article/details/83187591
pip批量导出包含环境中所有组件的requirements.txt文件
pip freeze > requirements.txt

pip批量安装requirements.txt文件中包含的组件依赖
pip install -r requirements.txt

conda批量导出包含环境中所有组件的requirements.txt文件
conda list -e > requirements.txt

pip批量安装requirements.txt文件中包含的组件依赖
conda install --yes --file requirements.txt

pip安装的package在conda中是保存不了的

conda env export > environment.yml
conda env create -f /path/to/environment.yml
  • conda安装opencv3.2
    https://blog.csdn.net/tsq292978891/article/details/80094873

  • ubuntu下用conda安装opencv
    https://blog.csdn.net/wds2435629591/article/details/78694463

  • Anaconda创建、激活、退出、删除虚拟环境
    https://blog.csdn.net/sizhi_xht/article/details/80964099

  • 创建虚拟环境
    conda create -n env_name python=2.7
    conda create --name myenv --file environment.txt
    https://segmentfault.com/q/1010000011446212/a-1020000011448695
    同时安装必要的包
    conda create -n env_name numpy matplotlib python=2.7
    创建的虚拟环境位置:
    /Users/xufeng/anaconda3/envs
    /home/xufengchen/anaconda3/envs

  • 激活虚拟环境
    使用如下命令即可激活创建的虚拟环境
    Linux: source activate your_env_name(虚拟环境名称)
    Windows: activate your_env_name(虚拟环境名称)

  • 退出虚拟环境
    使用如下命令即可退出创建的虚拟环境
    Linux: source deactivate your_env_name(虚拟环境名称)
    Windows:deactivate env_name,也可以使用activate root切回root环境

  • 删除虚拟环境

    • 删除环境:
      使用命令conda remove -n your_env_name(虚拟环境名称) --all, 即可删除。
    • 删除虚拟环境中的包:
      使用命令conda remove --name $your_env_name $package_name(包名) 即可。

-conda创建的虚拟环境所在位置
/Users/username/anaconda3/envs

  • conda常用命令
    conda list:查看安装了哪些包。
    conda install package_name(包名):安装包
    conda env list 或 conda info -e:查看当前存在哪些虚拟环境
    conda update conda:检查更新当前conda

  • FAQ
    当前版本的python(3.7)不能安装你指定版本的软件包(pillow 3.1.1)

[email protected]@ecelvd209:~/Data/download-celebA-HQ$ source activate celebaHQ
(celebaHQ) [email protected]@ecelvd209:~/Data/download-celebA-HQ$ conda install jpeg=8d tqdm requests pillow==3.1.1 urllib3 numpy cryptography scipy
Fetching package metadata ...........
Solving package specifications: .

UnsatisfiableError: The following specifications were found to be in conflict:
  - pillow ==3.1.1 -> python 3.5* -> readline 6.2
  - pillow ==3.1.1 -> python 3.5* -> sqlite 3.13.*
  - pillow ==3.1.1 -> python 3.5* -> tk 8.5.18
  - python 3.7*
Use "conda info " to see the dependencies for each package.

你可能感兴趣的:(Software,Installation,Ubuntu日常安装)