Installing request module in python 2.7 windows 10 - python-2.7

I have installed python 2.7,added the path in environment variables trying to import requests module in python IDLE.
To install requests module i am trying to use
python -m pip install requests
but i am getting error
Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x040C7530>, 'Connection to pypi.python.org timed out. (connect timeout=15)')': /simple/requests/
Could not find a version that satisfies the requirement requests (from versions: )
No matching distribution found for requests
please help me what can i do

This answer won't tell you why you are getting that error, but suggests a workaround at the end.
Just a wild guess but perhaps the error is caused by not having the correct version of pip?
Python : ImportError: No module named requests

Related

Can't install Python 2.7.x using pyenv

I am trying to use pyenv to install Python2.7. It fails, it seems, due to inabilities to download a compatible version of pip. I have already downgraded to pip version 20.3.4, but can't figure out how to tell pyenv this:
pyenv install 2.7.7
Installing openssl-1.0.2k...
Installed openssl-1.0.2k to /Users/username/.pyenv/versions/2.7.7
python-build: use readline from homebrew
Installing Python-2.7.7...
patching file ./Lib/site.py
patching file ./Lib/ssl.py
patching file ./Modules/_ssl.c
python-build: use tcl-tk from homebrew
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
WARNING: The Python sqlite3 extension was not compiled. Missing the SQLite3 lib?
Installing pip from https://bootstrap.pypa.io/pip/2.7/get-pip.py...
error: failed to install pip via get-pip.py
BUILD FAILED (OS X 12.6.2 using python-build 20180424)
Inspect or clean up the working tree at /var/folders/xl/3b9jpy1x5sq6gr7b_qzw1pkm0000gn/T/python-build.20221225200507.60628
Results logged to /var/folders/xl/3b9jpy1x5sq6gr7b_qzw1pkm0000gn/T/python-build.20221225200507.60628.log
Last 10 log lines:
WARNING: Certificate did not match expected hostname: pypi.org. Certificate: {'notAfter': 'Aug 27 18:45:09 2023 GMT', 'subjectAltName': (('DNS', 'www.python.org'), ('DNS', '*.python.org'), ('DNS', 'docs.python.org'), ('DNS', 'downloads.python.org'), ('DNS', 'pypi.python.org')), 'subject': ((('commonName', u'www.python.org'),),)}
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(CertificateError("hostname 'pypi.org' doesn't match either of 'www.python.org', '*.python.org', 'docs.python.org', 'downloads.python.org', 'pypi.python.org'",),)': /simple/pip/
/var/folders/xl/3b9jpy1x5sq6gr7b_qzw1pkm0000gn/T/tmpiEoxv0/pip.zip/pip/_vendor/urllib3/util/ssl_.py:164: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
WARNING: Certificate did not match expected hostname: pypi.org. Certificate: {'notAfter': 'Aug 27 18:45:09 2023 GMT', 'subjectAltName': (('DNS', 'www.python.org'), ('DNS', '*.python.org'), ('DNS', 'docs.python.org'), ('DNS', 'downloads.python.org'), ('DNS', 'pypi.python.org')), 'subject': ((('commonName', u'www.python.org'),),)}
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(CertificateError("hostname 'pypi.org' doesn't match either of 'www.python.org', '*.python.org', 'docs.python.org', 'downloads.python.org', 'pypi.python.org'",),)': /simple/pip/
/var/folders/xl/3b9jpy1x5sq6gr7b_qzw1pkm0000gn/T/tmpiEoxv0/pip.zip/pip/_vendor/urllib3/util/ssl_.py:164: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
WARNING: Certificate did not match expected hostname: pypi.org. Certificate: {'notAfter': 'Aug 27 18:45:09 2023 GMT', 'subjectAltName': (('DNS', 'www.python.org'), ('DNS', '*.python.org'), ('DNS', 'docs.python.org'), ('DNS', 'downloads.python.org'), ('DNS', 'pypi.python.org')), 'subject': ((('commonName', u'www.python.org'),),)}
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError(CertificateError("hostname 'pypi.org' doesn't match either of 'www.python.org', '*.python.org', 'docs.python.org', 'downloads.python.org', 'pypi.python.org'",),)) - skipping
ERROR: Could not find a version that satisfies the requirement pip<21.0 (from versions: none)
ERROR: No matching distribution found for pip<21.0
I'm on Mac 12.6

Pproblem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443):

so I am using Pycharm 2019.2 with Python 2.7
and I can't download any package.
I have tried:
hard copying packages to Python2.7 directory
pip install urllib3[secure]
pip install --trusted-host=pypi.python.org --trusted-host=pypi.org
--trusted-host=files.pythonhosted.org xlrd
all refused to connect with errors like this:
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '_ssl.c:499: error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version'),)': /simple/xlrd/
C:\Python27\lib\site-packages\pip-19.0.3-py2.7.egg\pip\_vendor\urllib3\util\ssl_.py:150: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
InsecurePlatformWarning
in Pycharm, I am getting the following error when trying to install a package:
Could not fetch URL https://pypi.org/simple/geopy/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/geopy/ (Caused by SSLError(SSLError(1, '_ssl.c:499: error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version'),)) - skipping
Proposed Solution:
Try to run this command from the system terminal. Make sure that you use the correct version of 'pip' installed for your Python interpreter located at 'C:\Python27\python.exe'.
Everything is working perfectly fine suing python 3.4 but only with 2.7 I'm getting SSL error.
I can't change to 3.4 due to technical reasons at my workplace.
It is an Interpreter Issue. The code was originally written using python 3.7

How to install pip for installing external packages in NAO robot

I have written some code and want to run it on NAO robot, but unfortunately the I used some packages like pygame and boto3 in my code, so now to work this code on NAO I have to install the packages on NAO robot, Can someone please explain the process, please.
I have tried running get-pip.py file on NAO using ssh nao#ip, but it can't install
I have been attempting copying the packages files to NAO, but it also doesn't solve the problem.
I followed the https://community.ald.softbankrobotics.com/ja/node/1506 forum, but it also doesn't solve it
Below is the console output when I run get-pip.py file
PS C:\Users\hp> ssh nao#169.254.252.60 Password: nao [0] ~ $ su Password: root#nao [0] nao # ls Ashim DigiCertHighAssuranceEVRootCA.pem classes.bin diagnosis naoqi recordings DigiCertHighAssuranceEVRootCA.crt angles.bin couples.bin expo.bin rayons.bin remotes root#nao [0] nao # cd Ashim root#nao [0] Ashim # ls boto3 client_secret.json example.py jmespath pip python-engineio six botocore custom-env get-pip.py mpolly.py pygame python-socketio urllib3 root#nao [0] Ashim # python get-pip.py
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. Collecting pip /tmp/tmpdQ8F7J/pip.zip/pip/_vendor/urllib3/connection.py:324: SystemTimeWarning: System time is way off (before 2017-06-30). This will probably lead to SSL verification errors /tmp/tmpdQ8F7J/pip.zip/pip/_vendor/urllib3/util/ssl_.py:354: SNIMissingWarning: An HTTPS request has been made, but the SNI (Server Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings /tmp/tmpdQ8F7J/pip.zip/pip/_vendor/urllib3/util/ssl_.py:150: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '_ssl.c:504: error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version'),)': /simple/pip/ /tmp/tmpdQ8F7J/pip.zip/pip/_vendor/urllib3/connection.py:324: SystemTimeWarning: System time is way off (before 2017-06-30). This will probably lead to SSL verification errors /tmp/tmpdQ8F7J/pip.zip/pip/_vendor/urllib3/util/ssl_.py:150: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '_ssl.c:504: error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version'),)': /simple/pip/
/tmp/tmpdQ8F7J/pip.zip/pip/_vendor/urllib3/connection.py:324: SystemTimeWarning: System time is way off (before 2017-06-30). This will probably lead to SSL verification errors
/tmp/tmpdQ8F7J/pip.zip/pip/_vendor/urllib3/util/ssl_.py:150: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '_ssl.c:504: error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version'),)': /simple/pip/
/tmp/tmpdQ8F7J/pip.zip/pip/_vendor/urllib3/connection.py:324: SystemTimeWarning: System time is way off (before 2017-06-30). This will probably lead to SSL verification errors
/tmp/tmpdQ8F7J/pip.zip/pip/_vendor/urllib3/util/ssl_.py:150: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '_ssl.c:504: error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version'),)': /simple/pip/
/tmp/tmpdQ8F7J/pip.zip/pip/_vendor/urllib3/connection.py:324: SystemTimeWarning: System time is way off (before 2017-06-30). This will probably lead to SSL verification errors
/tmp/tmpdQ8F7J/pip.zip/pip/_vendor/urllib3/util/ssl_.py:150: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '_ssl.c:504: error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version'),)': /simple/pip/
/tmp/tmpdQ8F7J/pip.zip/pip/_vendor/urllib3/connection.py:324: SystemTimeWarning: System time is way off (before 2017-06-30). This will probably lead to SSL verification errors
/tmp/tmpdQ8F7J/pip.zip/pip/_vendor/urllib3/util/ssl_.py:150: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError(SSLError(1, '_ssl.c:504: error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version'),)) - skipping
ERROR: Could not find a version that satisfies the requirement pip (from versions: none)
ERROR: No matching distribution found for pip
root#nao [err 1] Ashim #
Also, I tried to update the system time, but this also not solves the problem. the output remains the same as before:
root#nao [err 127] nao # ntpdate
17 Sep 02:55:02 ntpdate[8986]: no servers can be used, exiting
root#nao [err 1] nao # ntpdate -s 0.de.pool.ntp.org
root#nao [0] nao # ntpdate
11 Jul 10:51:42 ntpdate[9024]: no servers can be used, exiting
root#nao [err 1] nao # cd Ashim
I also tried to install the packages without pip, using sudo python setup.py install
But in this case it shows the error below:
error: could not create '/usr/lib/python2.7/site-packages/awscli-1.16.196-py2.7.egg': No space left on device
You have a:
SystemTimeWarning: System time is way off (before 2017-06-30). This
will probably lead to SSL verification errors
Fix your systemtime otherwise ssl verfication will fail.
It might work similar to pepper, follow the instructions here
You also get the
SNIMissingWarning: An HTTPS request has been made, but the SNI (Server
Name Indication) extension to TLS is not available on this platform.
This may cause the server to present an incorrect TLS certificate,
which can cause validation failures. You can upgrade to a newer
version of Python to solve this. For more information, see
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
To fix it you would need to install requests[security] package
You can also install packages witout pip as discribed here

Plotly installation fails to establish new connection

I usually use a proxy at my workplace such that I have:
C:\myPath>echo %https_proxy%
http://myUser:myPassword#myProxy:myPort
Now I am at home (it means.. no proxy!) and I am trying to install a package ("plotly"):
C:\myPath>conda install -c plotly plotly=1.3.2
Fetching package metadata ...
CondaHTTPError: HTTP None None
for url <None>
An HTTP error occurred when trying to retrieve this URL.
ProxyError(MaxRetryError("HTTPSConnectionPool(host='conda.anaconda.org', port=443): Max retries exceeded with url: /plot
ly/win-64/repodata.json (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('<requests.packages.urllib3
.connection.VerifiedHTTPSConnection object at 0x0000000004D786A0>: Failed to establish a new connection: [Errno 11004] g
etaddrinfo failed',)))",),)
In order to remove the proxy settings without removing the environment variables I tried:
set http_proxy = ""
set https_proxy= ""
but the situation does not change.
I have also tried:
C:\myPath>pip install plotly
Collecting plotly
Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'ProxyError('Cannot conne
ct to proxy.', NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0
x0000000003C6C400>: Failed to establish a new connection: [Errno 11004] getaddrinfo failed',))': /simple/plotly/
The questions are:
- is the problem my proxy settings?
- if it is, how can I change them?
I have solved in a very simple way. The mistake was in the way I removed the proxy. I set:
C:\myPath>set https_proxy=
and the command
C:\myPath>conda install -c plotly plotly=1.3.2
worked!
WARNING: the commands http(s)_proxy= have to contain no blank spaces.

pip install cryptography fails with a proxy error

Python version = 2.7.13
OS version = Windows 7
I am behind a corporate proxy, trying to install paramiko and crypotagrphy. I searched for a solution but none worked. I tried the following so far to no use.
**Tried setting the proxy variable on windows.
Tried installing urllib3.
Also tried creating a pip folder with a pip.ini file and pasted my proxy address there.
I get the following error when using
pip install --proxy=http:// crytography
Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connec
tion broken by 'ProxyError('Cannot connect to proxy.', error('Tunnel connection
failed: 405 Method Not Allowed',))': /simple/cryptography/
Any help would be appreciated.
Thanks!