How can I install a PyPI package while using Anaconda dependencies? - python

When I install a package through pip (since it was not available on Anaconda), it also pulls all dependencies. It seems it will use the pip versions of the dependencies, even if conda versions (same name) are available.
How can I easily install a pip package, but use conda for the dependencies where such a package exists?

There is no easy way, I suspect. Create a virtual environment, install all anticipated dependencies using conda and then install the main package using pip without -U/--upgrade. pip seeing dependencies installed will not install them again.

Related

Use Anaconda package manager in Winpython

I'm using Winpython to do a project but i'm struggling to install a package with pip. This package is easily installed using "conda install" in my Anaconda. I would like to know if there is some way to use the conda package manager in Winpython (i.e install package using conda install in Winpython)
No. Depending of what you miss:
download big binary packages from https://www.lfd.uci.edu/~gohlke/pythonlibs/ in a local directory "d:\toto"
"pip install --pre --no-index --trusted-host=None --find-links=d:\toto your_package"
or
"pip install d:\toto\your_package_wheel_exact_name"

Can I use pip in a conda environment?

I am using a conda environment to install a package and this package have dependencies that's not available in conda, so I have to use pip to install some additional packages in the conda environment. After I did all these:
I tested both:
pip list
and
conda list
And found that some dependencies occur in pip list but not in conda list. Is this OK? Do the packages installed by pip in conda enviroment also effect in this envorment?
Yes, I use a combination of pip install and conda install when setting up the environment for a project I'm working on. It works fine.
However, it is documented here that this combination can lead to issues: https://www.anaconda.com/blog/using-pip-in-a-conda-environment
According to that doc, you ought to first use conda to install as many of your packages as possible, then use pip to install the rest afterwards.

What is the effect of using pip to install python packages on anaconda?

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.

Installing python pip package from tar.gz with extra includes

I have a python package being built, which also has two options for extra_includes:
name='mypackage',
extras_require={
'option_one': ['dep1'],
'option_two': ['dep2']
}
I only have access to the tar.gz built package which means I cannot simply do:
pip install mypackage[option_two]
Previously, I was directly installing this directly from the tar.gz:
pip install path/to/mypackage.tar.gz
However, this no longer allows me to specify the extra_require like:
pip install path/to/mypackage.tar.gz[option_two] # this is wrong
I could expand the package and do a manual install from the directory but is there a way to more directly install from the tar.gz itself?
From the pip changelog:
7.0.0 (2015-05-21)
Allowing using extras when installing from a file path without requiring the use of an editable (PR #2785).
Some Linux distros bundle very old versions of pip when using the system packages for virtualenv or venv. Update pip after creating your env.
pip install -U pip
pip install package.tar.gz[name]

How to Uninstall setuptools python

Hi recently i installed setup tools module and google app engine gives me errors . Is there a way to uninstall setuptool? can any one tell me step by step because i tried hard
The answer depends on how it was installed.
If it was installed using the ubuntu (debian) package manager, try:
sudo apt-get remove --purge python-setuptools
[updated]
If you installed manually, probably the setuptools final location will be something like (adjust for your environment/python version):
/usr/local/lib/python2.6/dist-packages
Just delete the setuptools stuff there.
Lame, I know, but it is your burden for not using the excellent package manager provided by ubuntu: stick to dpkg unless you need bleeding edge stuff. For other python modules installed by setuptools, it provides no "uninstall" feature (but pip does, that is why there is a lot of enthusiasm around virtualenv, pip and yolk).
[2017 update]
It is 2017 and installing Python modules changed a bit:
pip is now the preferred installer program. Starting with Python 3.4, it is included by default with the Python binary installers.
venv is the standard tool for creating virtual environments (semi-isolated Python environments that allow packages to be installed for use by a particular application, rather than being installed system wide), and has been part of Python since Python 3.3. Starting with Python 3.4, it defaults to installing pip into all created virtual environments.
virtualenv is a third party alternative (and predecessor) to venv and if not official it is still very popular because it allows virtual environments to be used on versions of Python prior to 3.4, which either don’t provide venv at all, or aren’t able to automatically install pip into created environments.
easy_install pip
pip uninstall pip setuptools
(pip and setuptools both use the same package formats, but pip has uninstall support. kinda hilarious that installing something is the easiest way to uninstall.)
I was having trouble with the method below because my pip wasn't up to date.
easy_install pip
pip uninstall pip setuptools
After upgrading pip like this:
sudo -H pip install --upgrade pip
I was able to successfully uninstall setuptools like so:
pip uninstall setuptools

Categories