Does pip only use PyPI or does it use other domains to find packages? - pip

I know that by default, pip uses PyPI to look for packages. I would like to know if there are other domains other than PypI that pip uses.

PIP Can install from
PyPI
VCS project URL
Local project directories
Local or remote source archives
to run from a local passage you can input pip install /opt/mypackage
Finally, run pip install --help to see all installation options

PIP can install from many different sources. You can find the whole list here
You can also setup your own Python package repository and configure pip to install from there.

Related

How to avoid pip install package again while conda install was done before?

guys:
I use conda install tensorflow-gputo install tensorflow 2.0 , and
numpy=1.20.2 would be one of the package installed, and then I use python3 -m pip install SOMEPACKAGE ,this SOMEPACKAGE needs numpy to be installed as well , but pip seems does not check or realize the package numpy has already installed...
I would like to show everything I know so far :
1.I know the packages installed via conda install would go to anaconda3/envs/YOUR_ENV/lib/site-packages
2.I use python3 -m pip install -t anaconda3/envs/YOUR_ENV/lib/site-packages to force the package would be installed to the place where conda install would be.
However,pip still tries to dwonload *.whl file and install package again,I do not want this package installation process happen again ,while it did mention that I can use --upgrade to replace the existed package...
So I would like to know
How does pip and conda install check if the target package has already existed before they actually to through install process?
I think using python3 you are not using interpreter from your current conda environment so it gets installed elsewhere
python -m pip install (or simply pip install) from your activated environment should work and ignore dependencies installed by conda if they satisfy the requirements

installing python package from a github subdirectory on another branch

So I have a python package in a url which is something like this
https://github.com/my_profile/repo/tree/not_master_branch/folder_1/package
I know to install a package via pip it's:
pip install git+https://github.com/user/repo.git#branch
but how do I specify the folders?
python -m pip install 'git+https://github.com/user/repo.git#branch#subdirectory=folder_1/package'
Reference:
https://pip.pypa.io/en/stable/reference/pip_install/?highlight=subdirectory#vcs-support

how to uninstall packages installed with pip3 and it's dependencies?

I was installing apache-airflow in my centOS 8. Only pip3 works in my environment. I did something with the environment variable which created two config files for airflow. I am not able to find another config file to delete it. So, I was trying to uninstall airflow. I used
pip3 uninstall apache-airflow
It removed the package but still, the other dependent files that were installed are there. I googled and found pip-autoremove but it doesn't work for pip3.
I am trying to find a way to clean install airflow again by removing all the old files, dependent packages. Is there a way to use autoremove in pip3 or are there any other alternatives for my issue?
Maybe if you make a new Virtual Environment and then install your package inside it.
python3 -m venv /path/to/new/virtual/environment
source <venv>/bin/activate.csh
pip3 install apache-airflow
pip3 freeze > dependencies.txt
Then make a pip freeze and now you can delete all installed packages (which are apache-airflow and its dependencies) in you working environment. So you can go to your working environment and just delete them:
pip3 uninstall -r <path>/dependencies.txt
Delete all the files under $AIRFLOW_HOME (default path: ~/airflow). Airflow will look for config file at $AIRFLOW_HOME/airflow.cfg. So reinstall airflow, set $AIRFLOW_HOME to the place where you want to have all your config files and DAGs as mentioned in https://airflow.apache.org/start.html.

How do I check, using terminal what sudo pip packages I've installed?

How do I check what sudo pip packages I've installed on my mac?
Check the usage:
$ pip
Usage:
pip <command> [options]
Commands:
install Install packages.
download Download packages.
uninstall Uninstall packages.
freeze Output installed packages in requirements format.
list List installed packages.
show Show information about installed packages.
check Verify installed packages have compatible dependencies.
config Manage local and global configuration.
search Search PyPI for packages.
wheel Build wheels from your requirements.
hash Compute hashes of package archives.
completion A helper command used for command completion.
help Show help for commands.
The one you want is sudo pip list.

Installing Python Package to Conda Env Without Using Conda

I have a fresh Anaconda environment in which I would like to install the latest release of mysql-connector-python (v2.1.3). I'm on a CentOS6 system. The problem is, the newest Conda-hosted package is 2.0.3 and because the connector is not currently hosted on PyPI, it cannot be installed via Pip. (Pip's --allow-external option has been deprecated.)
I know that I can easily install the package via yum install, but I believe that will install it outside of the Conda environment.
Is there any way, using yum or otherwise, to isolate this package solely to this particular Conda environment?
Turns out this is surprisingly simple. Just download the source for the Python package that is not available on PyPI and pip install at the source directory. Just remember to have the Conda environment you want to install to active and Pip will correctly isolate the install to env scope.
I was unaware of Pip's install from local options, so big thanks to the folks on the Anaconda mailing list for their help with this.

Resources