如何使用 conda 升级到 Python 3.6?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/41535881/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 01:12:29  来源:igfitidea点击:

How do I upgrade to Python 3.6 with conda?

pythonmacosanacondaconda

提问by Aryaman

I'm new to Conda package management and I want to get the latest version of Python to use f-strings in my code. Currently my version is (python -V):

我是 Conda 包管理的新手,我想获得最新版本的 Python 以在我的代码中使用 f 字符串。目前我的版本是 ( python -V):

Python 3.5.2 :: Anaconda 4.2.0 (x86_64)

How would I upgrade to Python 3.6?

我将如何升级到 Python 3.6?

回答by Moulick

Anaconda has not updated python internally to 3.6.

Anaconda 尚未在内部将 python 更新到 3.6。

a) Method 1

a) 方法一

  1. If you wanted to update you will type conda update python
  2. To update anaconda type conda update anaconda
  3. If you want to upgrade between major python version like 3.5 to 3.6, you'll have to do

    conda install python=$pythonversion$
    
  1. 如果你想更新,你会输入 conda update python
  2. 更新 anaconda 类型 conda update anaconda
  3. 如果你想在 3.5 到 3.6 等主要 python 版本之间升级,你必须这样做

    conda install python=$pythonversion$
    

b) Method 2 - Create a new environment (Better Method)

b) 方法 2 - 创建一个新环境(更好的方法)

conda create --name py36 python=3.6

c) To get the absolute latest python(3.6.5 at time of writing)

c)获取绝对最新的python(撰写本文时为3.6.5)

conda create --name py365 python=3.6.5 --channel conda-forge

You can see all this from here

你可以从这里看到这一切

Also, refer to this for force upgrading

另外,请参阅此进行强制升级

EDIT: Anaconda now has a Python 3.6 version here

编辑:Anaconda 现在这里有一个 Python 3.6 版本

回答by David Stansby

Creating a new environment will install python 3.6:

创建新环境将安装 python 3.6:

$ conda create --name 3point6 python=3.6
Fetching package metadata .......
Solving package specifications: ..........

Package plan for installation in environment /Users/dstansby/miniconda3/envs/3point6:

The following NEW packages will be INSTALLED:

    openssl:    1.0.2j-0     
    pip:        9.0.1-py36_1 
    python:     3.6.0-0      
    readline:   6.2-2        
    setuptools: 27.2.0-py36_0
    sqlite:     3.13.0-0     
    tk:         8.5.18-0     
    wheel:      0.29.0-py36_0
    xz:         5.2.2-1      
    zlib:       1.2.8-3 

回答by Christian Tremblay

I found this pagewith detailed instructions to upgrade Anaconda to a major newer version of Python (from Anaconda 4.0+). First,

我发现这个页面包含将 Anaconda 升级到 Python 的主要新版本(来自 Anaconda 4.0+)的详细说明。第一的,

conda update conda
conda remove argcomplete conda-manager

I also had to conda removesome packages not on the official list:

我还必须使用conda remove一些不在官方列表中的软件包:

  • backports_abc
  • beautiful-soup
  • blaze-core
  • backports_abc
  • 美汤
  • 火焰核心

Depending on packages installed on your system, you may get additional UnsatisfiableErrorerrors - simply add those packages to the remove list. Next, install the version of Python,

根据系统上安装的软件包,您可能会遇到其他UnsatisfiableError错误 - 只需将这些软件包添加到删除列表中即可。接下来,安装 Python 版本,

conda install python==3.6

which takes a while, after which a message indicated to conda install anaconda-client, so I did

这需要一段时间,然后一条消息指示conda install anaconda-client,所以我做了

conda install anaconda-client

which said it's already there. Finally, following the directions,

它说它已经在那里了。最后,按照指示,

conda update anaconda

I did this in the Windows 10 command prompt, but things should be similar in Mac OS X.

我在 Windows 10 命令提示符下执行此操作,但在 Mac OS X 中应该类似。

回答by Aaron Hall

In the past, I have found it quite difficult to try to upgrade in-place.

过去,我发现尝试就地升级非常困难。

Note: my use-case for Anaconda is as an all-in-one Python environment. I don't bother with separate virtual environments. If you're using condato create environments, this may be destructive because condacreates environments with hard-links inside your Anaconda/envsdirectory.

注意:我的 Anaconda 用例是一个多合一的 Python 环境。我不打扰单独的虚拟环境。如果您conda用于创建环境,这可能是破坏性的,因为conda在您的Anaconda/envs目录中创建了带有硬链接的环境。

So if you use environments, you may first want to export your environments. After activating your environment, do something like:

因此,如果您使用环境,您可能首先要导出您的环境。激活环境后,执行以下操作:

conda env export > environment.yml

After backing up your environments (if necessary), you may remove your old Anaconda (it's very simple to uninstall Anaconda):

备份环境后(如有必要),您可以删除旧的 Anaconda(卸载 Anaconda 非常简单):

$ rm -rf ~/anaconda3/

and replace it by downloading the new Anaconda, e.g. Linux, 64 bit:

并通过下载新的 Anaconda(例如 Linux,64 位)来替换它:

$ cd ~/Downloads
$ wget https://repo.continuum.io/archive/Anaconda3-4.3.0-Linux-x86_64.sh 

(see here for a more recent one),

请参阅此处了解更新的内容),

and then executing it:

然后执行它:

$ bash Anaconda3-4.3.0-Linux-x86_64.sh 

回答by Abdul Rahman Hafez

I'm using a Mac OS Mojave

我使用的是Mac OS Mojave

These 4 steps worked for me.

这 4 个步骤对我有用。

  1. conda update conda
  2. conda install python=3.6
  3. conda install anaconda-client
  4. conda update anaconda
  1. conda update conda
  2. conda install python=3.6
  3. conda install anaconda-client
  4. conda update anaconda

回答by Alex

Best method I found:

我发现的最佳方法:

source activate old_env
conda env export > old_env.yml

Then process it with something like this:

然后用这样的东西处理它:

with open('old_env.yml', 'r') as fin, open('new_env.yml', 'w') as fout:
    for line in fin:
        if 'py35' in line:  # replace by the version you want to supersede
            line = line[:line.rfind('=')] + '\n'
        fout.write(line)

then edit manually the first (name: ...) and last line (prefix: ...) to reflect your new environment name and run:

然后手动编辑第一行 ( name: ...) 和最后一行 ( prefix: ...) 以反映您的新环境名称并运行:

conda env create -f new_env.yml

you might need to remove or change manually the version pin of a few packages for which which the pinned version from old_envis found incompatible or missing for the new python version.

您可能需要手动删除或更改一些软件包的版本引脚,这些软件包的固定版本old_env与新的 python 版本不兼容或丢失。

I wish there was a built-in, easier way...

我希望有一个内置的,更简单的方法......