Python Forum
Import Requests Does not Work
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Import Requests Does not Work
#11
(Apr-20-2018, 04:09 AM)DiceMann Wrote: The only other thing i can think of is a fresh install of windows.
Otherwise, none of this makes since.
You most tell what you have done,like have you looked at Environment Variables(Path) that i linked to before?
For me you see C:\python and C:\python36\Scripts.
This mean when i do pip install requests it will install to that version.

I have 5-6 other Python instantiation,but that dos not matter all as my main is set to 36(this is where Windows look).
Python 3.6 also install a shortcut(in Windows folder) py.exe ,that can call all versions.
[Image: lwkZgx.jpg]
Example cmd:
Microsoft Windows [Version 10.0.16299.371]
(c) 2017 Microsoft Corporation. Med enerett.

C:\WINDOWS\system32>cd\

C:\>pip -V
pip 9.0.3 from c:\python36\lib\site-packages (python 3.6)

C:\>python -c "import sys; print(sys.executable)"
C:\python36\python.exe

# Now it will install to 3.6,as shown over
C:\>pip install requests --upgrade
Requirement already up-to-date: requests in c:\python36\lib\site-packages
Requirement already up-to-date: urllib3<1.23,>=1.21.1 in c:\python36\lib\site-packages (from requests)
Requirement already up-to-date: idna<2.7,>=2.5 in c:\python36\lib\site-packages (from requests)
Requirement already up-to-date: chardet<3.1.0,>=3.0.2 in c:\python36\lib\site-packages (from requests)
Collecting certifi>=2017.4.17 (from requests)
  Downloading https://files.pythonhosted.org/packages/7c/e6/92ad559b7192d846975fc916b65f667c7b8c3a32bea7372340bfe9a15fa5/certifi-2018.4.16-py2.py3-none-any.whl (150kB)
    100% |████████████████████████████████| 153kB 1.8MB/s
Installing collected packages: certifi
  Found existing installation: certifi 2018.1.18
    Uninstalling certifi-2018.1.18:
      Successfully uninstalled certifi-2018.1.18
Successfully installed certifi-2018.4.16
You are using pip version 9.0.3, however version 10.0.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

# Access 2.7,using py
C:\>py -2.7 -V
Python 2.7.9

C:\>py -3.4 -V
Python 3.4.2

C:\>py -3.5 -V
Python 3.5.2

# Install to 2.7
C:\>py -2.7 -m pip install requests --upgrade
Requirement already up-to-date: requests in c:\python27\lib\site-packages
Requirement already up-to-date: idna<2.7,>=2.5 in c:\python27\lib\site-packages (from requests)
Requirement already up-to-date: urllib3<1.23,>=1.21.1 in c:\python27\lib\site-packages (from requests)
Collecting certifi>=2017.4.17 (from requests)
  Using cached https://files.pythonhosted.org/packages/7c/e6/92ad559b7192d846975fc916b65f667c7b8c3a32bea7372340bfe9a15fa5/certifi-2018.4.16-py2.py3-none-any.whl
Requirement already up-to-date: chardet<3.1.0,>=3.0.2 in c:\python27\lib\site-packages (from requests)
Installing collected packages: certifi
  Found existing installation: certifi 2017.7.27.1
    Uninstalling certifi-2017.7.27.1:
      Successfully uninstalled certifi-2017.7.27.1
Successfully installed certifi-2018.4.16
You are using pip version 9.0.1, however version 10.0.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

C:\>
Reply
#12
Two installed versions of Python often do not play nicely with each other, and it seems like you have two installed versions of Python 3. Problems seem to be caused not only by the PATH environment variable, but also by file associations. If this is the case I would suggest either of two approaches:
1. Uninstall both Python Version 3 installations and reinstall Python 3 (takes the least skill).

2. Try the following:
a. In Windows 10, goto Apps and Features and see if you have two versions of Python 3 installed. If so delete one of them.

b. Modify the two Python items in the PATH environment variable per snippsat's post above.

c. Reset the file associations (must be run as adminstrator - Right Click the .bat file and choose 'Run as Administrator'):
In a Windows .bat file
rem #############################################################################
rem #############################################################################
rem Change the line below to reflect your base Python folder
set PythonDIR=C:\Python

rem assoc displays or changes the association between a file extension and a fileType
rem ftype displays or changes the link between a FileType and an executable program
assoc .py=Python.File >NUL
assoc .pyw=PythonW.File >NUL
ftype Python.File="%PythonDIR%\python.exe" %%1 %%* >NUL
ftype PythonW.File="%PythonDIR%\pythonw.exe" %%1 %%* >NUL
Lewis
To paraphrase: 'Throw out your dead' code. https://www.youtube.com/watch?v=grbSQ6O6kbs Forward to 1:00
Reply
#13
Hey guys, thanks, i will try this as soon as i can!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  pip install requests doesnt work misodca 8 5,563 Jul-07-2023, 08:04 AM
Last Post: zyple
  getting an import statement to work in my program barryjo 1 1,615 Dec-06-2021, 04:28 PM
Last Post: snippsat
  Import requests/beautifulsoup problem Jokadaro_ 3 1,984 Dec-05-2021, 01:22 PM
Last Post: Jokadaro_
  'urllib3' Module not found when import 'requests' spanz 5 9,955 Jan-06-2021, 05:57 PM
Last Post: snippsat
  Does "import xlrd" work in Thonny? cnutakor 3 2,947 Apr-30-2020, 12:41 AM
Last Post: Larz60+
  import scalalib package doesn't work manu_brighter 2 2,840 Apr-17-2020, 06:36 PM
Last Post: snippsat
  [split] import PIL dont work vedansh 1 2,047 Mar-29-2020, 10:00 AM
Last Post: Larz60+
  import PIL dont work rodink 14 12,638 Feb-22-2020, 08:48 PM
Last Post: snippsat
  import requests gives me error blckpstv 1 7,280 Jan-22-2017, 10:41 AM
Last Post: snippsat

Forum Jump:

User Panel Messages

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