`pip install docker-py` vs `pip install 'molecule[docker]'`? - python

I have seen people using pip install docker-py or pip install 'molecule[docker]'.
I believe they are similar (equivalent?)
I read https://molecule.readthedocs.io/en/stable/getting-started.html
which says :
Molecule requires an external Python dependency for the Docker driver which is provided when installing Molecule using pip install 'molecule[docker]'.
so is the molecule[docker] one better in some way ?

pip install molecule[docker] is special pip syntax to say "install the molecule package, with its additional docker option". Using this is almost certainly better than installing molecule with no additional options, and then trying to manually install its Docker dependencies separately.

My guess would be that pip install docker-py install the library globally, or installs the entire library.
Whereas pip install molecule[docker] either only installs the necessary bits for molecule, or it installs it specifically in a molecule location.
I'm more inclined to believe it's the first option - that it saves on space and resources by only installing what is necessary. But that is just my guess.

Related

Installing as many dependencies as possible for pip package using Anaconda

When I use conda environments I often find myself using packages that are only on PyPI requiring pip to install them, but for which many of the dependencies could be installed using conda. If I just install them using pip I'll end up with an environment with several pip-managed packages.
Currently I have to start a pip install (say for torchkge), and notice that it requires for instance pandas and starts downloading it. I ctrl+C and then conda install pandas before redoing the pip install until I see that pip sees that all of the dependencies are satisfied and none need to be installed.
Is there a simple way of doing this dependency check and installing the available dependencies with conda?
You can use below command. For example if I need to check dependencies of Pandas:
pip show pandas
In result set you will find the modules required under Requires keyword.
OR
You can also use pipdeptree
$ pip install pipdeptree
then run
$ pipdeptree
and it will show you your dependencies in a tree form.
For pandas you can check:
$ pipdeptree -p pandas

Install python packages offline on server

I want to install some packages on the server which does not access to internet. so I have to take packages and send them to the server. But I do not know how can I install them.
Download all the packages you need and send them to the server where you need to install them. It doesn't matter if they have *whl or *tar.gz extension. Then install them one by one using pip:
pip install path/to/package
or:
python -m pip install path/to/package
The second option is useful if you have multiple interpreters on the server (e.g. python2 and python3 or multiple versions of either of them). In such case replace python with the one you want to use, e.g:
python3 -m pip install path/to/package
If you have a lot of packages, you can list them in a requirement file as you would normally do when you have access to the internet. Then instead of putting the names of the packages into the file, put the paths to the packages (one path per line). When you have the file, install all packages by typing:
python -m pip install -r requirements.txt
In the requirements file you can also mix between different types of the packages (*whl and *tar.gz). The only thing to take care about is to download the correct versions of the packages you need for the platform you have (64bit packages for 64bit platform etc.).
You can find more information regarding pip install in its documentation.
You can either download the packages from the website and run python setup.py install. Or you can run a pip install on a local dir, such as :
pip install path/to/tar/ball
https://pip.pypa.io/en/stable/reference/pip_install/#usage
Download the wheel packages from https://www.lfd.uci.edu/~gohlke/pythonlibs/ . You may install the .whl packages by pip install (package.whl) , refer installing wheels using pip for more.
Download the package from website and extract the tar ball.
run python setup.py install

Create install package of current pip packages (similar to pip freeze)

I'm needing to create an install package which contains all of the pip packages currently installed. Generally I think of this as using pip freeze > requirements.txt. However since I'm needing the actual install package I then need to do pip download -r requirements.txt.
It seems strange to have to download the packages if they are already on my computer opposed to being able to package them up. This also creates an install .whl for each package opposed to a single one. (This is not a show-stopper)
What is the best method for generating an install package of the current environment for pip packages?

Install python-scipy in a virtualenv

I'm trying making work scipy in my virtualenv but the only way to install it is with apt-get and there is not a way to install it for my virtual env. Doesn't exits a package for pil, so i tried copy the folder
/usr/lib/python2.7/dist-packages/scipy to /home/envs/conbert/lib/python2.7/site-packages but is not working. Is possible make work scipy for a specific environment?
You can install scipy using pip in your virtualenv with
pip install scipy
pip should install all Python dependencies necessary before installing scipy.
Note that you may have to install some extra non-Python dependencies using apt-get. These will be flagged as errors during the pip installation if they're necessary. Possible dependencies may include BLAS, LAPACK, ATLAS, various compilers, etc. Whether these are already installed will depend on what you've already done with your system.

Installing from a specific branch in GitHub. Do I need to specify egg?

I want to install the 2.3 branch of PyMC.
I have tried with:
pip install -e git+git:://github.com/pymc-devs/pymc#2.3
and
pip install git+git:://github.com/pymc-devs/pymc#2.3
without luck. Do I need to specify egg information? If so why?
You have too many colons in your URL:
git+git:://github.com/pymc-devs/pymc#2.3
# ----^
Just one colon is required:
pip install git+git://github.com/pymc-devs/pymc#2.3
or, in editable mode:
pip install -e git+git://github.com/pymc-devs/pymc#2.3
Provided you have a Fortran compiler installed that Just Works.
The #egg=<projectname> part is optional and only used to test for dependencies before downloading. It lets pip test if the package is already installed without needing to clone the whole repository.

Categories

Resources