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.
Related
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.
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!
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.
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.
Can conda install be used to install source-distributions (i.e. non-archived import packages that have a setup.py)?
Yes and no. You can not conda install per se. However, as the Conda documentation says, Conda ships with pip, so you should be able to pip install -e . your package. You can also install with traditional python setup.py [install|develop].
Remember to activate your Conda environment before installation if you're using one instead of site packages.
As mentioned by vaiski, you can use pip and/or setup.py to build and install the package, but this method is not ideal because packages installed with pip and conda do not respect each other's dependencies.
Thus, if the source distribution includes a conda build recipe (meta.yaml), then you can created the anaconda archive on your own machine by using the conda-build tool:
$ conda build meta.yaml
Afterwards, you will have a local tar.gz of the build package with meta-data that conda can understand. This is what you download from the internet whenever you install a package using conda.
Finally, you can install the package you built locally using:
$ conda install --use-local