Installing specific package versions with pip from git private repo - python

I'm deploying some custom packages with pip straight from my company's private git repo (and it's awesome). But what if I want to install a specific version of my package?
This question completements Specify extras_require with pip install -e.
I'm trying to install it with:
pip install git+https://github.com/user/project.git#egg=project==0.0.1[extra]
But I get a ERROR: Invalid requirement: 'project==0.0.1[extra]' message.
Thanks!

Easy enough:
pip install git+https://github.com/user/project.git#v0.0.1#egg=project[extra]
Of course, assuming version 0.0.1 exists.
If your project is in a subfolder:
pip install "git+https://github.com/user/project.git#v0.0.1#egg=project[extra]&subdirectory=my_subprojects/subproject"
From the documentation

Related

pip install: trying to install multiple version of same package from private pypi

I've a private pypi, and keep uploading new package framework to that registry.
I want to install the latest package in a virtualenv.
Command used:
pip install -i https://user:pass#registry framework
OUTPUT:
Collecting framework:
... downloads many versions
ERROR: Cannot install framework==0.25.13, framework==0.25.14 and framework==0.26.0 because these package versions have conflicting dependencies.
The conflict is caused by:
framework 0.26.0 depends on toolz<0.12.0 and >=0.11.1
framework 0.25.14 depends on toolz<0.12.0 and >=0.11.1
framework 0.25.13 depends on toolz<0.12.0 and >=0.11.1
To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict
ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/user_guide/#fixing-conflicting-dependencies
I want only the latest version to be downloaded. I cannot hard-code version like framework==0.26.0 while pip install because this command is to be used in script and I may need to modify the script everytime a new framework get uploaded.
pip version: pip 21.1.2
The solution that worked for this problem was using --extra-index-url instead of -i
Command to use
pip install --extra-index-url https://user:pass#registry framework

How to ignore my development project for installing a package with pip

I uploaded my package to testpypi, and installed it via:
pip install -i https://test.pypi.org/simple/ myporj==0.1.6
However it refuse to install it by saying:
Requirement already satisfied: myproj==0.1.6 in ./projs/myproj (0.1.6)
I guess I may add the project in editable mode:
pip install --editable .
However, I know want to disable it. I tried:
python setup.py develop --uninstall
But it has no effect.
It may be worth creating a separate env (Virtual Environments) for the installation.
Here are some articles on this subject:
https://docs.python.org/3/tutorial/venv.html
https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/#creating-a-virtual-environment
Or does it need to be installed in the same place?
You can try to find your package pip search myporj or pip list for show all packages.
And uninstall it later pip uninstall myporj (it may require the right of sudo in linux) then install again.
Maybe you may need --no-cache-dir option to ignore the cache during installation. Here is more details: https://pip.pypa.io/en/stable/reference/pip_install/#caching

How to install urllib3[secure] without pip

I have a old RHEL5 box running python 2.7 and I have to do a local install as the regular python site-packages are on a NFS filer I cannot write to. I need to install urllib3 and according to this doc: https://urllib3.readthedocs.io/en/latest/user-guide.html#ssl-py2
I should execute:
pip install urllib3[secure]
But I cannot figure out how to get pip to install one of my local filesystems. I have done ...
python setup.py install --prefix=/apps/local_packages
But I do not know how to get the "secure" install using setup.py.
python setup.py install[secure] --prefix=/apps/local_packages
doesn't work.
You can install pip by using get-pip from documentation.
And [secure] is using for install dependencies starting from 1.11 (2015-07-21) version

No module named google.protobuf

I am trying to run Google's deep dream. For some odd reason I keep getting
ImportError: No module named google.protobuf
after trying to import protobuf. I have installed protobuf using sudo install protobuf. I am running python 2.7 OSX Yosemite 10.10.3.
I think it may be a deployment location issue but i cant find anything on the web about it. Currently deploying to /usr/local/lib/python2.7/site-packages.
There is another possibility, if you are running a python 2.7.11 or other similar versions,
sudo pip install protobuf
is ok.
But if you are in a anaconda environment, you should use
conda install protobuf
Locating the google directory in the site-packages directory (for the proper latter directory, of course) and manually creating an (empty) __init__.py resolved this issue for me.
(Note that within this directory is the protobuf directory but my installation of Python 2.7 did not accept the new-style packages so the __init__.py was required, even if empty, to identify the folder as a package folder.)
...In case this helps anyone in the future.
In my case I
downloaded the source code, compiled and installed:
$ ./configure
$ make
$ make check
$ sudo make install`
for python I located its folder(python) under source code, and ran commands:
$ python setup.py build
$ python setup.py install'
Not sure if this could help you..
I got the same error message when I tried to use Tensor Flow. The solution was simply to uninstall Tensor Flow and protobuf:
$ sudo pip uninstall protobuf
$ sudo pip uninstall tensorflow
And reinstall it again: pip installation of Tensorflow. Currently, this is:
# Ubuntu/Linux 64-bit, CPU only:
$ sudo pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.8.0rc0-cp27-none-linux_x86_64.whl
# Ubuntu/Linux 64-bit, GPU enabled:
$ sudo pip install --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.8.0rc0-cp27-none-linux_x86_64.whl
# Mac OS X, CPU only:
$ sudo easy_install --upgrade six
$ sudo pip install --upgrade https://storage.googleapis.com/tensorflow/mac/tensorflow-0.8.0rc0-py2-none-any.whl
when I command pip install protobuf, I get the error:
Cannot uninstall 'six'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
If you have the same problem as me, you should do the following commands.
pip install --ignore-installed six
sudo pip install protobuf
According to your comments, you have multiply versions of python
what could happend is that you install the package with pip of anthor python
pip is actually link to script that donwload and install your package.
two possible solutions:
go to $(PYTHONPATH)/Scripts and run pip from that folder that way you insure
you use the correct pip
create alias to pip which points to $(PYTHONPATH)/Scripts/pip and then run pip install
how will you know it worked?
Simple if the new pip is used the package will be install successfully, otherwise the package is already installed
I installed the protobuf with this command:
conda install -c anaconda protobuf=2.6.1
(you should check the version of protobuf)
In my case, MacOS has the permission control.
sudo -H pip3 install protobuf
I had this problem to when I had a google.py file in my project files.
It is quite easy to reproduce.
main.py: import tensorflow as tf
google.py: print("Protobuf error due to google.py")
Not sure if this is a bug and where to report it.

pip install private package

I have one python package A which has depends on another private package named godot(hosted at bitbucket, and should be accessed by git+ssh protocol). In package A's setup.py, I have following code:
...
install_requires=['godot'],
dependency_links=['git+ssh://git#bitbucket.org/xxx/godot.git#egg=godot']
...
I have two questions here:
Now setuptools 1.4 (latest stable version) does not support 'git+ssh' protocol, only code in the development branch handle this protocol: Python setuptools: How can I list a private repository under install_requires?. I have installed the development version via:
pip install --upgrade --force-reinstall hg+https://bitbucket.org/pypa/setuptools#egg=setuptools
I almost solved this bit, but I wonder If any other approach available? Invoke pip install -r requirements.txt(have git+ssh://git#bitbucket.org/xxx/godot.git#egg=godot list in requirements.txt)?
The second question is name conflict. There is another package on pypi also named godot, So when I install package A using follow command, pip install the godot from pypi index:
pip install git+ssh://git#pypi.corp.com/xxx/A.git#egg=A
How could force pip(setup.py) to install the private godot package, rather than the one on pypi index?
For part 1: you can install packages via pip by specifying as:
$ pip install http://my.package.repo/SomePackage-1.0.4.zip
To keep it simple and avoid spending undue time on it, I would just download the .zip source file and install via pip as above.
See here...
For part 2: pip has a --no-dependencies switch. Add that after installing all the dependencies manually

Categories