Can conda coexist with pip? - python

Maybe is a stupid question but I would like to install a python package that is in conda but not in pip. This is the package:
https://wrf-python.readthedocs.io/en/latest/installation.html
I don't have conda installed. My concern is that can conda coexist with pip? In other words, if I install conda and install that package, I would be able to use it with all the packages that I already have installed in pip?
thanks

You can do this by running
conda config --add create_default_packages pip
and pip will be installed in any new environment.
But, the whole point of conda is for it to work better than pip, so I would suggest using conda instead of pip at all times.

Related

What is the difference between using conda pip install and conda skeleton?

I need to install a python package from pypi
Which are the differences between installing it directly in the conda enviroment using conda pip install, and using conda skeleton to build a conda package from the pypi package, and then add install it to the conda enviroment.
The difference is similar to using Software installer to install packages and apt-get install to install packages in Ubuntu. conda pip transfers whole control to pip for installing the required package whereas, conda skeleton uses functionality of conda itself to do all the necessary work step by step.

conda equivalent of pip install

If I have a directory with setup.py, in pip, I can pip install . in the directory to install the package.
What if I am using conda?
conda install . makes conda to find a package named dot.
conda packages are a different structure than standard python packaging. As a result, the official, recommended and best-practice approach is to use conda to install pip within an activated conda environment, and use that to install standard packages:
conda install pip
NOTE: You want to use conda packages whenever they're available, as they have more features within a conda environment than non-conda packages.
conda install pip will install pip within the currently activated conda environment, and will ensure that it is integrated with conda so that, for example, conda list, will include any packages installed with pip.
NOTE: Commands like conda update will ignore pip installed packages, as it only checks conda channels for available updates, so they still need to be updated using pip. See this Question/Answer discussion:
Does conda update packages from pypi installed using pip install?
NOTE: See #kalefranz comment below regarding conda 4.6 experimental handling of packages.
If you're interested in creating your own conda package(s), take a look at this question/1st answer for a great run-down:
How to install my own python module (package) via conda and watch its changes
If you simply wish to install non-conda packages, using pip is the correct, and expected, way to go.
You can use pip install from within conda environment.
Just activate your environment using:
$ conda activate myenvironment
and use pip install . to install your package in environment's directory.
EDIT: As pointed by Chris Larson in another answert, you should install pip inside the environment using
$ conda install pip
in order to register packages correctly.
If I have a whl file, I can use pip install xxx.whl to install it.
From the documentation, conda install from a local file is also available, but the file should be a tarball file, i.e. .tar.bz2 files.
conda install /package-path/package-filename.tar.bz2 works. And if I have multiple tarballs, I can tar them to get a .tar file, then conda install /packages-path/packages-filename.tar installs the packages in it.

In my anaconda's environment tensor, I have two pips . How can I uninstall the old version? my OS is windows10

There are two pips in my environment, I use the command "conda list" to list them
pip 18.0
pip 9.0.1 py35_1
I want to remove pip 9.0.1, how can I do it?
Have you tried conda uninstall pip=*version*?
You could also run conda uninstall pip (possibly conda uninstall pip*) and remove both versions, then install the latest version of pip after that.
Two versions of pip in a single conda env should not happen through the usual update processes. Either you mistakenly installed the second, or something went very wrong with anaconda. If you suspect that it is something on anaconda's end, then this is a good opportunity for some spring cleaning. Export and then remove the environment, update and clean conda, then either:
Rebuild the environment by removing anything you don't need from your exported environment file and importing this environment again. Then run another conda update --all to ensure you are on the latest version for these packages.
OR Create a fresh environment, manually go through your exported environment and install only your most-used packages. I'd recommend this one, to get a better understanding of what dependencies your projects actually need.
Addendum:
Kota Mori comments that:
Two pip's can happen if you: 1. conda istall pip, then 2. pip install pip --upgrade.
I did not consider this in my original answer. The Conda user guide does not explicitly advise against installing packages through a non-conda version of pip: Anything installed by your pip 18.0, is in the currently active conda environment.
Pip packages do not have all the features of conda packages, and we recommend first trying to install any package with conda. [...] To gain the benefits of conda integration, be sure to install pip inside the currently active conda environment, and then install packages with that instance of pip.
However, (and this is speculation) given that Anaconda aims to simplify package management for Python and R, it may be developed for the pip version delivered by conda. Delivering v10 would then be deliberate. I would personally be wary of unintended side effects and would choose to recreate my environment if I cannot cleanly uninstall v18 and return to v10, or whichever version is currently distributed through conda.

speedml not working with py-xgboost / conda installed py-xgboost is not recognized by pip

I have install py-xgboost from anaconda using:
conda install py-xgboost
where it is shown up when I run
conda list
conda env export
But from pip it doesnt show up:
pip freeze
Is there a way to make pip able to 'see' xg-boost that is installed from a conda package? The reason I need this is because I need speedml which has a dependency on xg-boost and speedml is only available to me from pip (the enterprise anaconda repo do not have speedml).
Thanks!!
This can actually be solved by using
--no-deps
as described in this SO question
So for example what I need is speedml but it requires xgboost then I create the conda environment, installed py-xgboostm, and run the following in same conda env.:
pip install speedml --no-dependencies
And afterwards speedml works!

Use conda or pip in intel-python? [duplicate]

I have installed a fresh anaconda v4.4. I realized that python packages can be installed using both conda and pip. What is the effect of using pip to install python packages instead of conda when using anaconda? Will the pip-installed libraries cease to function? I am using python v3
EDIT: I don't think the question is a duplicate of What is the difference between pip and conda?
That question explains the difference between pip and conda but does not talk about the effect of using pip when conda can be used.
Everything might keep working if you use pip to install vs conda. However, Conda cannot manage dependencies that pip has installed - it cannot upgrade them, or remove them. More importantly, conda will install a package even if its already been installed with pip! Try this test:
conda create -n testenv python=3
conda activate testenv
pip install numpy
conda install scipy
You will see from the third command that conda will want to re-install NumPy, even though it has already been installed with pip. This can cause problems if there are C libraries whose linking is different, or something like that. In general, whenever possible, use conda to install packages into conda environments.

Categories

Resources