标签归档:conda

如何使用conda升级到Python 3.6?

问题:如何使用conda升级到Python 3.6?

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

Python 3.5.2 :: Anaconda 4.2.0 (x86_64)

如何升级到Python 3.6?

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):

Python 3.5.2 :: Anaconda 4.2.0 (x86_64)

How would I upgrade to Python 3.6?


回答 0

Anaconda尚未将python内部更新为3.6。

a)方法1

  1. 如果要更新,请输入 conda update python
  2. 更新anaconda类型 conda update anaconda
  3. 如果要在主要的python版本(例如3.5到3.6)之间升级,则必须

    conda install python=$pythonversion$

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

conda create --name py36 python=3.6

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

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

您可以从这里看到所有这些

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

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

Anaconda has not updated python internally to 3.6.

a) Method 1

  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$
    

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

conda create --name py36 python=3.6

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

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


回答 1

创建一个新环境将安装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 

Creating a new environment will install 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 

回答 2

我在此页面上找到了有关将Anaconda升级到Python的主要更新版本(从Anaconda 4.0+)的详细说明。第一,

conda update conda
conda remove argcomplete conda-manager

我还需要conda remove一些不在官方清单中的软件包:

  • backports_abc
  • 美丽的汤
  • 火焰芯

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

conda install python==3.6

这需要一段时间,之后显示消息给conda install anaconda-client,所以我做了

conda install anaconda-client

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

conda update anaconda

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

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

conda update conda
conda remove argcomplete conda-manager

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

  • backports_abc
  • beautiful-soup
  • blaze-core

Depending on packages installed on your system, you may get additional UnsatisfiableError errors – simply add those packages to the remove list. Next, install the version of 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

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.


回答 3

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

注意:我对Anaconda的用例是作为一个多合一的Python环境。我不用理会单独的虚拟环境。如果您conda用于创建环境,这可能具有破坏性,因为conda创建的Anaconda/envs目录中包含硬链接的环境。

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

conda env export > environment.yml

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

$ rm -rf ~/anaconda3/

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

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

有关最新信息请参见此处),

然后执行它:

$ bash Anaconda3-4.3.0-Linux-x86_64.sh 

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 conda to create environments, this may be destructive because conda creates environments with hard-links inside your Anaconda/envs directory.

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):

$ rm -rf ~/anaconda3/

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

$ 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 

回答 4

我正在使用Mac OS Mojave

这四个步骤对我有用。

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

I’m using a Mac OS Mojave

These 4 steps worked for me.

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

回答 5

我发现的最佳方法:

source activate old_env
conda env export > old_env.yml

然后使用以下方法进行处理:

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)

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

conda env create -f new_env.yml

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

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

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:

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_env is found incompatible or missing for the new python version.

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


如何使用.yml文件更新现有的Conda环境

问题:如何使用.yml文件更新现有的Conda环境

如何用另一个.yml文件更新先前的conda环境。在具有多个需求文件(例如)的项目上工作时,这非常有用base.yml, local.yml, production.yml

例如,下面是一个base.yml包含conda-forge,conda和pip软件包的文件:

碱基

name: myenv
channels:
  - conda-forge
dependencies:
  - django=1.10.5
  - pip:
    - django-crispy-forms==1.6.1

实际环境是使用创建的 conda env create -f base.yml

稍后,需要将其他软件包添加到中base.yml。另一个文件,例如local.yml,需要导入这些更新。

先前完成此任务的尝试包括:

创建local.yml具有导入定义的文件:

channels:

dependencies:
  - pip:
    - boto3==1.4.4
imports:
  - requirements/base. 

然后运行命令: conda install -f local.yml

这是行不通的。有什么想法吗?

How can a pre-existing conda environment be updated with another .yml file. This is extremely helpful when working on projects that have multiple requirement files, i.e. base.yml, local.yml, production.yml, etc.

For example, below is a base.yml file has conda-forge, conda, and pip packages:

base.yml

name: myenv
channels:
  - conda-forge
dependencies:
  - django=1.10.5
  - pip:
    - django-crispy-forms==1.6.1

The actual environment is created with: conda env create -f base.yml.

Later on, additional packages need to be added to base.yml. Another file, say local.yml, needs to import those updates.

Previous attempts to accomplish this include:

creating a local.yml file with an import definition:

channels:

dependencies:
  - pip:
    - boto3==1.4.4
imports:
  - requirements/base. 

And then run the command: conda install -f local.yml.

This does not work. Any thoughts?


回答 0

尝试使用conda env update

conda activate myenv
conda env update --file local.yml

或无需激活环境(感谢@NumesSanguis):

conda env update --name myenv --file local.yml

Try using conda env update:

conda activate myenv
conda env update --file local.yml

Or without the need to activate the environment (thanks @NumesSanguis):

conda env update --name myenv --file local.yml

回答 1

建议的答案部分正确。您需要添加–prune选项,以卸载从environment.yml中删除的软件包。正确的命令:

conda env update -f local.yml --prune

The suggested answer is partially correct. You’ll need to add the –prune option to also uninstall packages that were removed from the environment.yml. Correct command:

conda env update -f local.yml --prune

回答 2

alkamid的答案是正确的,但是我发现如果环境已经处于活动状态,则Conda无法安装新的依赖项。停用环境首先可以解决此问题:

source deactivate;
conda env update -f whatever.yml;
source activate my_environment_name; # Must be AFTER the conda env update line!

alkamid’s answer is on the right lines, but I have found that Conda fails to install new dependencies if the environment is already active. Deactivating the environment first resolves this:

source deactivate;
conda env update -f whatever.yml;
source activate my_environment_name; # Must be AFTER the conda env update line!

如何恢复到Anaconda中的先前软件包?

问题:如何恢复到Anaconda中的先前软件包?

如果我做

conda info pandas

我可以看到所有可用的软件包。

pandas今天上午将其更新为最新版本,但是现在我需要恢复到以前的版本。我试过了

conda update pandas 0.13.1

但这没用。如何指定要使用的版本?

If I do

conda info pandas

I can see all of the packages available.

I updated my pandas to the latest this morning, but I need to revert to a prior version now. I tried

conda update pandas 0.13.1

but that didn’t work. How do I specify which version to use?


回答 0

我不得不改用该install函数:

conda install pandas=0.13.1

I had to use the install function instead:

conda install pandas=0.13.1

回答 1

对于希望还原最近安装的软件包的情况,该软件包对依赖项进行了一些更改(例如tensorflow),可以通过以下方法“回滚”到较早的安装状态:

conda list --revisions
conda install --revision [revision number]

第一个命令显示以前的安装版本(带有依赖项),第二个命令还原到revision number您指定的版本。

请注意,如果您希望(重新)安装更高版本,则可能必须顺序重新安装所有中间版本。如果您的版本为23,重新安装了版本20,并希望返回,则可能必须运行每个版本:

conda install --revision 21
conda install --revision 22
conda install --revision 23

For the case that you wish to revert a recently installed package that made several changes to dependencies (such as tensorflow), you can “roll back” to an earlier installation state via the following method:

conda list --revisions
conda install --revision [revision number]

The first command shows previous installation revisions (with dependencies) and the second reverts to whichever revision number you specify.

Note that if you wish to (re)install a later revision, you may have to sequentially reinstall all intermediate versions. If you had been at revision 23, reinstalled revision 20 and wish to return, you may have to run each:

conda install --revision 21
conda install --revision 22
conda install --revision 23

Anaconda导出环境文件

问题:Anaconda导出环境文件

如何制作可以在其他计算机上使用的anaconda环境文件?

我使用将Anaconda python环境导出到YML conda env export > environment.yml。导出的environment.yml内容包含此行prefix: /home/superdev/miniconda3/envs/juicyenv,它映射到我的anaconda的位置,这在其他计算机上将有所不同。

How can I make anaconda environment file which could be use on other computers?

I exported my anaconda python environment to YML using conda env export > environment.yml. The exported environment.yml contains this line prefix: /home/superdev/miniconda3/envs/juicyenv which maps to my anaconda’s location which will be different on other’s pcs.


回答 0

我在conda规范中找不到任何可让您导出环境文件的内容prefix: ...。但是,正如Alex在评论中指出的那样,从文件创建环境时,conda似乎并不关心前缀行。

考虑到这一点,如果您希望其他用户不了解您的默认安装路径,则可以grep在写入之前删除前缀行environment.yml

conda env export | grep -v "^prefix: " > environment.yml

无论哪种方式,另一个用户都可以运行:

conda env create -f environment.yml

并且该环境将安装在其默认的conda环境路径中。

如果您要指定与系统默认设置不同的安装路径(与environment.yml中的’prefix’不相关),只需使用-p标记后跟所需的路径即可。

conda env create -f environment.yml -p /home/user/anaconda3/envs/env_name

请注意,Conda建议environment.yml手动创建,这对于要跨平台(Windows / Linux / Mac)共享环境的用户尤其重要。在这种情况下,您可以省略该prefix行。

I can’t find anything in the conda specs which allow you to export an environment file without the prefix: ... line. However, as Alex pointed out in the comments, conda doesn’t seem to care about the prefix line when creating an environment from file.

With that in mind, if you want the other user to have no knowledge of your default install path, you can remove the prefix line with grep before writing to environment.yml.

conda env export | grep -v "^prefix: " > environment.yml

Either way, the other user then runs:

conda env create -f environment.yml

and the environment will get installed in their default conda environment path.

If you want to specify a different install path than the default for your system (not related to ‘prefix’ in the environment.yml), just use the -p flag followed by the required path.

conda env create -f environment.yml -p /home/user/anaconda3/envs/env_name

Note that Conda recommends creating the environment.yml by hand, which is especially important if you are wanting to share your environment across platforms (Windows/Linux/Mac). In this case, you can just leave out the prefix line.


回答 1

从要安装在另一台计算机上的环境中保存软件包的最简单方法是:

$ conda list -e > req.txt

然后您可以使用安装环境

$ conda create -n new environment --file req.txt

如果使用pip,请使用以下命令:reference https://pip.pypa.io/en/stable/reference/pip_freeze/

$ env1/bin/pip freeze > requirements.txt
$ env2/bin/pip install -r requirements.txt

The easiest way to save the packages from an environment to be installed in another computer is:

$ conda list -e > req.txt

then you can install the environment using

$ conda create -n new environment --file req.txt

if you use pip, please use the following commands: reference https://pip.pypa.io/en/stable/reference/pip_freeze/

$ env1/bin/pip freeze > requirements.txt
$ env2/bin/pip install -r requirements.txt

回答 2

  • 的Linux

    conda env导出-无构建| grep -v“前缀”> environment.yml

  • 视窗

    conda env export –no-builds | findstr -v“前缀”> environment.yml


基本原理:默认情况下,conda env export包括构建信息:

$ conda env export
...
dependencies:
  - backcall=0.1.0=py37_0
  - blas=1.0=mkl
  - boto=2.49.0=py_0
...

您可以转而无需构建信息即可导出环境:

$ conda env export --no-builds
...
dependencies:
  - backcall=0.1.0
  - blas=1.0
  - boto=2.49.0
...

这使环境与Python版本和OS脱钩。

  • Linux

    conda env export –no-builds | grep -v “prefix” > environment.yml

  • Windows

    conda env export –no-builds | findstr -v “prefix” > environment.yml


Rationale: By default, conda env export includes the build information:

$ conda env export
...
dependencies:
  - backcall=0.1.0=py37_0
  - blas=1.0=mkl
  - boto=2.49.0=py_0
...

You can instead export your environment without build info:

$ conda env export --no-builds
...
dependencies:
  - backcall=0.1.0
  - blas=1.0
  - boto=2.49.0
...

Which unties the environment from the Python version and OS.


回答 3

我发现仅以字符串格式导出软件包比导出整个conda环境更方便。正如前面的答案已经建议的那样:

$ conda list -e > requirements.txt

但是,它requirements.txt包含内部版本号,这些版本号在操作系统之间(例如Mac和之间)不可移植Ubuntu。在conda env export我们可以选择--no-builds但没有的情况下conda list -e,因此我们可以通过发出以下命令来删除内部版本号:

$ sed -i -E "s/^(.*\=.*)(\=.*)/\1/" requirements.txt 

并在另一台计算机上重新创建环境:

conda create -n recreated_env --file requirements.txt 

I find exporting the packages in string format only is more portable than exporting the whole conda environment. As the previous answer already suggested:

$ conda list -e > requirements.txt

However, this requirements.txt contains build numbers which are not portable between operating systems, e.g. between Mac and Ubuntu. In conda env export we have the option --no-builds but not with conda list -e, so we can remove the build number by issuing the following command:

$ sed -i -E "s/^(.*\=.*)(\=.*)/\1/" requirements.txt 

And recreate the environment on another computer:

conda create -n recreated_env --file requirements.txt 

回答 4

  1. 首先激活您的conda环境(您要导出/备份的环境)
conda activate myEnv
  1. 将所有包导出到文件(myEnvBkp.txt)
conda list --explicit > myEnvBkp.txt
  1. 恢复/导入环境:
conda create --name myEnvRestored --file myEnvBkp.txt
  1. First activate your conda environment (the one u want to export/backup)
conda activate myEnv
  1. Export all packages to a file (myEnvBkp.txt)
conda list --explicit > myEnvBkp.txt
  1. Restore/import the environment:
conda create --name myEnvRestored --file myEnvBkp.txt

是否应将conda或conda-forge用于Python环境?

问题:是否应将conda或conda-forge用于Python环境?

Conda并且conda-forge都是Python软件包管理器。当两个存储库中都存在一个程序包时,合适的选择是什么?例如,Django可以安装其中之一,但是两者之间的区别是几个依赖项(conda-forge还有更多)。对于这些差异没有任何解释,甚至没有简单的自述文件。

应该使用哪一个?康达或康达伪造?有关系吗?

Conda and conda-forge are both Python package managers. What is the appropriate choice when a package exists in both repositories? Django, for example, can be installed with either, but the difference between the two is several dependencies (conda-forge has many more). There is no explanation for these differences, not even a simple README.

Which one should be used? Conda or conda-forge? Does it matter?


回答 0

简短的回答是,根据我的经验,通常使用哪种都无关紧要。

长答案:

所以conda-forge是可以从其中安装的软件包的附加通道。从这个意义上讲,它没有比默认频道更特别,也没有其他任何人将软件包发布到的频道(数千个)中的任何一个。如果您在https://anaconda.org上注册并上传自己的Conda软件包,则可以添加自己的频道。

在这里,我们需要进行区分,我认为您对问题的措辞不清楚conda,即跨平台的程序包管理器和conda-forge程序包通道之间。该conda软件的主要开发人员Anaconda Inc.(以前称为Continuum IO)也维护一个单独的软件包频道,这是您在conda install packagename不更改任何选项的情况下键入的默认软件包。

有三种方法可以更改频道选项。每次安装软件包时,前两个步骤都会完成,而后一个则是持久性的。第一个是在每次安装软件包时指定一个通道:

conda install -c some-channel packagename

当然,该程序包必须存在于该通道上。这样将从进行安装packagename及其所有依赖项some-channel。或者,您可以指定:

conda install some-channel::packagename

该程序包仍然必须存在some-channel,但现在只能packagename从中提取some-channel。可以从您的默认频道列表中搜索满足依赖关系所需的任何其他软件包。

要查看您的频道配置,您可以编写:

conda config --show channels

您可以使用来控制搜索频道的顺序conda config。你可以写:

conda config --add channels some-channel

将通道添加some-channelchannels配置列表的顶部。这具有some-channel最高的优先级。当一个以上通道具有特定程序包时,优先级(部分)确定选择哪个通道。要将频道添加到列表的末尾并赋予其最低的优先级,请输入

conda config --append channels some-channel

如果您想删除添加的频道,可以通过以下方式删除

conda config --remove channels some-channel

看到

conda config -h

有关更多选项。

综上所述,使用conda-forge频道而不是defaultsAnaconda维护频道的主要原因有四个:

  1. 上的软件包conda-forge 可能defaults频道上的软件包最新
  2. conda-forge频道上的某些软件包无法从defaults
  3. 您可能希望使用诸如openblas(from conda-forge)而不是mkl(from defaults)的依赖项。
  4. 如果要安装需要编译库的软件包(例如,C扩展名或C库的包装器),则由于二进制原因,如果从单个通道在环境中安装所有软件包,则可能会减少不兼容的可能性。基本C库的兼容性(但是此建议可能会过时/将来会更改)。

The short answer is that, in my experience generally, it doesn’t matter which you use.

The long answer:

So conda-forge is an additional channel from which packages may be installed. In this sense, it is not any more special than the default channel, or any of the other hundreds (thousands?) of channels that people have posted packages to. You can add your own channel if you sign up at https://anaconda.org and upload your own Conda packages.

Here we need to make the distinction, which I think you’re not clear about from your phrasing in the question, between conda, the cross-platform package manager, and conda-forge, the package channel. Anaconda Inc. (formerly Continuum IO), the main developers of the conda software, also maintain a separate channel of packages, which is the default when you type conda install packagename without changing any options.

There are three ways to change the options for channels. The first two are done every time you install a package and the last one is persistent. The first one is to specify a channel every time you install a package:

conda install -c some-channel packagename

Of course, the package has to exist on that channel. This way will install packagename and all its dependencies from some-channel. Alternately, you can specify:

conda install some-channel::packagename

The package still has to exist on some-channel, but now, only packagename will be pulled from some-channel. Any other packages that are needed to satisfy dependencies will be searched for from your default list of channels.

To see your channel configuration, you can write:

conda config --show channels

You can control the order that channels are searched with conda config. You can write:

conda config --add channels some-channel

to add the channel some-channel to the top of the channels configuration list. This gives some-channel the highest priority. Priority determines (in part) which channel is selected when more than one channel has a particular package. To add the channel to the end of the list and give it the lowest priority, type

conda config --append channels some-channel

If you would like to remove the channel that you added, you can do so by writing

conda config --remove channels some-channel

See

conda config -h

for more options.

With all of that said, there are four main reasons to use the conda-forge channel instead of the defaults channel maintained by Anaconda:

  1. Packages on conda-forge may be more up-to-date than those on the defaults channel
  2. There are packages on the conda-forge channel that aren’t available from defaults
  3. You would prefer to use a dependency such as openblas (from conda-forge) instead of mkl (from defaults).
  4. If you are installing a package that requires a compiled library (e.g., a C extension or a wrapper around a C library), it may reduce the chance of incompatibilities if you install all of the packages in an environment from a single channel due to binary compatibility of the base C library (but this advice may be out of date/change in the future).

回答 1

Anaconda更改了服务条款,以使“大量商业用户”需要付费,其中不包括conda-forge渠道。

conda-forge如果您不想为使用付费,则可能要坚持。如文档所述

conda config --add channels conda-forge
conda config --set channel_priority strict
conda install <package-name>

你也可以使用miniforge具有conda-forge作为默认的通道,并支持ppc64le和aarch64平台,以及其他常用的。

Anaconda has changed their Terms of Service so that “heavy commercial users” would have to pay, which doesn’t include conda-forge channel.

You probably would want to stick to conda-forge if you don’t want to pay for the usage. As stated in the docs:

conda config --add channels conda-forge
conda config --set channel_priority strict
conda install <package-name>

You could also use miniforge which has conda-forge as the default channel, and supports ppc64le and aarch64 platforms as well as the other usual ones.


回答 2

在conda-forge渠道中,您可以找到针对conda构建的软件包,但尚未成为Anaconda官方发行版的一部分。

通常,您可以使用其中任何一个。

The conda-forge channel is where you can find packages that have been built for conda but yet to be part of the official Anaconda distribution.

Generally, you can use any of them.


回答 3

有些Python库无法简单安装,conda install因为除非应用conda-forge,否则它们的通道不可用。根据我的经验,与conda相比,pip更通用于研究不同的渠道来源。例如,如果要安装python-constraint,可以通过,pip install但可以通过** cond **进行安装。您必须指定频道- conda-forge

conda install -c conda-forge python-constraint // works

但不是

conda install python-constraint

There are some Python libraries that you cannot install with a simple conda install since their channel is not available unless you apply conda-forge. From my experience, pip is more generic to look into different channel sources than conda. For instance, if you want to install python-constraint you can do it via pip install but to install it via **cond **. you have to specify the channel – conda-forge.

conda install -c conda-forge python-constraint // works

but not

conda install python-constraint

Conda和Anaconda有什么区别?

问题:Conda和Anaconda有什么区别?

问题后更新:

有关更多详细信息,请参见《 Conda简介》


问题:

当我尝试更新anaconda时,我首先在ubuntu上安装了Anaconda~/anaconda,根据Continuum Analytics 的文档,我应该使用以下命令:

conda update conda
conda update anaconda

然后我意识到我没有安装conda,因此我使用此处的文档进行了安装。

安装conda后,当我运行时conda update anaconda,出现以下错误:

错误:/ home / xiang / miniconda中未安装软件包“ anaconda”

似乎conda假定我的anaconda已安装,/home/xiang/miniconda但事实并非如此。

问题:

  1. condaanaconda有什么区别?
  2. 如何告诉conda我的Anaconda安装在哪里?

Post-question update:

See Introduction to Conda for more details.


The problem:

I first installed Anaconda on my ubuntu at ~/anaconda, when I was trying to update my anaconda, according to the documentation from Continuum Analytics, I should use the following commands:

conda update conda
conda update anaconda

Then I realized that I did not have conda installed, so I installed it using the documentation from here.

After conda is installed, when I run conda update anaconda, I got the following error:

Error: package ‘anaconda’ is not installed in /home/xiang/miniconda

It appears conda is assuming my anaconda is installed under /home/xiang/miniconda which is NOT true.

The questions:

  1. What are the differences between conda and anaconda?
  2. How can I tell conda where my anaconda is installed?

回答 0

conda是程序包管理器。Anaconda是一组大约一百个程序包,包括conda,numpy,scipy,ipython notebook等。

您安装了Miniconda,这是Anaconda的一个较小替代方案,它只是conda及其依赖项,而不是上面列出的依赖项。

拥有Miniconda之后,您可以使用轻松地将Anaconda安装到其中conda install anaconda

conda is the package manager. Anaconda is a set of about a hundred packages including conda, numpy, scipy, ipython notebook, and so on.

You installed Miniconda, which is a smaller alternative to Anaconda that is just conda and its dependencies, not those listed above.

Once you have Miniconda, you can easily install Anaconda into it with conda install anaconda.


回答 1

简要

conda 既是命令行工具,又是python包。

Miniconda安装程序= Python + conda

Anaconda安装程序= Python conda++ meta包anaconda

meta Python pkg anaconda=约160个其他Python日常使用的软件包

Anaconda安装程序= Miniconda安装程序+ conda install anaconda

详情

conda是环境经理和程序包经理。这意味着工具本身。conda使有可能

  • 安装软件包 conda install flake8
  • 使用任何版本的Python创建环境 conda create -n myenv python=3.6

conda不是二进制命令,而是Python包。要进行conda工作,您必须创建一个Python环境并将软件包安装conda到其中。这是Anaconda安装程序和Miniconda安装程序进入的地方。

安装程序Minoconda将安装Python和软件包conda。安装程序Anaconda不仅会执行Miniconda的操作,还会安装一个为您命名的meta Python软件包anaconda

元软件包是不包含实际软件的软件包,仅依赖于要安装的其他软件包。

pkg anaconda中包含的实际160多个python软件包info/recipe/meta.yaml在其源文件中列出。

package:
    name: anaconda
    version: '2019.07'
build:
    ignore_run_exports:
        - '*'
    number: '0'
    pin_depends: strict
    string: py36_0
requirements:
    build:
        - python 3.6.8 haf84260_0
    is_meta_pkg:
        - true
    run:
        - alabaster 0.7.12 py36_0
        - anaconda-client 1.7.2 py36_0
        - anaconda-project 0.8.3 py_0
        # ...
        - beautifulsoup4 4.7.1 py36_1
        # ...
        - curl 7.65.2 ha441bb4_0
        # ...
        - hdf5 1.10.4 hfa1e0ec_0
        # ...
        - ipykernel 5.1.1 py36h39e3cac_0
        - ipython 7.6.1 py36h39e3cac_0
        - ipython_genutils 0.2.0 py36h241746c_0
        - ipywidgets 7.5.0 py_0
        # ...
        - jupyter 1.0.0 py36_7
        - jupyter_client 5.3.1 py_0
        - jupyter_console 6.0.0 py36_0
        - jupyter_core 4.5.0 py_0
        - jupyterlab 1.0.2 py36hf63ae98_0
        - jupyterlab_server 1.0.0 py_0
        # ...
        - matplotlib 3.1.0 py36h54f8f79_0
        # ...
        - mkl 2019.4 233
        - mkl-service 2.0.2 py36h1de35cc_0
        - mkl_fft 1.0.12 py36h5e564d8_0
        - mkl_random 1.0.2 py36h27c97d8_0
        # ...
        - nltk 3.4.4 py36_0
        # ...
        - numpy 1.16.4 py36hacdab7b_0
        - numpy-base 1.16.4 py36h6575580_0
        - numpydoc 0.9.1 py_0
        # ...
        - pandas 0.24.2 py36h0a44026_0
        - pandoc 2.2.3.2 0
        # ...
        - pillow 6.1.0 py36hb68e598_0
        # ...
        - pyqt 5.9.2 py36h655552a_2
        # ...
        - qt 5.9.7 h468cd18_1
        - qtawesome 0.5.7 py36_1
        - qtconsole 4.5.1 py_0
        - qtpy 1.8.0 py_0
        # ...
        - requests 2.22.0 py36_0
        # ...
        - sphinx 2.1.2 py_0
        - sphinxcontrib 1.0 py36_1
        - sphinxcontrib-applehelp 1.0.1 py_0
        - sphinxcontrib-devhelp 1.0.1 py_0
        - sphinxcontrib-htmlhelp 1.0.2 py_0
        - sphinxcontrib-jsmath 1.0.1 py_0
        - sphinxcontrib-qthelp 1.0.2 py_0
        - sphinxcontrib-serializinghtml 1.1.3 py_0
        - sphinxcontrib-websupport 1.1.2 py_0
        - spyder 3.3.6 py36_0
        - spyder-kernels 0.5.1 py36_0
        # ...

来自meta pkg的预安装软件包anaconda主要用于Web抓取和数据科学。像requestsbeautifulsoupnumpynltk,等。

Brief

conda is both a command line tool, and a python package.

Miniconda installer = Python + conda

Anaconda installer = Python + conda + meta package anaconda

meta Python pkg anaconda = about 160 other Python packages for daily use in data science

Anaconda installer = Miniconda installer + conda install anaconda

Detail

conda is an environment manager and a package manager. It means the tool itself. conda makes it possible to

  • install package with conda install flake8
  • create an environment with any version of Python with conda create -n myenv python=3.6

conda is not a binary command, is a Python package. To make conda work, you have to create a Python environment and install package conda into it. This is where Anaconda installer and Miniconda installer comes in.

Installer Minoconda installs a Python and the package conda. Installer Anaconda not only does what Miniconda does, it also install a meta Python package named anaconda for you.

Meta packages, are packages that do NOT contain actual softwares and simply depend on other packages to be installed.

The actual 160+ python packages included in pkg anaconda are listed in info/recipe/meta.yaml in its source file.

package:
    name: anaconda
    version: '2019.07'
build:
    ignore_run_exports:
        - '*'
    number: '0'
    pin_depends: strict
    string: py36_0
requirements:
    build:
        - python 3.6.8 haf84260_0
    is_meta_pkg:
        - true
    run:
        - alabaster 0.7.12 py36_0
        - anaconda-client 1.7.2 py36_0
        - anaconda-project 0.8.3 py_0
        # ...
        - beautifulsoup4 4.7.1 py36_1
        # ...
        - curl 7.65.2 ha441bb4_0
        # ...
        - hdf5 1.10.4 hfa1e0ec_0
        # ...
        - ipykernel 5.1.1 py36h39e3cac_0
        - ipython 7.6.1 py36h39e3cac_0
        - ipython_genutils 0.2.0 py36h241746c_0
        - ipywidgets 7.5.0 py_0
        # ...
        - jupyter 1.0.0 py36_7
        - jupyter_client 5.3.1 py_0
        - jupyter_console 6.0.0 py36_0
        - jupyter_core 4.5.0 py_0
        - jupyterlab 1.0.2 py36hf63ae98_0
        - jupyterlab_server 1.0.0 py_0
        # ...
        - matplotlib 3.1.0 py36h54f8f79_0
        # ...
        - mkl 2019.4 233
        - mkl-service 2.0.2 py36h1de35cc_0
        - mkl_fft 1.0.12 py36h5e564d8_0
        - mkl_random 1.0.2 py36h27c97d8_0
        # ...
        - nltk 3.4.4 py36_0
        # ...
        - numpy 1.16.4 py36hacdab7b_0
        - numpy-base 1.16.4 py36h6575580_0
        - numpydoc 0.9.1 py_0
        # ...
        - pandas 0.24.2 py36h0a44026_0
        - pandoc 2.2.3.2 0
        # ...
        - pillow 6.1.0 py36hb68e598_0
        # ...
        - pyqt 5.9.2 py36h655552a_2
        # ...
        - qt 5.9.7 h468cd18_1
        - qtawesome 0.5.7 py36_1
        - qtconsole 4.5.1 py_0
        - qtpy 1.8.0 py_0
        # ...
        - requests 2.22.0 py36_0
        # ...
        - sphinx 2.1.2 py_0
        - sphinxcontrib 1.0 py36_1
        - sphinxcontrib-applehelp 1.0.1 py_0
        - sphinxcontrib-devhelp 1.0.1 py_0
        - sphinxcontrib-htmlhelp 1.0.2 py_0
        - sphinxcontrib-jsmath 1.0.1 py_0
        - sphinxcontrib-qthelp 1.0.2 py_0
        - sphinxcontrib-serializinghtml 1.1.3 py_0
        - sphinxcontrib-websupport 1.1.2 py_0
        - spyder 3.3.6 py36_0
        - spyder-kernels 0.5.1 py36_0
        # ...

The pre-installed packages from meta pkg anaconda are mainly for web scraping and data science. Like requests, beautifulsoup, numpy, nltk, etc.


无法将“ Conda”识别为内部或外部命令

问题:无法将“ Conda”识别为内部或外部命令

我在Windows 7 Professional计算机上安装了Anaconda3 4.4.0(32位),并在Jupyter笔记本电脑上导入了NumPy和Pandas,因此我认为Python已正确安装。但是当我键入conda listconda --version在命令提示符下时,它说conda is not recognized as internal or external command.

我已经为Anaconda3设置了环境变量;Variable Name: PathVariable Value: C:\Users\dipanwita.neogy\Anaconda3

我该如何运作?

I installed Anaconda3 4.4.0 (32 bit) on my Windows 7 Professional machine and imported NumPy and Pandas on Jupyter notebook so I assume Python was installed correctly. But when I type conda list and conda --version in command prompt, it says conda is not recognized as internal or external command.

I have set environment variable for Anaconda3; Variable Name: Path, Variable Value: C:\Users\dipanwita.neogy\Anaconda3

How do I make it work?


回答 0

尽管其他人为您提供了很好的解决方案,但我认为指出实际情况会有所帮助。根据Anaconda 4.4更改日志,https : //docs.anaconda.com/anaconda/reference/release-notes/#what-s-new-in-anaconda-4-4 :

在Windows上,默认情况下不再更改PATH环境变量,因为这可能导致其他软件出现问题。建议的方法是,当您希望使用Anaconda软件时,改用Anaconda Navigator或Anaconda命令提示符(位于“ Anaconda”下的“开始”菜单中)。

(注意:最近的Win 10并不假定您具有安装或更新的特权。如果命令失败,请右键单击Anaconda命令提示符,选择“更多”,选择“以管理员身份运行”)

这是对先前安装的更改。尽管您也可以随时将其添加到PATH中,但建议使用Navigator或Anaconda Prompt。在安装过程中,现在没有选中将Anaconda添加到PATH的框,但是您可以选择它。

Although you were offered a good solution by others I think it is helpful to point out what is really happening. As per the Anaconda 4.4 changelog, https://docs.anaconda.com/anaconda/reference/release-notes/#what-s-new-in-anaconda-4-4:

On Windows, the PATH environment variable is no longer changed by default, as this can cause trouble with other software. The recommended approach is to instead use Anaconda Navigator or the Anaconda Command Prompt (located in the Start Menu under “Anaconda”) when you wish to use Anaconda software.

(Note: recent Win 10 does not assume you have privileges to install or update. If the command fails, right-click on the Anaconda Command Prompt, choose “More”, chose “Run as administrator”)

This is a change from previous installations. It is suggested to use Navigator or the Anaconda Prompt although you can always add it to your PATH as well. During the install the box to add Anaconda to the PATH is now unchecked but you can select it.


回答 1

我在Windows 10中遇到了同样的问题,请按照以下步骤更新环境变量,它可以正常工作。

我知道这对于简单的环境设置来说是一个冗长的答案,我认为这对于新窗口10用户可能有用。

1)打开Anaconda提示:

2)检查Conda安装位置。

where conda

3)打开高级系统设置

4)点击环境变量

5)编辑路径

6)添加新路径

 C:\Users\RajaRama\Anaconda3\Scripts

 C:\Users\RajaRama\Anaconda3

 C:\Users\RajaRama\Anaconda3\Library\bin

7)打开命令提示符并检查版本

8)在第7步键入conda之后,在cmd中安装anaconda-navigator,然后按y

I was faced with the same issue in windows 10, Updating the environment variable following steps, it’s working fine.

I know It is a lengthy answer for the simple environment setups, I thought it’s may be useful for the new window 10 users.

1) Open Anaconda Prompt:

2) Check Conda Installed Location.

where conda

3) Open Advanced System Settings

4) Click on Environment Variables

5) Edit Path

6) Add New Path

 C:\Users\RajaRama\Anaconda3\Scripts

 C:\Users\RajaRama\Anaconda3

 C:\Users\RajaRama\Anaconda3\Library\bin

7) Open Command Prompt and Check Versions

8) After 7th step type conda install anaconda-navigator in cmd then press y


回答 2

我找到了解决方案。可变值应为C:\Users\dipanwita.neogy\Anaconda3\Scripts

I found the solution. Variable value should be C:\Users\dipanwita.neogy\Anaconda3\Scripts


回答 3

现在在Windows上安装anaconda时,它不会自动将Python或Conda添加到您的路径中。

在安装过程中,您可以选中此框,也可以将python和/或python手动添加到路径中(如下面的图片所示)

如果您不知道您的conda和/或python在哪里,请在anaconda提示符下键入以下命令

where python
where conda

接下来,您可以通过在命令提示符下使用setx命令将Python和Conda添加到您的路径中(替换C:\Users\mgalarnyk\Anaconda2为运行时获得的结果where pythonwhere conda)。

SETX PATH "%PATH%;C:\Users\mgalarnyk\Anaconda2\Scripts;C:\Users\mgalarnyk\Anaconda2"

接下来,关闭该命令提示符并打开一个新命令。恭喜您现在可以使用conda和python

来源:https : //medium.com/@GalarnykMichael/install-python-on-windows-anaconda-c63c7c3d1444

When you install anaconda on windows now, it doesn’t automatically add Python or Conda to your path.

While during the installation process you can check this box, you can also add python and/or python to your path manually (as you can see below the image)

If you don’t know where your conda and/or python is, you type the following commands into your anaconda prompt

where python
where conda

Next, you can add Python and Conda to your path by using the setx command in your command prompt (replace C:\Users\mgalarnyk\Anaconda2 with the results you got when running where python and where conda).

SETX PATH "%PATH%;C:\Users\mgalarnyk\Anaconda2\Scripts;C:\Users\mgalarnyk\Anaconda2"

Next close that command prompt and open a new one. Congrats you can now use conda and python

Source: https://medium.com/@GalarnykMichael/install-python-on-windows-anaconda-c63c7c3d1444


回答 4

为了清楚起见,您需要转到controlpanel\System\Advanced system settings\Environment Variables\Path,然后点击编辑并添加:

C:Users\user.user\Anaconda3\Scripts

到最后并重新启动cmd行

Just to be clear, you need to go to the controlpanel\System\Advanced system settings\Environment Variables\Path, then hit edit and add:

C:Users\user.user\Anaconda3\Scripts

to the end and restart the cmd line


回答 5

如果您有较新版本的Anaconda Navigator,请打开安装中附带的Anaconda Prompt程序。在此处输入所有常用的conda update/ conda install命令。

我认为上面的答案可以解释这一点,但是我可以使用这样一个非常简单的指令。也许会帮助别人。

If you have a newer version of the Anaconda Navigator, open the Anaconda Prompt program that came in the install. Type all the usual conda update/conda install commands there.

I think the answers above explain this, but I could have used a very simple instruction like this. Perhaps it will help others.


回答 6

除了添加C:\Users\yourusername\Anaconda3和之外C:\Users\yourusername\Anaconda3\Scripts(如Raja所建议的那样),还将添加C:\Users\yourusername\Anaconda3\Library\bin到您的path变量中。如果您是在全新安装的Anaconda上执行此操作,则可以防止发生SSL错误。

In addition to adding C:\Users\yourusername\Anaconda3 and C:\Users\yourusername\Anaconda3\Scripts, as recommended by Raja (above), also add C:\Users\yourusername\Anaconda3\Library\bin to your path variable. This will prevent an SSL error that is bound to happen if you’re performing this on a fresh install of Anaconda.


回答 7

转到anaconda提示符(在笔记本电脑的搜索框中键入“ anaconda”)。输入以下命令

where conda

将该位置添加到您的环境路径变量中。关闭cmd,然后再次打开

Go To anaconda prompt(type “anaconda” in search box in your laptop). type following commands

where conda

add that location to your environment path variables. Close the cmd and open it again


回答 8

如果您不想将Anaconda添加到环境中。路径,并且您正在使用Windows,请尝试以下操作:

  • 打开cmd;
  • 键入文件夹安装的路径。就像这样:C:\ Users \ your_home文件夹\ Anaconda3 \ Scripts
  • 测试Anaconda,例如conda –version类型。
  • 更新Anaconda:conda更新conda或conda更新-全部或conda更新anaconda。

更新Spyder:

  • 康达更新qt pyqt
  • 康达更新间谍

If you don’t want to add Anaconda to env. path and you are using Windows try this:

  • Open cmd;
  • Type path to your folder instalation. It’s something like: C:\Users\your_home folder\Anaconda3\Scripts
  • Test Anaconda, for exemple type conda –version.
  • Update Anaconda: conda update conda or conda update –all or conda update anaconda.

Update Spyder:

  • conda update qt pyqt
  • conda update spyder

回答 9

我有Windows 10 64位,这对我有用此解决方案可以在两种(Anaconda / MiniConda)发行版中都可以使用。

  1. 首先,尝试卸载引起问题的anaconda / miniconda
  2. 之后,从“ C:\ Users \”删除“ .anaconda”和“ .conda”文件夹
  3. 如果您有任何杀毒软件装然后尝试排除所有文件夹,子文件夹内的“C:\ ProgramData \ Anaconda3 \”

    • 行为检测。
    • 病毒检测。
    • DNA扫描。
    • 可疑文件扫描。
    • 任何其他病毒防护模式。

    *(注意:“ C:\ ProgramData \ Anaconda3”此文件夹是默认安装文件夹,您可以在安装Anaconda时更改它,仅在安装目标位置提示处替换排除的路径)*

  4. 现在,以管理员权限安装Anaconda。
    • 将安装路径设置为“ C:\ ProgramData \ Anaconda3”或者您可以指定自定义路径,只是要记住该路径不应包含任何空格,并且应将其从病毒检测中排除。
    • 在“高级安装选项”中,您可以选中“将Anaconda添加到我的PATH环境变量(可选)”和“将Anaconda注册为我的默认Python 3.6”
    • 使用其他默认设置进行安装。完成后单击完成。
    • 重启你的电脑。

现在打开命令提示符或Anaconda提示符并使用以下命令检查安装

康达清单

如果您获得任何软件包列表,则表明anaconda / miniconda已成功安装。

I have Windows 10 64 bit, this worked for me, This solution can work for both (Anaconda/MiniConda) distributions.

  1. First of all try to uninstall anaconda/miniconda which is causing problem.
  2. After that delete ‘.anaconda’ and ‘.conda’ folders from ‘C:\Users\’
  3. If you have any antivirus software installed then try to exclude all the folders,subfolders inside ‘C:\ProgramData\Anaconda3\’ from

    • Behaviour detection.
    • Virus detection.
    • DNA scan.
    • Suspicious files scan.
    • Any other virus protection mode.

    *(Note: ‘C:\ProgramData\Anaconda3’ this folder is default installation folder, you can change it just replace your excluded path at installation destination prompt while installing Anaconda)*

  4. Now install Anaconda with admin privileges.
    • Set the installation path as ‘C:\ProgramData\Anaconda3’ or you can specify your custom path just remember it should not contain any white space and it should be excluded from virus detection.
    • At Advanced Installation Options you can check “Add Anaconda to my PATH environment variable(optional)” and “Register Anaconda as my default Python 3.6”
    • Install it with further default settings. Click on finish after done.
    • Restart your computer.

Now open Command prompt or Anaconda prompt and check installation using following command

conda list

If you get any package list then the anaconda/miniconda is successfully installed.


回答 10

当我多次安装Anaconda时,这个问题对我来说就出现了。我很小心地进行了卸载,但是有些事情卸载过程不会撤消。

就我而言,我需要删除一个文件Microsoft.PowerShell_profile.ps1~\Documents\WindowsPowerShell\。通过在文本编辑器中将其打开,我确定了该文件是罪魁祸首。我看到它引用了旧的安装位置C:\Anaconda3\

This problem arose for me when I installed Anaconda multiple times. I was careful to do an uninstall but there are some things that the uninstall process doesn’t undo.

In my case, I needed to remove a file Microsoft.PowerShell_profile.ps1 from ~\Documents\WindowsPowerShell\. I identified that this file was the culprit by opening it in a text editor. I saw that it referenced the old installation location C:\Anaconda3\.


回答 11

我刚刚启动了anaconda-navigator并从那里运行conda命令。

I have just launched anaconda-navigator and run the conda commands from there.


回答 12

我在Windows中遇到了这个问题。大多数答案都不是anaconda推荐的,您不应将路径添加到环境变量中,因为它可能会破坏其他内容。相反,您应该使用顶部答案中提到的anaconda提示符。

但是,这也可能会中断。在这种情况下,右键单击快捷方式,转到快捷方式选项卡,目标值应类似于:

%windir%\System32\cmd.exe "/K" C:\Users\myUser\Anaconda3\Scripts\activate.bat C:\Users\myUser\Anaconda3

I had this problem in windows. Most of the answers are not as recommended by anaconda, you should not add the path to the environment variables as it can break other things. Instead you should use anaconda prompt as mentioned in the top answer.

However, this may also break. In this case right click on the shortcut, go to shortcut tab, and the target value should read something like:

%windir%\System32\cmd.exe "/K" C:\Users\myUser\Anaconda3\Scripts\activate.bat C:\Users\myUser\Anaconda3

Conda:直接从github安装/升级

问题:Conda:直接从github安装/升级

我可以使用conda从GitHub安装/升级软件包吗?

例如,pip我可以这样做:

pip install git+git://github.com/scrappy/scrappy@master

scrappy直接从masterGitHub中的分支安装。我可以用conda做一些等效的事情吗?

如果这不可能,那么用conda安装pip并使用pip管理此类本地安装是否有意义?

Can I install/upgrade packages from GitHub using conda?

For example, with pip I can do:

pip install git+git://github.com/scrappy/scrappy@master

to install scrappy directly from the master branch in GitHub. Can I do something equivalent with conda?

If this is not possible, would it make any sense to install pip with conda and manage such local installations with pip?


回答 0

现在,对此有了更好的支持conda-env。例如,您现在可以执行以下操作:

name: sample_env
channels:
dependencies:
   - requests
   - bokeh>=0.10.0
   - pip:
     - "--editable=git+https://github.com/pythonforfacebook/facebook-sdk.git@8c0d34291aaafec00e02eaa71cc2a242790a0fcc#egg=facebook_sdk-master"

它仍然在后台调用pip,但是您现在可以在一个environment.yml文件中统一conda和pip软件包的规范。

如果要使用此文件更新根环境,则需要将其保存到文件中(例如environment.yml),然后运行命令:conda env update -f environment.yml

您更可能想创建一个新环境:

conda env create -f environment.yml (已按评论中的假设进行了更改)

There’s better support for this now through conda-env. You can, for example, now do:

name: sample_env
channels:
dependencies:
   - requests
   - bokeh>=0.10.0
   - pip:
     - "--editable=git+https://github.com/pythonforfacebook/facebook-sdk.git@8c0d34291aaafec00e02eaa71cc2a242790a0fcc#egg=facebook_sdk-master"

It’s still calling pip under the covers, but you can now unify your conda and pip package specifications in a single environment.yml file.

If you wanted to update your root environment with this file, you would need to save this to a file (for example, environment.yml), then run the command: conda env update -f environment.yml.

It’s more likely that you would want to create a new environment:

conda env create -f environment.yml (changed as supposed in the comments)


回答 1

答案已经过时了。您只需要conda安装pip和git。然后您可以正常使用pip:

  1. 激活您的conda环境 source activate myenv

  2. conda install git pip

  3. pip install git+git://github.com/scrappy/scrappy@master

The answers are outdated. You simply have to conda install pip and git. Then you can use pip normally:

  1. Activate your conda environment source activate myenv

  2. conda install git pip

  3. pip install git+git://github.com/scrappy/scrappy@master


回答 2

conda不直接支持此功能,因为它是从二进制文件安装的,而git install是从源代码安装的。conda build确实支持从git构建的配方。另一方面,如果您要做的只是保持最新和最新的软件包,则在Anaconda中使用pip很好,或者替代地,setup.py develop对git克隆使用。

conda doesn’t support this directly because it installs from binaries, whereas git install would be from source. conda build does support recipes that are built from git. On the other hand, if all you want to do is keep up-to-date with the latest and greatest of a package, using pip inside of Anaconda is just fine, or alternately, use setup.py develop against a git clone.


回答 3

我在condas问题中找到了对此的参考。现在应该可以进行以下操作。

name: sample_env
channels:
dependencies:
   - requests
   - bokeh>=0.10.0
   - pip:
     - git+https://github.com/pythonforfacebook/facebook-sdk.git

I found a reference to this in condas issues. The following should now work.

name: sample_env
channels:
dependencies:
   - requests
   - bokeh>=0.10.0
   - pip:
     - git+https://github.com/pythonforfacebook/facebook-sdk.git

结合conda environment.yml和pip requirements.txt

问题:结合conda environment.yml和pip requirements.txt

我在conda环境下工作,还需要一些pip包,例如〜gohlke的预编译轮。

目前,我有两个文件: environment.yml对于conda与:

# run: conda env create --file environment.yml
name: test-env
dependencies:
- python>=3.5
- anaconda

requirements.txt用于PIP可以上述环境康达激活后使用:

# run: pip install -i requirements.txt
docx
gooey
http://www.lfd.uci.edu/~gohlke/pythonlibs/bofhrmxk/opencv_python-3.1.0-cp35-none-win_amd64.whl

是否可以将它们合并到一个文件中(用于conda)?

I work with conda environments and need some pip packages as well, e.g. pre-compiled wheels from ~gohlke.

At the moment I have two files: environment.yml for conda with:

# run: conda env create --file environment.yml
name: test-env
dependencies:
- python>=3.5
- anaconda

and requirements.txt for pip which can be used after activating above conda environment:

# run: pip install -i requirements.txt
docx
gooey
http://www.lfd.uci.edu/~gohlke/pythonlibs/bofhrmxk/opencv_python-3.1.0-cp35-none-win_amd64.whl

Is there a possibility to combine them in one file (for conda)?


回答 0

点依赖可以包含在这样的environment.yml文件中(docs):

# run: conda env create --file environment.yml
name: test-env
dependencies:
- python>=3.5
- anaconda
- pip
- pip:
  # works for regular pip packages
  - docx
  - gooey
  # and for wheels
  - http://www.lfd.uci.edu/~gohlke/pythonlibs/bofhrmxk/opencv_python-3.1.0-cp35-none-win_amd64.whl

它也适用.whl于同一目录中的文件(请参阅Dengar的answer)以及常见的pip包。

Pip dependencies can be included in the environment.yml file like this (docs):

# run: conda env create --file environment.yml
name: test-env
dependencies:
- python>=3.5
- anaconda
- pip
- pip:
  # works for regular pip packages
  - docx
  - gooey
  # and for wheels
  - http://www.lfd.uci.edu/~gohlke/pythonlibs/bofhrmxk/opencv_python-3.1.0-cp35-none-win_amd64.whl

It also works for .whl files in the same directory (see Dengar’s answer) as well as with common pip packages.


回答 1

也可以requirements.txt直接在YAML中使用。例如,

name: test-env
dependencies:
  - python>=3.5
  - anaconda
  - pip
  - pip:
    - -r file:requirements.txt

基本上,您可以使用的任何选项都可以pip install在YAML中运行。有关其他功能的展示,请参见高级点子示例

One can also use the requirements.txt directly in the YAML. For example,

name: test-env
dependencies:
  - python>=3.5
  - anaconda
  - pip
  - pip:
    - -r file:requirements.txt

Basically, any option you can run with pip install you can run in a YAML. See the Advanced Pip Example for a showcase of other capabilities.


回答 2

只是想补充一点,在目录中添加轮子也可以。使用整个URL时出现此错误:

HTTP error 404 while getting http://www.lfd.uci.edu/~gohlke/pythonlibs/f9r7rmd8/opencv_python-3.1.0-cp35-none-win_amd64.whl

最终下载了转轮,并将其保存到yml文件所在的目录中。

name: test-env
dependencies:
- python>=3.5
- anaconda
- pip
- pip:
  - opencv_python-3.1.0-cp35-none-win_amd64.whl

Just want to add that adding a wheel in the directory also works. I was getting this error when using the entire URL:

HTTP error 404 while getting http://www.lfd.uci.edu/~gohlke/pythonlibs/f9r7rmd8/opencv_python-3.1.0-cp35-none-win_amd64.whl

Ended up downloading the wheel and saving it into the same directory as the yml file.

name: test-env
dependencies:
- python>=3.5
- anaconda
- pip
- pip:
  - opencv_python-3.1.0-cp35-none-win_amd64.whl

Windows 10无法识别Conda命令

问题:Windows 10无法识别Conda命令

我按照以下说明在Windows 10上安装了Anaconda 4.4.0(Python 3.6版本):https : //www.continuum.io/downloads。但是,当我打开命令提示符窗口并尝试编写时

conda list

我得到了

无法识别’conda’命令…

错误。

我试着跑

set PATH=%PATH%;C:\Users\Alex\Anaconda3

但这没有帮助。我还读到我可能需要编辑.bashrc文件,但是我不知道如何访问该文件以及如何编辑它。

I installed Anaconda 4.4.0 (Python 3.6 version) on Windows 10 by following the instructions here: https://www.continuum.io/downloads. However, when I open the Command prompt window and try to write

conda list

I get the

‘conda’ command is not recognized…

error.

I tried to run

set PATH=%PATH%;C:\Users\Alex\Anaconda3

but it didn’t help. I also read that I might need to edit my .bashrc file, but I don’t know how to access this file, and how I should edit it.


回答 0

在Windows中,您必须将路径设置为将Anaconda3安装到的位置。

对我来说,我将anaconda3安装到中C:\Anaconda3。因此,您需要在路径变量中添加C:\Anaconda3C:\Anaconda3\Scripts\,例如set PATH=%PATH%;C:\Anaconda3;C:\Anaconda3\Scripts\

您可以通过powershell进行此操作(请参见上文,https: //msdn.microsoft.com/zh-cn/library/windows/desktop/bb776899(v = vs.85).aspx ),或按一下windows键→输入environment→选择从settings→→ edit environment variables for your account选择Path变量Edit→→ New

要测试它,请打开一个新的dos外壳,您现在应该可以使用conda命令。例如,尝试conda --version

In Windows, you will have to set the path to the location where you installed Anaconda3 to.

For me, I installed anaconda3 into C:\Anaconda3. Therefore you need to add C:\Anaconda3 as well as C:\Anaconda3\Scripts\ to your path variable, e.g. set PATH=%PATH%;C:\Anaconda3;C:\Anaconda3\Scripts\.

You can do this via powershell (see above, https://msdn.microsoft.com/en-us/library/windows/desktop/bb776899(v=vs.85).aspx ), or hit the windows key → enter environment → choose from settingsedit environment variables for your account → select Path variable → EditNew.

To test it, open a new dos shell, and you should be able to use conda commands now. E.g., try conda --version.


回答 1

在conda 4.6之后,情况发生了变化

程序“ Anaconda Prompt”和“ Anaconda Powershell”会conda自动为您显示命令。在启动菜单中找到它们。

如果您不想使用上面的提示,请尝试conda使用普通cmd.exe和Powershell。阅读以下内容。


暴露conda在每个shell

以下内容的目的是使命令在Windows condacmd.exe和Powershell中均可用。

如果在Anaconda安装过程中已选中“将Anaconda添加到我的PATH环境变量”,请跳过步骤1。

  1. 如果Anaconda仅安装用于当前用途,则将%USERPROFILE%\Anaconda3\condabin(我的意思是condabin,不是Scripts)添加到环境变量PATH(用户一个)中。如果您的计算机上的所有用户都安装了Anaconda,请添加C:\ProgramData\Anaconda3\condabin到中PATH

    如何在Windows上设置系统环境变量?

  2. 打开一个新的 Powershell,一次运行以下命令进行初始化conda

    conda init

这些步骤确保conda命令显示在您的cmd.exePowershell中。


扩展阅读:conda init来自Conda 4.6

警告:将新内容添加到您的中,\path\to\anaconda3\condabin但不要添加。这是4.6中引入的重大更改\path\to\anaconda3\ScriptsPATHconda

激活脚本初始化fron conda4.6发布日志

Conda 4.6添加了广泛的初始化支持,因此可以使用新conda activate命令的外壳比以前更多。有关更多信息,请阅读的输出。conda init –help对于这种新的工作方式,我们特别感到兴奋,因为消除了修改需求,PATH使Conda对系统上其他软件的破坏性大大降低。

在过去,这\path\to\anaconda3\Scripts是您的必备条件PATH。它conda同时在“基本”环境中公开命令和默认Python。

conda4.6 之后,conda相关命令分为condabin。这样就可以公开仅命令,conda而无需从“基本”环境中激活Python。

参考文献

Things have been changed after conda 4.6.

Programs “Anaconda Prompt” and “Anaconda Powershell” expose the command conda for you automatically. Find them in your startup menu.

If you don’t wanna use the prompts above and try to make conda available in a normal cmd.exe and a Powershell. Read the following content.


Expose conda in Every Shell

The purpose of the following content is to make command conda available both in cmd.exe and Powershell on Windows.

If you have already checked “Add Anaconda to my PATH environment variable” during Anaconda installation, skip step 1.

  1. If Anaconda is installed for the current use only, add %USERPROFILE%\Anaconda3\condabin (I mean condabin, not Scripts) into the environment variable PATH (the user one). If Anaconda is installed for all users on your machine, add C:\ProgramData\Anaconda3\condabin into PATH.

    How do I set system environment variables on Windows?

  2. Open a new Powershell, run the following command once to initialize conda.

    conda init
    

These steps make sure the conda command is exposed into your cmd.exe and Powershell.


Extended Reading: conda init from Conda 4.6

Caveat: Add the new \path\to\anaconda3\condabin but not \path\to\anaconda3\Scripts into your PATH. This is a big change introduced in conda 4.6.

Activation script initialization fron conda 4.6 release log

Conda 4.6 adds extensive initialization support so that more shells than ever before can use the new conda activate command. For more information, read the output from conda init –help We’re especially excited about this new way of working, because removing the need to modify PATH makes Conda much less disruptive to other software on your system.

In the old days, \path\to\anaconda3\Scripts is the one to be put into your PATH. It exposes command conda and the default Python from “base” environment at the same time.

After conda 4.6, conda related commands are separated into condabin. This makes it possible to expose ONLY command conda without activating the Python from “base” environment.

References


回答 2

现在在Windows上安装anaconda时,它不会自动添加Python或Conda。

如果您不知道conda和/或python在哪里,请在anaconda提示符下键入以下命令

接下来,您可以在命令提示符下使用setx命令将Python和Conda添加到路径中。

接下来,关闭该命令提示符并打开一个新命令。恭喜您现在可以使用conda和python

来源:https : //medium.com/@GalarnykMichael/install-python-on-windows-anaconda-c63c7c3d1444

When you install anaconda on windows now, it doesn’t automatically add Python or Conda.

If you don’t know where your conda and/or python is, you type the following commands into your anaconda prompt

Next, you can add Python and Conda to your path by using the setx command in your command prompt.

Next close that command prompt and open a new one. Congrats you can now use conda and python

Source: https://medium.com/@GalarnykMichael/install-python-on-windows-anaconda-c63c7c3d1444


回答 3

用于Windows的最新版本的Anaconda安装程序还将为“ Anaconda Prompt”和“ Anaconda Powershell Prompt”安装Windows启动器。如果您使用其中之一而不是常规的Windows cmd Shell,则conda默认情况下,此Shell中应使用命令python等。

The newest version of the Anaconda installer for Windows will also install a windows launcher for “Anaconda Prompt” and “Anaconda Powershell Prompt”. If you use one of those instead of the regular windows cmd shell, the conda command, python etc. should be available by default in this shell.


回答 4

如果要在Windows的常规cmd中使用Anaconda,则需要向Path env变量添加几个路径。

这些路径是(根据 PC 上的Anaconda版本文件夹可能是Anaconda2而不是Anaconda2):

\Users\YOUR_USER\Anaconda3
\Users\YOUR_USER\Anaconda3\Library\mingw-w64\bin
\Users\YOUR_USER\Anaconda3\Library\usr\bin
\Users\YOUR_USER\Anaconda3\Library\bin
\Users\YOUR_USER\Anaconda3\Scripts
\Users\YOUR_USER\Anaconda3\bin

If you want to use Anaconda in regular cmd on windows you need to add several paths to your Path env variable.

Those paths are (instead of Anaconda3 the folder may be Anaconda2 depending on the Anaconda version on your PC):

\Users\YOUR_USER\Anaconda3
\Users\YOUR_USER\Anaconda3\Library\mingw-w64\bin
\Users\YOUR_USER\Anaconda3\Library\usr\bin
\Users\YOUR_USER\Anaconda3\Library\bin
\Users\YOUR_USER\Anaconda3\Scripts
\Users\YOUR_USER\Anaconda3\bin

回答 5

一个小时前,我也遇到了同样的问题。我试图用Python安装QuTip Quantum Toolbox 不幸的是,我没有及时发现该页面。假设您已经下载了Anaconda安装程序并运行到最后。天真地,我在Windows 10中打开了命令提示符,然后继续输入qutip installation docs中给出的以下命令。

康达创建-n qutip-env

conda配置-添加通道conda-forge

康达安装qutip

但是,当我键入第一行时,我得到以下响应

不能将conda识别为内部或外部命令,可操作程序或批处理文件

错误消息

我继续尝试了一些其他操作,如该数字 错误消息所示。 最后,在访问了多个conda网站之后,我了解了如何解决此问题。在底部的搜索栏中输入Anaconda提示符,如下所示(在同一位置您赞美Cortana) Anaconda提示符

一旦您在这里,所有的conda命令将照常工作

I had also faced the same problem just an hour back. I was trying to install QuTip Quantum Toolbox in Python Unfortunately, I didn’t stumble onto this page in time. Say you have downloaded Anaconda installer and run it until the end. Naively, I opened the command prompt in windows 10 and proceded to type the following commands as given in the qutip installation docs.

conda create -n qutip-env

conda config –append channels conda-forge

conda install qutip

But as soon as I typed the first line I got the following response

conda is not recognized as an internal or external command, operable program or batch file

error messsage

I went ahead and tried some other things as seen in this figures error message Finally after going through a number conda websites, I understood how one fixes this problem. Type Anaconda prompt in the search bar at the bottom like this (same place where you hail Cortana) Anaconda prompt

Once you are here all the conda commands will work as usual


回答 6

如果您已安装Visual Studio 2017(专业版)

安装位置:

C:\ProgramData\Anaconda3\Scripts

如果您不希望将其放入Windows的path环境变量中并重新启动,可以通过以下简单方式运行它:

C:\>"C:\ProgramData\Anaconda3\Scripts\conda.exe" update qt pyqt

If you have installed Visual studio 2017 (profressional)

The install location:

C:\ProgramData\Anaconda3\Scripts

If you do not want the hassle of putting this in your path environment variable on windows and restarting you can run it by simply:

C:\>"C:\ProgramData\Anaconda3\Scripts\conda.exe" update qt pyqt

回答 7

甚至在我初次安装Anaconda时遇到了同样的问题。它说找不到“ conda”命令。

因此,我只设置了两个值[在PATH变量中添加了Anaconda的两个新路径]系统环境变量:C:\ Users \ mshas \ Anaconda2 \和C:\ Users \ mshas \ Anaconda2 \ Scripts

很多人忘记添加第二个变量“ Scripts”,而只需添加“ conda”命令即可。

Even I got the same problem when I’ve first installed Anaconda. It said ‘conda’ command not found.

So I’ve just setup two values[added two new paths of Anaconda] system environment variables in the PATH variable which are: C:\Users\mshas\Anaconda2\ & C:\Users\mshas\Anaconda2\Scripts

Lot of people forgot to add the second variable which is “Scripts” just add that then ‘conda’ command works.


回答 8

您需要将C://…/Anaconda3安装文件中的python.exe以及C://…/Anaconda3/Scripts添加到PATH。

首先转到您的安装目录,在我的情况下,它安装在C:// Users / user / Anaconda3中,并按住Shift键并单击鼠标右键,然后按“在此处打开命令窗口”,或者如果是powershell,则可能是“在此处打开powershell” ,只需编写cmd并按Enter键即可运行命令窗口。然后运行以下命令setx PATH%cd%

然后转到C:// Users / user / Anaconda3 / Scripts并在上面打开命令窗口,然后运行相同的命令“ setx PATH%cd%”

You need to add the python.exe in C://…/Anaconda3 installation file as well as C://…/Anaconda3/Scripts to PATH.

First go to your installation directory, in my case it is installed in C://Users/user/Anaconda3 and shift+right click and press “Open command window here” or it might be “Open powershell here”, if it is powershell, just write cmd and hit enter to run command window. Then run the following command setx PATH %cd%

Then go to C://Users/user/Anaconda3/Scripts and open the command window there as above, then run the same command “setx PATH %cd%”


回答 9

情况#1 您应设置3条路径:

%ANACONDAPATH%;
%ANACONDAPATH%\Scripts;
%ANACONDAPATH%\Library\bin;

它将解决问题:

C:\WINDOWS\system32>conda update conda
Solving environment: failed

CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://repo.anaconda.com/pkgs/msys2/noarch/repodata.json.bz2>
Elapsed: -
...

案例2 您还可以使用Anaconda Promd(用于Win10)代替CLI(cmd.exe)

case #1 You should set 3 path:

%ANACONDAPATH%;
%ANACONDAPATH%\Scripts;
%ANACONDAPATH%\Library\bin;

It will solve problem:

C:\WINDOWS\system32>conda update conda
Solving environment: failed

CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://repo.anaconda.com/pkgs/msys2/noarch/repodata.json.bz2>
Elapsed: -
...

case #2 Also you can use Anaconda Promd (for Win10) instead CLI (cmd.exe)


回答 10

为了防止SSL出现其他问题,您应该将所有这些都添加到Path中:

 SETX PATH "%PATH%;C:\<path>\Anaconda3;C:\<path>\Anaconda3\Scripts;C:\<path>\Anaconda3\Library\bin"

请求(由SSLError引起(“由于SSL模块不可用,无法连接到HTTPS URL。”)PyCharm请求网站中的错误

To prevent having further issues with SSL you should add all those to Path :

 SETX PATH "%PATH%;C:\<path>\Anaconda3;C:\<path>\Anaconda3\Scripts;C:\<path>\Anaconda3\Library\bin"

Requests (Caused by SSLError(“Can’t connect to HTTPS URL because the SSL module is not available.”) Error in PyCharm requesting website