Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PIP problem
#11
Dear helpers,

Answers to the various questions:

I removed 3.6 and installed 3.5 from scratch from https://www.python.org/downloads/windows/. by using the windows x86 executable installer. I change one option: the location where Python is to be installed.

My environment variables: PATH=C:\Program Files\Python 3.5\Scripts\;C:\Program Files\Python 3.5\;C:\Program Files\Python\Scripts\;C:\Program Files\Python\;C:\Program Files\Nmap

Now for completeness the erro message I am getting with the new install:


Error:
>>> pip list Traceback (most recent call last): File "c:\program files\python 3.5\lib\site-packages\pip\_vendor\requests\packages\urllib3\connection.py", line 11, in <module> from http.client import HTTPConnection as _HTTPConnection File "c:\users\hmd\desktop\python\http.py", line 3, in <module> import requests ImportError: No module named 'requests' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "c:\program files\python 3.5\lib\site-packages\pip\_vendor\requests\packages\__init__.py", line 27, in <module> from . import urllib3 File "c:\program files\python 3.5\lib\site-packages\pip\_vendor\requests\packages\urllib3\__init__.py", line 8, in <module> from .connectionpool import ( File "c:\program files\python 3.5\lib\site-packages\pip\_vendor\requests\packages\urllib3\connectionpool.py", line 35, in <module> from .connection import ( File "c:\program files\python 3.5\lib\site-packages\pip\_vendor\requests\packages\urllib3\connection.py", line 14, in <module> from httplib import HTTPConnection as _HTTPConnection ImportError: No module named 'httplib' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "c:\program files\python 3.5\lib\runpy.py", line 174, in _run_module_as_main mod_name, mod_spec, code = _get_module_details(mod_name, _Error) File "c:\program files\python 3.5\lib\runpy.py", line 133, in _get_module_details return _get_module_details(pkg_main_name, error) File "c:\program files\python 3.5\lib\runpy.py", line 109, in _get_module_details __import__(pkg_name) File "c:\program files\python 3.5\lib\site-packages\pip\__init__.py", line 16, in <module> from pip.vcs import git, mercurial, subversion, bazaar # noqa File "c:\program files\python 3.5\lib\site-packages\pip\vcs\mercurial.py", line 9, in <module> from pip.download import path_to_url File "c:\program files\python 3.5\lib\site-packages\pip\download.py", line 39, in <module> from pip._vendor import requests, six File "c:\program files\python 3.5\lib\site-packages\pip\_vendor\requests\__init__.py", line 58, in <module> from . import utils File "c:\program files\python 3.5\lib\site-packages\pip\_vendor\requests\utils.py", line 26, in <module> from .compat import parse_http_list as _parse_list_header File "c:\program files\python 3.5\lib\site-packages\pip\_vendor\requests\compat.py", line 7, in <module> from .packages import chardet File "c:\program files\python 3.5\lib\site-packages\pip\_vendor\requests\packages\__init__.py", line 29, in <module> import urllib3 ImportError: No module named 'urllib3' >>>
Reply
#12
Python 3.5 is definitely urllib.request it should already be installed
so:

# GetUrl - Fetch files or web pages from internet
#
# Author: Larz60+
import urllib.request as ur
import os
from time import sleep


class GetUrl:
    def __init__(self, returndata=False):
        self.returndata = returndata

    def get_url(self, url, ret=False, tofile=None, bin=False):
        rdata = None
        head, tail = os.path.split(url)
        try:
            if tofile:
                if os.path.exists(tofile):
                    os.remove(tofile)
                if bin:
                    with open(tofile, 'wb') as f:
                        rdata = ur.urlopen(url).read()
                        f.write(rdata)
                else:
                    with open(tofile, 'w') as f:
                        rdata = ur.urlopen(url).read().decode('utf8')
                        f.write(rdata)
                sleep(.5)
            if ret:
                return rdata
        except:
            print("Unexpected error:", sys.exc_info()[0])

if __name__ == '__main__':
    url = 'ftp://ftp.nasdaqtrader.com/symboldirectory/phlxListedStrikesWithOptionIds.zip'
    tofile = 'G:\python\stock_market\symbols\data\DailyFiles\\USA\phlxListedStrikesWithOptionIds.zip'
    p = GetUrl()
    p.get_url(url, tofile, bin=True)
should work

don't use tofile if you want to preserve the old file

only set bin=True if you are downloading binary files
Reply
#13
Doesn't work :


Error:
Traceback (most recent call last): File "C:\Users\hmd\Desktop\Python\test.py", line 4, in <module> import urllib.request as ur File "c:\program files\python 3.5\lib\urllib\request.py", line 88, in <module> import http.client File "c:\users\hmd\desktop\python\http.py", line 3, in <module> import requests ImportError: No module named 'requests'
Reply
#14
(Nov-06-2016, 03:08 PM)sparkz_alot Wrote: Here is a more detailed explanation: https://www.nextofwindows.com/how-to-add...-windows-7
New in 3.5 for Windows is that this can be done under installation.

Hubert follow of this,remove what you have first.
So make sure that "Add Python 3.5 to PATH" and "pip" is marked under installation.
Restart.
Now you check that "python" and "pip" command work from anywhere in cmd.
pip -V to check version.
C:\>pip -V
pip 9.0.0 from c:\python34\lib\site-packages (python 3.4)
C:\>
So this should be 3.5 placement for you.

You can upgrade pip,it's okay to do it from Scripts folder("pip.exe" is placed here).
Eg.
C:\>cd python34\scripts
C:\Python34\Scripts>pip install --upgrade pip
Now should version be 9.0.0.
Reply
#15
That looks better. Though you could remove the "C:\Program Files\Python\Scripts\;C:\Program Files\Python\" from your environmental variables.

Next, do you have "requests" installed?


C:\>pip install requests
Collecting requests
  Downloading requests-2.11.1-py2.py3-none-any.whl (514kB)
    100% |████████████████████████████████| 522kB 936kB/s
Installing collected packages: requests
Successfully installed requests-2.11.1

C:\>
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply
#16
I re-installed again, now setting the PATH tickbox.

In a cmd-window I can run Python and I can run PIP. Unfortunately when I run pip -V I get again:


Error:
pip -V Traceback (most recent call last): File "c:\program files\python 3.5\lib\site-packages\pip\_vendor\requests\packages\urllib3\connection.py", line 11, in <module> from http.client import HTTPConnection as _HTTPConnection File "C:\Users\hmd\Desktop\Python\http.py", line 3, in <module> import requests ImportError: No module named 'requests' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "c:\program files\python 3.5\lib\site-packages\pip\_vendor\requests\packages\__init__.py", line 27, in <module> from . import urllib3 File "c:\program files\python 3.5\lib\site-packages\pip\_vendor\requests\packages\urllib3\__init__.py", line 8, in <module> from .connectionpool import ( File "c:\program files\python 3.5\lib\site-packages\pip\_vendor\requests\packages\urllib3\connectionpool.py", line 35, in <module> from .connection import ( File "c:\program files\python 3.5\lib\site-packages\pip\_vendor\requests\packages\urllib3\connection.py", line 14, in <module> from httplib import HTTPConnection as _HTTPConnection ImportError: No module named 'httplib' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "c:\program files\python 3.5\lib\runpy.py", line 174, in _run_module_as_main mod_name, mod_spec, code = _get_module_details(mod_name, _Error) File "c:\program files\python 3.5\lib\runpy.py", line 133, in _get_module_details return _get_module_details(pkg_main_name, error) File "c:\program files\python 3.5\lib\runpy.py", line 109, in _get_module_details __import__(pkg_name) File "c:\program files\python 3.5\lib\site-packages\pip\__init__.py", line 16, in <module> from pip.vcs import git, mercurial, subversion, bazaar # noqa File "c:\program files\python 3.5\lib\site-packages\pip\vcs\mercurial.py", line 9, in <module> from pip.download import path_to_url File "c:\program files\python 3.5\lib\site-packages\pip\download.py", line 39, in <module> from pip._vendor import requests, six File "c:\program files\python 3.5\lib\site-packages\pip\_vendor\requests\__init__.py", line 58, in <module> from . import utils File "c:\program files\python 3.5\lib\site-packages\pip\_vendor\requests\utils.py", line 26, in <module> from .compat import parse_http_list as _parse_list_header File "c:\program files\python 3.5\lib\site-packages\pip\_vendor\requests\compat.py", line 7, in <module> from .packages import chardet File "c:\program files\python 3.5\lib\site-packages\pip\_vendor\requests\packages\__init__.py", line 29, in <module> import urllib3 ImportError: No module named 'urllib3'
Reply
#17
Look like a connection problem,you do have internet working?(pip need this).
Try also run cmd as administrator.
Reply
#18
No connection problems!

Some additional info that might be relevant:

When I initially started with Python (few weeks ago), I didn't have this PIP-problem. It popped up when I installed some hhtp-related module from python.org.


Regards,

Hubert
Reply
#19
Quote:When I initially started with Python (few weeks ago), I didn't have this PIP-problem. It popped up when I installed some hhtp-related module from python.org.
Not sure yet what it is,have to search for simelar problems.

Just if someone wonder,so do pip use own internally version of Reqeusts and urllib3.
So solution is not to install those.
Reply
#20
(Nov-06-2016, 03:23 PM)Hubert Wrote: I removed 3.6 and installed 3.5 from scratch
Quote:It popped up when I installed some hhtp-related module from python.org.

Each python install has its own pip and modules. So any module you installed in the past would not effect a fresh python install.
Recommended Tutorials:
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020