1

I assume both pip and conda, despite differences, are package managers and check for consistency of packages installed in an environment! In my case though, I have a list of requirements.txt, on top of python=3.6. In my conda virtual environment, I installed them one-by-one. The strange thing is that when locating some packages in anaconda.org channels and installing them with conda install, conda complains! An example is when I tried to install statistics=1.0.3.5, and I got this message on terminal:

UnsatisfiableError: The following specifications were found
to be incompatible with the existing python installation in your environment:

Specifications:

  - statistics=1.0.3.5 -> python[version='2.7.*|<3|>=2.7,<2.8.0a0']

Your python: python=3.6

However, when I did it with pip, it worked!

Why is that?

Am I going to bump into a problem down the road with this package?

I read this Stackoverflow post about the difference between pip and conda and tried to understand it from the doc (Although not that successful).

Ehsan Sh
  • 227
  • 2
  • 8
  • 1
    Be aware that the `statistics` package is a backport of [the standard library module](https://docs.python.org/3/library/statistics.html) introduced in Python 3.4. It is only designed to be installed in Python 2 because it already is part of Python 3.4+, i.e., looks like Conda is working correctly. Not sure what the consequence is of installing it through Pip. – merv Aug 02 '21 at 16:43

1 Answers1

1

When working with conda virtual environments, installing packages with pip should be the last resort. If a package isn't available through the default channel, try installing from conda-forge first.

The difference between conda and pip is huge (not to mention virtual environments): Conda aims to install a consistent set of packages - which results in an optimization problem - while pip just installs dependencies, no matter if that is in conflict with any previously installed package.

However, since you are writing unit tests with your code you'll immediatly realize if you bump into a problem.

Peter
  • 10,959
  • 2
  • 30
  • 47
  • Thanks @Peter for your answer. However, as I mentioned, conda refuses to install this version of package after adding appropriate channel! So let me ask this if you don't mind. "Conda aims to install a consistent set of packages, while pip just installs dependencies, no matter if that is in conflict with any previously installed package." so would you mind resolving my confusions in below comments? – Ehsan Sh Aug 01 '21 at 18:28
  • 1- Suppose I have package 'A' which depends on package `B=1' and try to install package `C` which depends on package `B=2`. I think this is when I would have "conflict"! right? – Ehsan Sh Aug 01 '21 at 18:28
  • 2- If 1 is true, what does it mean to have conflict with Specifications , in my case `python=3.6`? currently, I am able to `import statistics` in python shell! – Ehsan Sh Aug 01 '21 at 18:29
  • 3-If 1 is true, I assume that conda simply refuses to install package `C` from your answer! What does pip do in this case? Simply updates package `B` according to the dependency of latest package installed?! and them I assume I would have problem with package `A` ! Right? – Ehsan Sh Aug 01 '21 at 18:31
  • How do I go about cleaning my machine (Linux Ubuntu 18.04) after using pip and conda interchangeably? I'd like to start fresh and use conda as my go-to package manager. I was unaware of the harm I caused using both indiscriminately. – Max Eisenhardt Apr 08 '22 at 21:40