Why do we install streamlit with pip and not conda?

I’m just getting started with streamlit and I notice the installation instructions suggest creating an environment with conda, then opening a terminal window in that environment and using pip to install streamlit.

But why don’t we just install it with conda? In Anaconda I can see a package called streamlit. Wouldn’t it be better to install streamlit directly with conda, along with any other packages I need to use in building my streamlit-based application?

Hello @mcrepeau, welcome to the forum

You will find a lot of opinions regarding installing with pip or conda in a conda environment.

From my experience of mixing pip and conda installed packages in the same environment, this blog post has been the closest to my experience:

  • You’re fine to use either pip or conda, but try to stick to only one of the 2 in the same environment. There were times for me where conda install of a package did not resolve pip dependencies very well and vice-versa (they don’t use the same dependency resolver), and you could end up mixing and breaking versions of a dependency.
  • I use pip for all Python packages, almost all packages deploy first on PyPi then on Conda, so you have more chances of the pip install being the more recent version than the conda one (in fact it’s possible the streamlit conda is not the most recent one) (this is not always the case for all packages, but like for me it was 85-90%)
  • I use conda for non Python packages (like git or openjdk) or packages that pip can’t install on Windows but conda can, generally because of compiled extensions like C++ dependencies (like pystan on Windows from memory for fbprophet). This is also where you find the 10% conda packages that don’t have a pip install in my experience.
  • For ML libraries which heavily depend on C++ like pytorch, or which promise specific CPU optimizations like numpy with MKL optimization, I tend to use pip anyways but if it does not work I’ll go with conda

So what I do is always use pip in conda environments, and conda install when pip install did not work for the very specific libraries with hardcore C dependencies

Have a nice day,
Fanilo

3 Likes

Thanks! That’s very helpful!

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.