标签归档:package-managers

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

为什么apt-get功能在Mac OS X v10.9(Mavericks)的终端中不起作用?

问题:为什么apt-get功能在Mac OS X v10.9(Mavericks)的终端中不起作用?

我正在观看此视频,如您所见,告诉我的第一个命令是:

sudo apt-get install python-setuptools

当我这样做时,它输出:

sudo: apt-get: command not found

我不知道为什么会这样。

如何解决此问题,以便正确遵循本教程?

I was watching this, and, as you can see, the first command I am told to put in is:

sudo apt-get install python-setuptools

When I do this, it outputs:

sudo: apt-get: command not found

I have no idea why this is the case.

How can I resolve this so I am following the tutorial correctly?


回答 0

Mac OS X没有apt-get。有一个叫做Homebrew的程序包管理器代替了。

该命令将是:

brew安装python

使用Homebrew安装否则会用到的软件包apt-get

我链接到的页面具有安装Homebrew的最新方法,但是目前,您可以按以下方式安装Homebrew:

在Mac OS X终端中键入以下内容:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

在那之后,Homebrew的用法为brew install <package>

XCode命令行工具是Homebrew的前提条件之一。

  1. 从App Store安装XCode。
  2. 请按照此Stack Overflow答案中的说明安装XCode命令行工具

背景

软件包管理器(如apt-getbrew)只是为您的系统提供了一种简单且自动化的安装软件包或库的方法。不同的系统使用不同的程序。 apt及其派生类在基于Debian的linux系统上使用。使用Red Hat式的Linux系统rpm(或者至少在很多年前,他们做了很多)。 yum还是基于RedHat的系统的软件包管理器。

基于高山的系统使用apk

警告

自2016年4月25日起,默认情况下自制软件会选择让用户加入分析。可以通过两种方式选择退出:

设置环境变量:

  1. 打开您喜欢的环境变量编辑器
  2. 进行以下设置:HOMEBREW_NO_ANALYTICS=1 在保存环境变量的任何地方(通常是~/.bash_profile
  3. 关闭文件,然后重新启动终端或source ~/.bash_profile

运行以下命令:

brew analytics off

然后可以使用以下命令检查分析状态:

brew analytics

Mac OS X doesn’t have apt-get. There is a package manager called Homebrew that is used instead.

This command would be:

brew install python

Use Homebrew to install packages that you would otherwise use apt-get for.

The page I linked to has an up-to-date way of installing homebrew, but at present, you can install Homebrew as follows:

Type the following in your Mac OS X terminal:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

After that, usage of Homebrew is brew install <package>.

One of the prerequisites for Homebrew are the XCode command line tools.

  1. Install XCode from the App Store.
  2. Follow the directions in this Stack Overflow answer to install the XCode Command Line Tools.

Background

A package manager (like apt-get or brew) just gives your system an easy and automated way to install packages or libraries. Different systems use different programs. apt and its derivatives are used on Debian based linux systems. Red Hat-ish Linux systems use rpm (or at least they did many, many, years ago). yum is also a package manager for RedHat based systems.

Alpine based systems use apk.

Warning

As of 25 April 2016, homebrew opts the user in to sending analytics by default. This can be opted out of in two ways:

Setting an environment variable:

  1. Open your favorite environment variable editor.
  2. Set the following: HOMEBREW_NO_ANALYTICS=1 in whereever you keep your environment variables (typically something like ~/.bash_profile)
  3. Close the file, and either restart the terminal or source ~/.bash_profile.

Running the following command:

brew analytics off

the analytics status can then be checked with the command:

brew analytics

回答 1

因为Homebrew是我在macOS上的最爱,尽管有可能apt-get使用Fink在macOS上使用。

As Homebrew is my favorite for macOS although it is possible to have apt-get on macOS using Fink.


回答 2

MacPorts是OS X的另一个软件包管理器:。

安装说明在该MacPorts的项目-下载和安装之后,一个问题sudo port install pythonXX,这里XX2735

MacPorts is another package manager for OS X:.

Installation instructions are at The MacPorts Project — Download & Installation after which one issues sudo port install pythonXX, where XX is 27 or 35.


回答 3

Conda也可以用作程序包管理器。可以从Anaconda安装。

另外,一个免费的最小安装程序是Miniconda

Conda can also be used as package manager. It can be installed from Anaconda.

Alternatively, a free minimal installer is Miniconda.


回答 4

您还可以使用curl命令安装东西,只要在URL提及apt-get的地方…

例如,

curl -O http://www.magentocommerce.com/downloads/assets/1.8.1.0/magento-1.8.1.0.tar.gz

Alternatively You can use the brew or curl command for installing things, wherever apt-get is mentioned with a URL…

For example,

curl -O http://www.magentocommerce.com/downloads/assets/1.8.1.0/magento-1.8.1.0.tar.gz

dist-packages和site-packages有什么区别?

问题:dist-packages和site-packages有什么区别?

我对python软件包的安装过程有些不满意。具体来说,安装在dist-packages目录和site-packages目录中的软件包之间有什么区别?

I’m a bit miffed by the python package installation process. Specifically, what’s the difference between packages installed in the dist-packages directory and the site-packages directory?


回答 0

dist-packages是特定于Debian的约定,也存在于其衍生版本中,例如Ubuntu。当模块从Debian软件包管理器进入以下位置时,它们将安装到dist-packages中:

/usr/lib/python2.7/dist-packages

由于easy_installpip是从软件包管理器安装的,因此它们也使用dist-packages,但是它们将软件包放在此处:

/usr/local/lib/python2.7/dist-packages

Debian Python Wiki

dist-packages而不是site-packages。从Debian软件包安装的第三方Python软件进入dist软件包,而不是站点软件包。这是为了减少系统Python与您可能手动安装的任何源Python构建之间的冲突。

这意味着,如果您从源代码手动安装Python,它将使用site-packages目录。这使您可以将两个安装分开,特别是因为Debian和Ubuntu在许多系统实用程序中都依赖Python的系统版本。

dist-packages is a Debian-specific convention that is also present in its derivatives, like Ubuntu. Modules are installed to dist-packages when they come from the Debian package manager into this location:

/usr/lib/python2.7/dist-packages

Since easy_install and pip are installed from the package manager, they also use dist-packages, but they put packages here:

/usr/local/lib/python2.7/dist-packages

From the Debian Python Wiki:

dist-packages instead of site-packages. Third party Python software installed from Debian packages goes into dist-packages, not site-packages. This is to reduce conflict between the system Python, and any from-source Python build you might install manually.

This means that if you manually install Python from source, it uses the site-packages directory. This allows you to keep the two installations separate, especially since Debian and Ubuntu rely on the system version of Python for many system utilities.


回答 1

dist-packages是debian专用的目录,apt朋友可以在其中安装他们的东西,并且site-packages是标准pip目录。

问题是-当不同目录中存在相同软件包的不同版本时,会发生什么?

我对这个问题的解决方案是建立dist-packages一个符号链接到site-packages

for d in $(find $WORKON_HOME -type d -name dist-packages); do
  pushd $d
  cd ..
  if test -d dist-packages/__pycache__; then
    mv -v dist-packages/__pycache__/* site-packages/__pycache__/
    rmdir -v dist-packages/__pycache__
  fi
  mv -v dist-packages/* site-packages/
  rmdir -v dist-packages
  ln -sv site-packages dist-packages
  popd
done

(如果您不使用gnu工具,请删除该-v选项)。

dist-packages is the debian-specific directory where apt and friends install their stuff, and site-packages is the standard pip directory.

The problem is — what happens when different versions of the same package are present in different directories?

My solution to the problem is to make dist-packages a symlink to site-packages:

for d in $(find $WORKON_HOME -type d -name dist-packages); do
  pushd $d
  cd ..
  if test -d dist-packages/__pycache__; then
    mv -v dist-packages/__pycache__/* site-packages/__pycache__/
    rmdir -v dist-packages/__pycache__
  fi
  mv -v dist-packages/* site-packages/
  rmdir -v dist-packages
  ln -sv site-packages dist-packages
  popd
done

(if you are not using gnu tools, remove the -v option).


如何从虚拟环境内部更新点子本身?

问题:如何从虚拟环境内部更新点子本身?

我可以更新点子管理的软件包,但是如何更新点子本身?据介绍pip --version,我目前在virtualenv中安装了pip 1.1,我想更新到最新版本。

这是什么命令?我需要使用distribute还是本机pip或virtualenv命令?我已经尝试过pip update,并pip update pip没有成功。

I’m able to update pip-managed packages, but how do I update pip itself? According to pip --version, I currently have pip 1.1 installed in my virtualenv and I want to update to the latest version.

What’s the command for that? Do I need to use distribute or is there a native pip or virtualenv command? I’ve already tried pip update and pip update pip with no success.


回答 0

pip仅仅是一个的PyPI包像任何其他; 您可以像升级任何软件包一样使用它来升级自身:

pip install --upgrade pip

在Windows上,推荐的命令是:

python -m pip install --upgrade pip

pip is just a PyPI package like any other; you could use it to upgrade itself the same way you would upgrade any package:

pip install --upgrade pip

On Windows the recommended command is:

python -m pip install --upgrade pip

回答 1

更安全的方法是通过python模块运行pip

python -m pip install -U pip

在Windows上,尝试替换自身的二进制文件似乎存在问题,此方法可解决该限制。

The more safe method is to run pip though a python module:

python -m pip install -U pip

On windows there seem to be a problem with binaries that try to replace themselves, this method works around that limitation.


回答 2

就我而言,我的pip版本已损坏,因此更新本身无法进行。

固定:

(inside virtualenv):easy_install -U pip

In my case my pip version was broken so the update by itself would not work.

Fix:

(inside virtualenv):easy_install -U pip

回答 3

我在Debian Jessie下尝试了上面提到的所有这些解决方案。它们不起作用,因为它只需要由debian软件包管理器编译的最新版本1.5.6相当于6.0.x版本。某些使用pip作为前提条件的软件包将无法正常运行,例如spaCy(需要使用–no-cache-dir选项才能正常运行)。

因此,解决这些问题的实际最佳方法是运行从wget下载的get-pip.py,它是从网站或使用curl进行的,如下所示:

 wget https://bootstrap.pypa.io/get-pip.py -O ./get-pip.py
 python ./get-pip.py
 python3 ./get-pip.py

这将安装当前版本,在编写此解决方案时为9.0.1,这远远超出了Debian提供的功能。

 $ pip --version
 pip 9.0.1 from /home/myhomedir/myvirtualenvdir/lib/python2.7/dist-packages (python 2.7)
 $ pip3 --version
 pip 9.0.1 from /home/myhomedir/myvirtualenvdir/lib/python3.4/site-packages (python 3.4)

I tried all of these solutions mentioned above under Debian Jessie. They don’t work, because it just takes the latest version compile by the debian package manager which is 1.5.6 which equates to version 6.0.x. Some packages that use pip as prerequisites will not work as a results, such as spaCy (which needs the option –no-cache-dir to function correctly).

So the actual best way to solve these problems is to run get-pip.py downloaded using wget, from the website or using curl as follows:

 wget https://bootstrap.pypa.io/get-pip.py -O ./get-pip.py
 python ./get-pip.py
 python3 ./get-pip.py

This will install the current version which at the time of writing this solution is 9.0.1 which is way beyond what Debian provides.

 $ pip --version
 pip 9.0.1 from /home/myhomedir/myvirtualenvdir/lib/python2.7/dist-packages (python 2.7)
 $ pip3 --version
 pip 9.0.1 from /home/myhomedir/myvirtualenvdir/lib/python3.4/site-packages (python 3.4)

回答 4

由于可怕的证书问题,使用’ pip install –upgrade pip ‘ 升级pip 并不总是有效:确认ssl证书时出现问题:[SSL:TLSV1_ALERT_PROTOCOL_VERSION] tlsv1警报协议版本

我喜欢对虚拟环境使用单行命令:

curl https://bootstrap.pypa.io/get-pip.py | python -

或者,如果您想将其安装在宽盒中,则需要

curl https://bootstrap.pypa.io/get-pip.py | sudo python -

如果要在自动化脚本中运行时使输出静音,则可以给curl -s标志。

Upgrading pip using ‘pip install –upgrade pip‘ does not always work because of the dreaded cert issue: There was a problem confirming the ssl certificate: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version

I like to use the one line command for virtual envs:

curl https://bootstrap.pypa.io/get-pip.py | python -

Or if you want to install it box wide you will need

curl https://bootstrap.pypa.io/get-pip.py | sudo python -

you can give curl a -s flag if you want to silence the output when running in an automation script.


回答 5

就我而言,这是从Debian Stable中的终端命令行执行的

python3 -m pip install --upgrade pip

In my case this worked from the terminal command line in Debian Stable

python3 -m pip install --upgrade pip

回答 6

为了使它对我有用,我必须使用Python命令提示符(在VS CODE的WIN10上)在Python目录中进行深入研究。就我而言,它位于我的“ AppData \ Local \ Programs \ Python \ python35-32”目录中。从现在开始,我执行命令…

python -m pip install --upgrade pip

这很有效,我很好。

To get this to work for me I had to drill down in the Python directory using the Python command prompt (on WIN10 from VS CODE). In my case it was in my “AppData\Local\Programs\Python\python35-32” directory. From there now I ran the command…

python -m pip install --upgrade pip

This worked and I’m good to go.


回答 7

使用管理员权限打开命令提示符,然后重复以下命令:

python -m pip install --upgrade pip

Open Command Prompt with Administrator Permissions, and repeat the command:

python -m pip install --upgrade pip

回答 8

pip版本10有问题。它将显示为错误:

ubuntu@mymachine-:~/mydir$ sudo pip install --upgrade pip
Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    from pip import main
ImportError: cannot import name main

解决方案是在要升级的venv中,然后运行:

sudo myvenv/bin/pip install --upgrade pip

而不只是

sudo pip install --upgrade pip

pip version 10 has an issue. It will manifest as the error:

ubuntu@mymachine-:~/mydir$ sudo pip install --upgrade pip
Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    from pip import main
ImportError: cannot import name main

The solution is to be in the venv you want to upgrade and then run:

sudo myvenv/bin/pip install --upgrade pip

rather than just

sudo pip install --upgrade pip

回答 9

如果您使用venv,则任何更新到pip的安装都将导致升级系统pip,而不是venv pip。您还需要升级pip引导程序包。

  python3 -m pip install --upgrade pip setuptools wheel

In case you are using venv any update to pip install will result in upgrading the system pip instead of the venv pip. You need to upgrade the pip bootstrapping packages as well.

  python3 -m pip install --upgrade pip setuptools wheel

回答 10

我已经在C:\ Python \ Python36中安装了Python,因此转到Windows命令提示符并键入“ cd C:\ Python \ Python36”以获取正确的目录。然后输入“ python -m install –upgrade pip”全部好!

I had installed Python in C:\Python\Python36 so I went to the Windows command prompt and typed “cd C:\Python\Python36 to get to the right directory. Then entered the “python -m install –upgrade pip” all good!


回答 11

在Windows 7笔记本电脑上,正确安装最新版本的pip的正确方法是:

python.exe -m pip install --upgrade pip

On my lap-top with Windows 7 the right way to install latest version of pip is:

python.exe -m pip install --upgrade pip

回答 12

单行Python程序
我发现的最好方法是编写一个单行程序,该程序可以下载并运行官方的get-pip脚本。参见下面的代码。

官方文档建议使用curl下载get-pip脚本,但是由于我在Windows上工作且未安装curl,因此我更喜欢使用python本身来下载和运行脚本。

这是可以使用Python 3通过命令行运行的单行程序:

python -c "import urllib.request; exec(urllib.request.urlopen('https://bootstrap.pypa.io/get-pip.py').read())"

根据安装说明,该行将获取官方的“ get-pip.py”脚本,并使用“ exec”命令执行该脚本。

对于Python2,您可以将“ urllib.request”替换为“ urllib2”:

python -c "import urllib2; exec(urllib2.urlopen('https://bootstrap.pypa.io/get-pip.py').read())"

预防措施
值得注意的是,盲目运行任何python脚本本质上都是危险的。因此,官方说明建议在运行之前下载脚本并进行检查。

就是说,许多人实际上并不检查代码,而只是运行它。这一单行程序使这一过程变得更加容易。

Single Line Python Program
The best way I have found is to write a single line program that downloads and runs the official get-pip script. See below for the code.

The official docs recommend using curl to download the get-pip script, but since I work on windows and don’t have curl installed I prefer using python itself to download and run the script.

Here is the single line program that can be run via the command line using Python 3:

python -c "import urllib.request; exec(urllib.request.urlopen('https://bootstrap.pypa.io/get-pip.py').read())"

This line gets the official “get-pip.py” script as per the installation notes and executes the script with the “exec” command.

For Python2 you would replace “urllib.request” with “urllib2”:

python -c "import urllib2; exec(urllib2.urlopen('https://bootstrap.pypa.io/get-pip.py').read())"

Precautions
It’s worth noting that running any python script blindly is inherently dangerous. For this reason, the official instructions recommend downloading the script and inspecting it before running.

That said, many people don’t actually inspect the code and just run it. This one-line program makes that easier.


回答 13

我在树莓派上遇到了类似的问题。

问题在于http需要SSL,因此我需要强制它使用https来解决此要求。

sudo pip install --upgrade pip --index-url=https://pypi.python.org/simple

要么

sudo pip-3.2 --upgrade pip --index-url=https://pypi.python.org/simple/

I had a similar problem on a raspberry pi.

The problem was that http requires SSL and so I needed to force it to use https to get around this requirement.

sudo pip install --upgrade pip --index-url=https://pypi.python.org/simple

or

sudo pip-3.2 --upgrade pip --index-url=https://pypi.python.org/simple/

回答 14

我处于类似情况,想更新urllib3软件包。对我有用的是:

pip3 install --upgrade --force-reinstall --ignore-installed urllib3==1.25.3

I was in a similar situation and wanted to update urllib3 package. What worked for me was:

pip3 install --upgrade --force-reinstall --ignore-installed urllib3==1.25.3

回答 15

很简单。只需从https://bootstrap.pypa.io/get-pip.py下载pip 。将文件保存在forlder或dekstop中。我将文件保存在D盘中,然后从命令提示符导航到下载pip的文件夹。然后在那打

python -get-pip.py

Very Simple. Just download pip from https://bootstrap.pypa.io/get-pip.py . Save the file in some forlder or dekstop. I saved the file in my D drive.Then from your command prompt navigate to the folder where you have downloaded pip. Then type there

python -get-pip.py


pip和conda有什么区别?

问题:pip和conda有什么区别?

我知道pip是python软件包的软件包管理器。但是,我看到IPython网站conda上的安装用于安装IPython。

我可以pip用来安装IPython吗?conda我已经拥有了为什么还要用作另一个python软件包管理器pip

pip和之间有什么区别conda

I know pip is a package manager for python packages. However, I saw the installation on IPython’s website use conda to install IPython.

Can I use pip to install IPython? Why should I use conda as another python package manager when I already have pip?

What is the difference between pip and conda?


回答 0

引用来自Conda博客

参与python世界已经很长时间了,我们都知道pip,easy_install和virtualenv,但是这些工具不能满足我们所有的特定要求。主要问题是它们专注于Python,而忽略了非Python库依赖项,例如HDF5,MKL,LLVM等,它们的源代码中没有setup.py,也没有将文件安装到Python的站点中-packages目录。

因此,Conda是一种包装工具和安装程序,旨在做更多的事情pip。处理Python包之外的库依赖关系以及Python包本身。Conda也像创建虚拟环境一样virtualenv

因此,也许应该将Conda与Buildout进行比较,后者是另一个可以让您处理Python和非Python安装任务的工具。

由于Conda引入了新的包装格式,因此您不能pip与Conda互换使用。 pip无法安装Conda软件包格式。您可以使用并排的两个工具侧(通过安装pipconda install pip),但他们不具备互操作性无论是。

自编写此答案以来,Anaconda 理解Conda和Pip发布了新页面,该页面也与此相呼应:

这凸显了conda和pip之间的关键区别。Pip安装Python软件包,而conda安装软件包,其中可能包含以任何语言编写的软件。例如,在使用pip之前,必须通过系统软件包管理器或下载并运行安装程序来安装Python解释器。另一方面,Conda可以直接安装Python软件包以及Python解释器。

并进一步

有时需要一个软件包,该软件包不是conda软件包,但在PyPI上可用,可以与pip一起安装。在这些情况下,尝试同时使用conda和pip是有意义的。

Quoting from the Conda blog:

Having been involved in the python world for so long, we are all aware of pip, easy_install, and virtualenv, but these tools did not meet all of our specific requirements. The main problem is that they are focused around Python, neglecting non-Python library dependencies, such as HDF5, MKL, LLVM, etc., which do not have a setup.py in their source code and also do not install files into Python’s site-packages directory.

So Conda is a packaging tool and installer that aims to do more than what pip does; handle library dependencies outside of the Python packages as well as the Python packages themselves. Conda also creates a virtual environment, like virtualenv does.

As such, Conda should be compared to Buildout perhaps, another tool that lets you handle both Python and non-Python installation tasks.

Because Conda introduces a new packaging format, you cannot use pip and Conda interchangeably; pip cannot install the Conda package format. You can use the two tools side by side (by installing pip with conda install pip) but they do not interoperate either.

Since writing this answer, Anaconda has published a new page on Understanding Conda and Pip, which echoes this as well:

This highlights a key difference between conda and pip. Pip installs Python packages whereas conda installs packages which may contain software written in any language. For example, before using pip, a Python interpreter must be installed via a system package manager or by downloading and running an installer. Conda on the other hand can install Python packages as well as the Python interpreter directly.

and further on

Occasionally a package is needed which is not available as a conda package but is available on PyPI and can be installed with pip. In these cases, it makes sense to try to use both conda and pip.


回答 1

这是一个简短的摘要:

点子

  • 仅Python软件包。
  • 从源代码编译所有内容。编辑:pip现在会安装二进制车轮(如果可用)。
  • 受核心Python社区的祝福(即Python 3.4+包含自动引导pip的代码)。

康达

  • 不可知的Python。现有软件包的主要焦点是用于Python,的确Conda本身是用Python编写的,但是您也可以拥有用于C库,R软件包或其他任何东西的Conda软件包。
  • 安装二进制文件。有一个名为的工具conda build可以从源代码构建软件包,但conda install它本身可以从已构建的Conda软件包安装东西。
  • 外部。Conda是Anaconda的软件包管理器,它是Continuum Analytics提供的Python发行版,但也可以在Anaconda之外使用。您可以通过pip安装将其与现有的Python安装配合使用(尽管除非您有充分的理由使用现有的安装,否则不建议这样做)。

在两种情况下:

  • 用Python编写
  • 开源(Conda是BSD,pip是MIT)

实际上,Conda的前两个要点是使许多包装优于点子的原因。由于pip是从源代码安装的,因此如果您无法编译源代码,则可能会很麻烦地安装东西(在Windows上尤其如此,但在Linux上,如果软件包中包含一些困难的C或FORTRAN库,甚至可能也是这样。依赖项)。Conda从二进制安装,这意味着某人(例如Continuum)已经完成了编译软件包的艰苦工作,因此安装很容易。

如果您对构建自己的软件包感兴趣,也有一些区别。例如,pip是建立在setuptools之上的,而Conda使用自己的格式,这种格式具有一些优点(例如,静态的,Python不可知的)。

Here is a short rundown:

pip

  • Python packages only.
  • Compiles everything from source. EDIT: pip now installs binary wheels, if they are available.
  • Blessed by the core Python community (i.e., Python 3.4+ includes code that automatically bootstraps pip).

conda

  • Python agnostic. The main focus of existing packages are for Python, and indeed Conda itself is written in Python, but you can also have Conda packages for C libraries, or R packages, or really anything.
  • Installs binaries. There is a tool called conda build that builds packages from source, but conda install itself installs things from already built Conda packages.
  • External. Conda is the package manager of Anaconda, the Python distribution provided by Continuum Analytics, but it can be used outside of Anaconda too. You can use it with an existing Python installation by pip installing it (though this is not recommended unless you have a good reason to use an existing installation).

In both cases:

  • Written in Python
  • Open source (Conda is BSD and pip is MIT)

The first two bullet points of Conda are really what make it advantageous over pip for many packages. Since pip installs from source, it can be painful to install things with it if you are unable to compile the source code (this is especially true on Windows, but it can even be true on Linux if the packages have some difficult C or FORTRAN library dependencies). Conda installs from binary, meaning that someone (e.g., Continuum) has already done the hard work of compiling the package, and so the installation is easy.

There are also some differences if you are interested in building your own packages. For instance, pip is built on top of setuptools, whereas Conda uses its own format, which has some advantages (like being static, and again, Python agnostic).


回答 2

其他答案对这些细节给出了合理的描述,但我想强调一些高级要点。

pip是一个软件包管理器,可简化python软件包的安装,升级和卸载。它还适用于虚拟python环境。

conda是任何软件(安装,升级和卸载)的软件包管理器。它还适用于虚拟系统环境。

conda设计的目标之一是促进用户所需的整个软件堆栈的软件包管理,其中一个或多个python版本可能只是其中的一小部分。这包括低级库(例如线性代数),编译器(例如Windows上的mingw),编辑器,版本控制工具(例如Hg和Git)或其他需要分发和管理的内容

对于版本管理,pip允许您在多个python环境之间切换和管理。

Conda允许您在多个通用环境之间进行切换和管理,在多个通用环境中,其他多个版本的版本号可能会有所不同,例如C库,编译器,测试套件或数据库引擎等。

Conda不是以Windows为中心的,但是在Windows上,当需要安装和管理需要编译的复杂科学软件包时,它是目前可用的高级解决方案。

当我想到尝试通过Windows上的pip编译许多这些软件包或pip install在需要编译时调试失败的会话时浪费了多少时间时,我想哭。

最后,Continuum Analytics还托管(免费)binstar.org(现在称为anaconda.org),以允许常规软件包开发人员创建自己的自定义(内置!)软件堆栈,包用户可以conda install从中使用它们。

The other answers give a fair description of the details, but I want to highlight some high-level points.

pip is a package manager that facilitates installation, upgrade, and uninstallation of python packages. It also works with virtual python environments.

conda is a package manager for any software (installation, upgrade and uninstallation). It also works with virtual system environments.

One of the goals with the design of conda is to facilitate package management for the entire software stack required by users, of which one or more python versions may only be a small part. This includes low-level libraries, such as linear algebra, compilers, such as mingw on Windows, editors, version control tools like Hg and Git, or whatever else requires distribution and management.

For version management, pip allows you to switch between and manage multiple python environments.

Conda allows you to switch between and manage multiple general purpose environments across which multiple other things can vary in version number, like C-libraries, or compilers, or test-suites, or database engines and so on.

Conda is not Windows-centric, but on Windows it is by far the superior solution currently available when complex scientific packages requiring compilation are required to be installed and managed.

I want to weep when I think of how much time I have lost trying to compile many of these packages via pip on Windows, or debug failed pip install sessions when compilation was required.

As a final point, Continuum Analytics also hosts (free) binstar.org (now called anaconda.org) to allow regular package developers to create their own custom (built!) software stacks that their package-users will be able to conda install from.


回答 3

不要再让您感到困惑了,但是您也可以在conda环境中使用pip,这可以验证上面的一般管理员和python特定管理员的评论。

conda install -n testenv pip
source activate testenv
pip <pip command>

您还可以将pip添加到任何环境的默认程序包中,因此每次都会显示pip,因此您不必遵循上述代码段。

Not to confuse you further, but you can also use pip within your conda environment, which validates the general vs. python specific managers comments above.

conda install -n testenv pip
source activate testenv
pip <pip command>

you can also add pip to default packages of any environment so it is present each time so you don’t have to follow the above snippet.


回答 4

引用康达在Continuum网站上发表的关于数据科学的文章:

康达vs点

Python程序员可能很熟悉pip从PyPI下载软件包并管理他们的要求。尽管conda和pip都是程序包管理器,但它们却大不相同:

  • Pip是特定于Python软件包的,而conda是与语言无关的,这意味着我们可以使用conda管理任何语言的软件包。
  • Conda本机创建与语言无关的环境,而pip依靠virtualenv仅管理Python环境尽管建议始终使用conda软件包,但conda也包含pip,因此您不必在这两者之间进行选择。例如,要安装没有conda软件包但可通过pip获得的python软件包,请运行,例如:
conda install pip
pip install gensim

Quote from Conda for Data Science article onto Continuum’s website:

Conda vs pip

Python programmers are probably familiar with pip to download packages from PyPI and manage their requirements. Although, both conda and pip are package managers, they are very different:

  • Pip is specific for Python packages and conda is language-agnostic, which means we can use conda to manage packages from any language Pip compiles from source and conda installs binaries, removing the burden of compilation
  • Conda creates language-agnostic environments natively whereas pip relies on virtualenv to manage only Python environments Though it is recommended to always use conda packages, conda also includes pip, so you don’t have to choose between the two. For example, to install a python package that does not have a conda package, but is available through pip, just run, for example:
conda install pip
pip install gensim

回答 5

引用《Conda:神话与误解》(全面描述):

误解3:Conda和Pip是直接竞争对手

现实:Conda和pip服务于不同的目的,仅直接竞争一小部分任务:即在隔离的环境中安装Python软件包。

皮普,代表P IP nstalls P ackages,是Python的官方认可的包管理器,并且是最常用的在其上安装Python包索引(PyPI中)发布的数据包。pip和PyPI均受Python Packaging Authority(PyPA)管辖和支持。

简而言之,pip是Python软件包的通用管理器。conda是与语言无关的跨平台环境管理器。对于用户而言,最明显的区别可能是:pip在任何环境中安装python软件包;conda在conda环境中安装任何软件包。如果您要做的只是在隔离的环境中安装Python软件包,则conda和pip + virtualenv通常是可互换的,从而在依赖项处理和软件包可用性方面取得了一些差异。隔离环境是指conda-env或virtualenv,您可以在其中安装软件包而无需修改系统Python安装。

即使抛开神话#2,如果我们只关注Python软件包的安装,conda和pip也可以为不同的受众和不同的目的服务。例如,如果要管理现有系统Python安装中的Python软件包,conda不能为您提供帮助:根据设计,它只能在conda环境中安装软件包。例如,如果您想使用许多依赖于外部依赖关系的Python包(NumPy,SciPy和Matplotlib是常见的示例),而以有意义的方式跟踪这些依赖关系时,pip并不能帮助您:通过设计,它仅管理Python软件包。

Conda和pip不是竞争对手,而是针对不同用户群和使用方式的工具。

Quoting from Conda: Myths and Misconceptions (a comprehensive description):

Myth #3: Conda and pip are direct competitors

Reality: Conda and pip serve different purposes, and only directly compete in a small subset of tasks: namely installing Python packages in isolated environments.

Pip, which stands for Pip Installs Packages, is Python’s officially-sanctioned package manager, and is most commonly used to install packages published on the Python Package Index (PyPI). Both pip and PyPI are governed and supported by the Python Packaging Authority (PyPA).

In short, pip is a general-purpose manager for Python packages; conda is a language-agnostic cross-platform environment manager. For the user, the most salient distinction is probably this: pip installs python packages within any environment; conda installs any package within conda environments. If all you are doing is installing Python packages within an isolated environment, conda and pip+virtualenv are mostly interchangeable, modulo some difference in dependency handling and package availability. By isolated environment I mean a conda-env or virtualenv, in which you can install packages without modifying your system Python installation.

Even setting aside Myth #2, if we focus on just installation of Python packages, conda and pip serve different audiences and different purposes. If you want to, say, manage Python packages within an existing system Python installation, conda can’t help you: by design, it can only install packages within conda environments. If you want to, say, work with the many Python packages which rely on external dependencies (NumPy, SciPy, and Matplotlib are common examples), while tracking those dependencies in a meaningful way, pip can’t help you: by design, it manages Python packages and only Python packages.

Conda and pip are not competitors, but rather tools focused on different groups of users and patterns of use.


回答 6

对于WINDOWS用户

最近,“标准”包装工具的状况正在改善:

  • 截至9月,在pypi本身上,有48%的车轮包装。2015年11月11日(高于2015年5月的38%和2014年9月的24%),

  • 现在,最新的python 2.7.9支持开箱即用的wheel格式,

“标准” +“调整”包装工具的状况也在改善:

  • 您可以在http://www.lfd.uci.edu/~gohlke/pythonlibs上找到几乎所有关于转轮格式的科学软件包,

  • mingwpy项目可能有一天为Windows用户带来一个“编译”包,允许在需要时从源代码安装所有内容。

“康达”包装对于所服务的市场而言仍然更好,并强调了“标准” 应该改进的地方。

(同样,在标准车轮系统和conda系统中,或者在扩展方面,依赖规范的多方面努力不是很Python,如果所有这些打包的“核心”技术都可以通过某种PEP收敛,那就太好了)

For WINDOWS users

“standard” packaging tools situation is improving recently:

  • on pypi itself, there are now 48% of wheel packages as of sept. 11th 2015 (up from 38% in may 2015 , 24% in sept. 2014),

  • the wheel format is now supported out-of-the-box per latest python 2.7.9,

“standard”+”tweaks” packaging tools situation is improving also:

  • you can find nearly all scientific packages on wheel format at http://www.lfd.uci.edu/~gohlke/pythonlibs,

  • the mingwpy project may bring one day a ‘compilation’ package to windows users, allowing to install everything from source when needed.

“Conda” packaging remains better for the market it serves, and highlights areas where the “standard” should improve.

(also, the dependency specification multiple-effort, in standard wheel system and in conda system, or buildout, is not very pythonic, it would be nice if all these packaging ‘core’ techniques could converge, via a sort of PEP)


回答 7

pip 是包裹经理。

conda 既是包管理器又是环境管理器。

详情:

参考文献

pip is a package manager.

conda is both a package manager and an environment manager.

Detail:

References


回答 8

我可以使用pip安装iPython吗?

当然,两者(第一种方法在页面上)

pip install ipython

和(第三种方法,第二种是conda

您可以从GitHub或PyPI手动下载IPython。要安装这些版本之一,请解压缩它并使用终端从顶级源目录运行以下命令:

pip install .

官方推荐的安装方法

当我已经有了pip时,为什么还要使用conda作为另一个python软件包管理器?

这里所说:

如果您需要一个特定的软件包,也许仅用于一个项目,或者需要与其他人共享该项目,那么conda似乎更合适。

康达(YMMV)超过点

  • 使用非Python工具的项目
  • 与同事分享
  • 在版本之间切换
  • 在具有不同库版本的项目之间切换

pip和conda有什么区别?

其他所有人对此都有广泛的回答。

Can I use pip to install iPython?

Sure, both (first approach on page)

pip install ipython

and (third approach, second is conda)

You can manually download IPython from GitHub or PyPI. To install one of these versions, unpack it and run the following from the top-level source directory using the Terminal:

pip install .

are officially recommended ways to install.

Why should I use conda as another python package manager when I already have pip?

As said here:

If you need a specific package, maybe only for one project, or if you need to share the project with someone else, conda seems more appropriate.

Conda surpasses pip in (YMMV)

  • projects that use non-python tools
  • sharing with colleagues
  • switching between versions
  • switching between projects with different library versions

What is the difference between pip and conda?

That is extensively answered by everyone else.


回答 9

pip 仅适用于Python

conda仅适用于Anaconda +其他科学软件包,例如R依赖等。并非每个人都需要Python附带的Anaconda。Anaconda主要适合那些进行机器学习/深度学习等的人。Casual Python开发人员不会在他的笔记本电脑上运行Anaconda。

pip is for Python only

conda is only for Anaconda + other scientific packages like R dependencies etc. NOT everyone needs Anaconda that already comes with Python. Anaconda is mostly for those who do Machine learning/deep learning etc. Casual Python dev won’t run Anaconda on his laptop.


回答 10

我可能已经发现了另一小的区别。我在python环境下/usr而不是在/home任何环境下。为了安装它,我将不得不使用sudo install pip。对我来说,不想要的副作用sudo install pip是比被广泛报道的其他地方略有不同:这样做之后,我还得跑pythonsudo以进口任何的sudo-installed包。我放弃了这一点,最终发现我可以sudo conda将软件包安装到一个环境中/usr,然后在该环境下可以正常导入而不需要sudo获得许可python。我什sudo conda至习惯于修复损坏的东西,pip而不是使用sudo pip uninstall pipor sudo pip --upgrade install pip

I may have found one further difference of a minor nature. I have my python environments under /usr rather than /home or whatever. In order to install to it, I would have to use sudo install pip. For me, the undesired side effect of sudo install pip was slightly different than what are widely reported elsewhere: after doing so, I had to run python with sudo in order to import any of the sudo-installed packages. I gave up on that and eventually found I could use sudo conda to install packages to an environment under /usr which then imported normally without needing sudo permission for python. I even used sudo conda to fix a broken pip rather than using sudo pip uninstall pip or sudo pip --upgrade install pip.