How to correctly use pip install --download? [closed] - python

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I have pip installed on Windows (bundled with ActivePython), Debian 7 (installed via sudo apt-get install python-pip) and OSX 10.8 (installed via easy_install pip).
I want to download mercurial package without installing it (just a .tar.gaz archive) so i issued following documented command:
pip install --download=. mercurial
On Windows it works, but no file appears in current directory. On Debian and OSX it fails like this:
Downloading/unpacking mercurial
Running setup.py egg_info for package mercurial
...
lots of text, complains about no headers to compile
What i'm doing wrong? I was sure that pip is not supposed to actually run something with --download command, but it seems that on both Debian and OSX it is trying to install package after downloading :(.

It doesn't actually build and install the package, but it does do the egg_info step, if that's available for your package on your platform. You can see this from your output (or from ~/.pip/pip.log):
Running setup.py egg_info for package mercurial
…
Command python setup.py egg_info failed with error code 1 in /var/folders/fl/kgrflrj92pv1yjr_918x0t800000gq/T/pip-build/mercurial
Whether that step succeeds or fails, you still end up with nothing installed to site-packages. However, you may not end up with the tarball in your target directory unless it succeeds. (From a very quick test, it looks like 1.2.1 and 1.4dev1 under Python 2.7.2 both fail to copy the tarball to the target if it fails, while 1.4dev1 under 3.3.0 copies it ether way… But that may be misleading; it's possible that the difference has to do with whether the tarball is already in the download-cache or something…)

Related

How to install python packages in a private network [duplicate]

This question already has answers here:
How to install packages offline?
(12 answers)
Closed 3 years ago.
I'm an experienced programmer, but very new to python. My company requires us to do development on a private network for some of our projects. There is a pypi index on the private network which can be used to install packages using pip. Recently, while needing to install a package, the pypi index when down and was down for several hours. Although it did come back up eventually, the situation begs the question, how do I install packages (maybe manually without pip) in the absense of an index? I've tried to google this, but came up empty. I'm sure there's a way, but I'm probably not searching for the right phrase. Thanks for any help with.
You can manually install Python packages if you have read access to the package repositories. Every Python package has a setup.py file in the root directory and you can do something like
python setup.py sdist
This creates a subdirectory called dist which contains a compressed archived file, tar.gz or .zip depending in your OS. You can pass this archived file to pip and install the package
pip3 install some-python-package.tar.gz
I would download the wheel and install that. For this to you do need to install the wheel package:
pip install wheel
You can then tell pip to install the project (and it'll download the wheel if available), or the wheel file directly:
pip install project_name # download and install
pip install wheel_file.whl # directly install the wheel
The wheel module is also runnable from the command line and you can use it to install already-downloaded wheels:
python -m wheel install wheel_file.whl
There are a few ways you can get around this issue. The two that I know of are:
Use a proxy to get to the standard PyPI. If your company permits it, then you can tunnel your traffic through their proxy and install packages from PyPA's standard locations.
Use a locally hosted index. All you need is a directory structured like https://pypi.org/simple/, and you can then pip install -i ~/my/personal/index/path and packages will be installed from there.

Brew not installing the latest version [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I am trying to get that latest version of python on a Mac Mountain Lion. But the latest version is 2.7.4, but when I run brew install python it downloads the 2.7.2. What is going on?
brew install python
==> Downloading http://www.python.org/ftp/python/2.7.2/Python-2.7.2.tar.bz2
File already downloaded in /Users/pietro/Library/Caches/Homebrew
==> Patching patching file Lib/whichdb.py
Hunk #1 succeeded at 91 with fuzz 1.
==> ./configure --prefix=/usr/local/Cellar/python/2.7.2 --enable-shared
==> make
==> make install
==> Downloading http://pypi.python.org/packages/source/d/distribute/distribute-0.6.24.tar.gz
File already downloaded in /Users/pietro/Library/Caches/Homebrew
==> /usr/local/Cellar/python/2.7.2/bin/python setup.py install
==> Caveats
A "distutils.cfg" has been written to: /usr/local/Cellar/python/2.7.2/lib/python2.7/distutils specifing the
install-scripts folder as: /usr/local/share/python
If you install Python packages via "python setup.py install",
easy_install, pip, any provided scripts will go into the
install-scripts folder above, so you may want to add it to your PATH.
Distribute has been installed, so easy_install is available. To update
distribute itself outside of Homebrew:
/usr/local/share/python/easy_install pip
/usr/local/share/python/pip install --upgrade distribute
See: https://github.com/mxcl/homebrew/wiki/Homebrew-and-Python
==> Summary
/usr/local/Cellar/python/2.7.2: 4803 files, 81M, built in 2.4 minutes
Have you updated Homebrew lately (by running brew up)? 2.7.4 is the current Python version in Homebrew.

Python install issue on Mac OS X [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I have been using the standard python that comes with OS X Lion (2.7.2) but I wanted to build a UCS-4 version to handle 4-byte unicode characters better.
I had already installed pip and packages like pytz, virtualenv and virtualenvwrapper, etc., and these are installed in /Library/Python/2.7/site-packages. My $PATH is /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin.
To build a new version of python on the machine (outside of any project specific virtual environments, that will come later), I followed the instructions on this article and managed to build it in /usr/local/bin. The problem is that when I launched a new bash window, I got the following virtualenvwrapper error:
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named virtualenvwrapper.hook_loader virtualenvwrapper.sh: There was a problem running the initialization hooks.
If Python could not import the module virtualenvwrapper.hook_loader, check that virtualenv has been installed for VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python and that PATH is set properly.
The instructions said to move /usr/local/bin to the top of the /etc/paths file, and since then I've noticed some strange issues. I installed pip into /usr/local/bin and now I have assumed that since I'm working in /usr/local/bin, and the newly installed python's site packages is now located in /usr/local/lib/python2.7/site-packages, when I do pip freeze, it should be empty as nothing is installed there yet. However, pip freeze still reports things installed in the old (OS X) site-packages folder. Here's some info after the build:
$ which python
/usr/local/bin/python
$ which pip
/usr/local/bin/pip
$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
When I uninstall a python package with pip, it removes it from the old site-packages folder as expected. When I install it again, instead of installing it in /usr/local/lib/python2.7/site-packages, it installs it in /Library/Python/2.7/site-packages (verified by attempting to install it again and receiving Requirement already satisfied (use --upgrade to upgrade): pytz in /Library/Python/2.7/site-packages
). How is it getting that path for the old site-packages folder? Why won't it install it in the correct location for the python install it's using?
I'm getting several other issues since promoting /usr/local/bin but I think if I understand this I'll be able to get somewhere.
Can anyone see what's happening? If you need any more info I'll be happy to provide it.
Since you will be using the custom python installation as your main one, I suggest you uninstall all non-standard packages from the system python and make sure that the existing easy_install.py is gone (possibly by manually removing it). Then download distribute's distribute_setup.py and run it with the new interpreter. From then on everything should work as expected.

while installing python2.6 getting error on ubuntu 12.04 [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
"I am using ubuntu 12.04 and by default python 2.7 is installed .I want python 2.6 .
When I used
apt-get install python2.6
I am getting error
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package python2.6 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
python-gdbm
E: Package 'python2.6' has no installation candidate
Thanks in advance."
As per the Ubuntu Wiki - Python Toolchain, Python 2.6 is no longer available in the repository.
Either:
You can simply build it from source by downloading the tarball from
Python 2.6.7
You need to find out some repository which might have an older version of
Python. One alternative is
https://launchpad.net/~fkrull/+archive/deadsnakes
You need to install the PPA
sudo add-apt-repository ppa:fkrull/deadsnakes
Run Update:
sudo apt-get update
And then install the version you are looking for
sudo apt-get install python2.6 python2.6-dev

How to cache downloaded PIP packages [duplicate]

This question already has answers here:
How do I install from a local cache with pip?
(11 answers)
Closed 9 years ago.
The community reviewed whether to reopen this question 1 year ago and left it closed:
Original close reason(s) were not resolved
How do you prevent PIP from re-downloading previously downloaded packages? I'm testing the install of matplotlib, an 11MB package that depends on several distro-specific packages. Everytime I run pip install matplotlib, it re-downloads matplotlib. How do I stop this?
NOTE: Only wheels downloaded over HTTPS are cached. If you are using a custom repo over plain old HTTP, the cache is disabled.
For new Pip versions:
Newer Pip versions by default now cache downloads. See this documentation:
https://pip.pypa.io/en/stable/topics/caching/
For old Pip versions:
Create a configuration file named ~/.pip/pip.conf, and add the following contents:
[global]
download_cache = ~/.cache/pip
In one command:
printf '[global]\ndownload_cache = ~/.cache/pip\n' >> ~/.pip/pip.conf
You can use a specific environment variable PIP_DOWNLOAD_CACHE and make it point to a directory where your packages will be stored. If they are to be installed again, they will be taken from this directory.
There seems to be also an additional option for PIP pip --download-cache which ought to do something similar, but I have never tried it myself. For your example, to avoid re-downloading matplotlib every time, you would do the following:
pip install --download-cache /path/to/pip/cache matplotlib
Does that answer your question?
You could
# download and extract package to build path
pip install --no-install matplotlib
# the build path could be found by
pip install --help|grep Unpack\ packages\ into -A 2
# then rm pip-delete-this-directory.txt inside the build path
# this prevent pip from removing package from the build directory after install
# you could check the content of the file
rm build/pip-delete-this-directory.txt
# from now on you could install matplotlib quickly
# this uses single build directory
# and can speed up compiling by caching intermediate objects.
pip install --no-download matplotlib
Also, you could manually download the package
pip install -d dir_for_packages matplotlib
Then install it by un-tar and python setup install later.
The pip install --download-cache works in a similar way w/ extra checking: it firstly search for the latest or specified version of the target package from web, if the search has result and there is cached package in the directory specified by download-cache, the cached package will be used instead of downloading. For example,
pip install --download-cache . pymongo
will download pymongo package to current directory:
http%3A%2F%2Fpypi.python.org%2Fpackages%2Fsource%2Fp%2Fpymongo%2Fpymongo-2.1.1.tar.gz
http%3A%2F%2Fpypi.python.org%2Fpackages%2Fsource%2Fp%2Fpymongo%2Fpymongo-2.1.1.tar.gz.content-type

Categories

Resources