How to install urllib3[secure] without pip - python

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

Related

why is my pip installing tool not working anymore with python version 3.7

When I run pip3 install -r requirements.txt on a project I get this error message:
pip._vendor.pkg_resources.VersionConflict: (pip 20.2.2
(/usr/local/lib/python3.7/site-packages),
Requirement.parse('pip==20.1.1'))
Why is that happening? I am completely blocked on working on new projects.
My python version is 3.7.8 and I am working on a MAC.
Has this something to do with homebrew python version is now 3.8 what is also installed on my machine.
It looks like pip is mentioned in the requirements.txt file, requiring a specific version of pip. Installation should work when you remove the line which specifies the pip version from requirements.txt.
requirements.txt should mention the packages you need for your project, not the tool which you need to install those requirements. That's kind of self-referencing.
Try upgrading your pip version.
python -m pip install --upgrade pip
If this does pesist, consider using python virtual environments (venv)

Install library / package in python

I'd like to install python bayesian_changepoint_detection, but I can't find instructions for how to install:
https://github.com/hildensia/bayesian_changepoint_detection
I tried
conda install bayesian_changepoint_detection
and
pip install bayesian_changepoint_detection
but it didn't work. Do you know how I should install it? My OS is Ububntu 14.04 LTS. Thanks.
You need to use the install from Github::
pip install git+git#github.com:hildensia/bayesian_changepoint_detection.git
or
pip install git+https://github.com/hildensia/bayesian_changepoint_detection.git
Looking at the content of the package in Github, I see setup.py, which means, that this module should be installed from terminal(after you've downloaded the package), like so:
python setup.py install

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.

Installing pip for an offline machine on Python 2.7, CentOS 6.3

I'm trying to install lxml for Centos6.3, due to this issue. It looks like I've got a conflicting version of pip. The standing solution seems to re-install pip for the correct version of python.
My main issue is that all the methods I've found for installing pip require an internet connection. Is it possible to download pip install files, and then run pip install -U pip and point it at the right files?
The PyPI page for pip only has pip6.11 as a .whl. I've tried running pip install -U pip-6.1.1-py2.py3-none-any.whl and it's not worked.
I'm stumped. How do I install it?
You could try to download pip and setuptools manually from: https://pypi.org/project/pip/#files and https://pypi.org/project/setuptools/#files
get the python pip script from: https://bootstrap.pypa.io/get-pip.py
after that unzip/untar packages and run:
python get-pip.py --no-index --find-links=/path/to/pip-and-setuptools
or alternatively trying:
python setup.py install when running in unpacked folders
More here: https://github.com/pypa/pip/issues/2351

How do I install Python libraries in wheel format?

I was looking for a tutorial on how to install Python libraries in the wheel format.
It does not seem straightforward so I'd appreciate a simple step by step tutorial how to install the module named "requests" for CPython.
I downloaded it from: https://pypi.python.org/pypi/requests and now I have a .whl file. I've got Python 2.7 and 3.3 on Windows, so how do I install it so all the other Python scripts I run can use it?
You want to install a downloaded wheel (.whl) file on Python under Windows?
Install pip on your Python(s) on Windows (on Python 3.4+ it is already included)
Upgrade pip if necessary (on the command line)
pip install -U pip
Install a local wheel file using pip (on the command line)
pip install --no-index --find-links=LocalPathToWheelFile PackageName
Option --no-index tells pip to not look on pypi.python.org (which would fail for many packages if you have no compiler installed), --find-links then tells pip where to look for instead. PackageName is the name of the package (numpy, scipy, .. first part or whole of wheel file name). For more informations see the install options of pip.
You can execute these commands in the command prompt when switching to your Scripts folder of your Python installation.
Example:
cd C:\Python27\Scripts
pip install -U pip
pip install --no-index --find-links=LocalPathToWheelFile PackageName
Note: It can still be that the package does not install on Windows because it may contain C/C++ source files which need to be compiled. You would need then to make sure a compiler is installed. Often searching for alternative pre-compiled distributions is the fastest way out.
For example numpy-1.9.2+mkl-cp27-none-win_amd64.whl has PackageName numpy.
If you want to be relax for installing libraries for python.
You should using pip, that is python installer package.
To install pip:
Download ez_setup.py and then run:
python ez_setup.py
Then download get-pip.py and run:
python get-pip.py
upgrade installed setuptools by pip:
pip install setuptools --upgrade
If you got this error:
Wheel installs require setuptools >= 0.8 for dist-info support.
pip's wheel support requires setuptools >= 0.8 for dist-info support.
Add --no-use-wheel to above cmd:
pip install setuptools --no-use-wheel --upgrade
Now, you can install libraries for python, just by:
pip install library_name
For example:
pip install requests
Note that to install some library may they need to compile, so you need to have compiler.
On windows there is a site for Unofficial Windows Binaries for Python Extension Packages that have huge python packages and complied python packages for windows.
For example to install pip using this site, just download and install setuptools and pip installer from that.
To install wheel packages in python 2.7x:
Install python 2.7x (i would recommend python 2.78) - download the appropriate python binary for your version of windows . You can download python 2.78 at this site https://www.python.org/download/releases/2.7.8/
-I would recommend installing the graphical Tk module, and including python 2.78 in the windows path (environment variables) during installation.
Install get-pip.py and setuptools
Download the installer at
https://bootstrap.pypa.io/get-pip.py
Double click the above file to run it. It will install pip and setuptools [or update them, if you have an earlier version of either]
-Double click the above file and wait - it will open a black window and print will scroll across the screen as it downloads and installs [or updates] pip and setuptools --->when it finishes the window will close.
Open an elevated command prompt - click on windows start icon, enter cmd in the search field (but do not press enter), then press ctrl+shift+. Click 'yes' when the uac box appears.
A-type
cd c:\python27\scripts
[or cd \scripts ]
B-type
pip install -u
Eg to install pyside, type pip install -u pyside
Wait - it will state 'downloading PySide or -->it will download and install the appropriate version of the python package [the one that corresponds to your version of python and windows.]
Note - if you have downloaded the .whl file and saved it locally on your hard drive, type in
pip install --no-index --find-links=localpathtowheelfile packagename
**to install a previously downloaded wheel package you need to type in the following command
pip install --no-index --find-links=localpathtowheelfile packagename
Have you checked this http://docs.python.org/2/install/ ?
First you have to install the module
$ pip install requests
Then, before using it you must import it from your program.
from requests import requests
Note that your modules must be in the same directory.
Then you can use it.
For this part you have to check for the documentation.
Install distribute by downloading and running distribute_setup.py. This will make easy_install available, and from there you can install pip with easy_install pip. Then you can run pip install CAGE. Using pip to install things is a lot easier than messing with manually running setup.py, because pip can do things like:
automatically resolve dependencies
show you a list of all installed packages and their versions
install a set of specified packages from a requirements.txt
upgrade and uninstall packages
work with virtualenv
If you're on Windows, the one downside of pip occurs when there are C library dependencies, as pip will want a C toolchain installed so it can compile things. If that is the case, then there are two options. If there are precompiled binaries on PyPI, then just run easy_install package instead; easy_install knows how to use binary packages. You can also check Christoph Gohlke's site for executable installers of many binary packages. These can also be installed by easy_install if you want to use them with a virtualenv (just point it to the path of the .exe) or you can click and run if you don't care about virtualenv.
The main point is that no matter what route you choose to install packages, at no point are you ever moving around files by hand. You need to get out of the mindset of "I extracted this archive, where do I put these .py files?" That's not how it works. You're either running pip, running easy_install, running setup.py, clicking on an installer package, or using your distribution's installer. At no point are you ever doing anything by hand with the files directly.
Once you have a library downloaded you can execute this from the MS-DOS command box:
python setup.py install
The setup.py is located inside every library main folder.
For windows, there are automatic installer packages available at this site
It includes most of the python packages.
But the best way for it is of course using pip.
You don't need to download exclusively from the website. Just make sure you have pip (which you probably will if you have python installed). Just open your Command Prompt (CMD) and run the command:
pip install pygame
It will automatically download the correct whl version of pygame compatible with your configuration of PC. Make sure you remember the version which appears while "downloading" as this is the compatible version of .whl packages you shall be looking for in the future.
Simple steps to install python in Ubuntu:
Download Python
$ cd /usr/src
$ wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz
Extract the downloaded package
$ sudo tar xzf Python-3.6.0.tgz
Compile Python source
$ cd Python-3.6.0
$ sudo ./configure
$ sudo make altinstall
Note make altinstall is used to prevent replacing the default python binary file /usr/bin/python.
check the python version
# python3.6 -V
i have write the answer here
How to add/use libraries in Python (3.5.1)
but no problem will rewrite it again
if u have or you can create a file requirements.txt which contains the libraries that you want to install for ex:
numpy==1.14.2
Pillow==5.1.0
You gonna situate in your folder which contains that requirements.txt in my case the path to my project is
C:\Users\LE\Desktop\Projet2_Sig_Exo3\exo 3\k-means
now just type
python -m pip install -r ./requirements.txt
and all the libararies that you want gonna install
C:\Users\LE\Desktop\Projet2_Sig_Exo3\exo 3\k-means>python -m pip install -r ./requirements.txt

Categories