Python Forum
Import Requests Does not Work
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Import Requests Does not Work
#1
Hello all!

On Windows 10, running Python 3.6.5 (v3.6.5:f59c0932b4, after following exactly snippsat installation here:

https://python-forum.io/Thread-Basic-Par...8#pid18498


I am unable to install the "Requests" module.

I can run PIP in windows, and can run python from the cmd line, but i cant

Whats crazy is that i CAN import modules like statistics.
Im looking for any help i can find with this.


C:\Users\MYNAME>pip install requests
Collecting requests
Using cached requests-2.18.4-py2.py3-none-any.whl
Collecting idna<2.7,>=2.5 (from requests)
Using cached idna-2.6-py2.py3-none-any.whl
Collecting certifi>=2017.4.17 (from requests)
Using cached certifi-2018.1.18-py2.py3-none-any.whl
Collecting chardet<3.1.0,>=3.0.2 (from requests)
Using cached chardet-3.0.4-py2.py3-none-any.whl
Collecting urllib3<1.23,>=1.21.1 (from requests)
Using cached urllib3-1.22-py2.py3-none-any.whl
Installing collected packages: idna, certifi, chardet, urllib3, requests
Successfully installed certifi-2018.1.18 chardet-3.0.4 idna-2.6 requests-2.18.4 urllib3-1.22

The C prompt never re-appeared after installation.

I had to actually and completley exit out of dos prompt/CMD and re open it.


 import requests
Traceback (most recent call last):
  File "<pyshell#4>", line 1, in <module>
    import requests
ModuleNotFoundError: No module named 'requests'
>>>

(Apr-15-2018, 09:17 PM)DiceMann Wrote: Hello all!

On Windows 10, running Python 3.6.5 (v3.6.5:f59c0932b4, after following exactly snippsat installation here:

https://python-forum.io/Thread-Basic-Par...8#pid18498


I am unable to install the "Requests" module.

I can run PIP in windows, and can run python from the cmd line, but i cant

Whats crazy is that i CAN import modules like statistics.
Im looking for any help i can find with this.


C:\Users\MYNAME>pip install requests
Collecting requests
Using cached requests-2.18.4-py2.py3-none-any.whl
Collecting idna<2.7,>=2.5 (from requests)
Using cached idna-2.6-py2.py3-none-any.whl
Collecting certifi>=2017.4.17 (from requests)
Using cached certifi-2018.1.18-py2.py3-none-any.whl
Collecting chardet<3.1.0,>=3.0.2 (from requests)
Using cached chardet-3.0.4-py2.py3-none-any.whl
Collecting urllib3<1.23,>=1.21.1 (from requests)
Using cached urllib3-1.22-py2.py3-none-any.whl
Installing collected packages: idna, certifi, chardet, urllib3, requests
Successfully installed certifi-2018.1.18 chardet-3.0.4 idna-2.6 requests-2.18.4 urllib3-1.22

The C prompt never re-appeared after installation.

I had to actually and completley exit out of dos prompt/CMD and re open it.


 import requests
Traceback (most recent call last):
  File "<pyshell#4>", line 1, in <module>
    import requests
ModuleNotFoundError: No module named 'requests'
>>>

So..i realized i needed this too lxml.
Problem is when i run it..its imply hangs....


C:\Python36\Scripts>pip install lxml
Collecting lxml



Has this always been necessary with the requests module?
Reply
#2
Look at part-1 and the test in cmd.
You see how Requests is installed and tester.
(Apr-15-2018, 09:17 PM)DiceMann Wrote: Has this always been necessary with the requests module?
No Requests has always work alone,you most be sure that test of pip and python work in cmd as part-1.
Microsoft Windows [Version 10.0.16299.309]
(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
 
C:\>
Reply
#3
So I have:

C:\>pip install requests
Requirement already satisfied: requests in c:\python36\lib\site-packages (2.18.4)
Requirement already satisfied: idna<2.7,>=2.5 in c:\python36\lib\site-packages (from requests) (2.6)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in c:\python36\lib\site-packages (from requests) (3.0.4)
Requirement already satisfied: certifi>=2017.4.17 in c:\python36\lib\site-packages (from requests) (2018.1.18)
Requirement already satisfied: urllib3<1.23,>=1.21.1 in c:\python36\lib\site-packages (from requests) (1.22)


I thought I had all bases covered.


Also


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

C:\WINDOWS\system32>


I also heard you have to install "lmxl" but when i do it does this:

C:\WINDOWS\system32>pip install lxml
Collecting lxml


Problem is, it sits there and hangs for hours. Doesnt complete.

Thanks!

ps.


C:\>python -V
Python 3.6.5
Reply
#4
I think with Windows you can't install lxml through pip

You need to download the whl file from the website and run it through CMD
Reply
#5
(Apr-16-2018, 01:44 AM)DiceMann Wrote: Problem is, it sits there and hangs for hours. Doesnt complete.
What hangs when you install or run code?
Run cmd as Administrator
Your python and pip is correct from cmd.
(Apr-16-2018, 08:07 AM)digitalmatic7 Wrote: I think with Windows you can't install lxml through pip

You need to download the whl file from the website and run it through CMD
With pip-9 and 3.6 there is no need to download the wheel file,pip install lxml work fine.
C:\>pip -V
pip 9.0.3 from c:\python36\lib\site-packages (python 3.6)

C:\>pip install lxml
Collecting lxml
  Using cached lxml-4.2.1-cp36-cp36m-win32.whl
Installing collected packages: lxml
Successfully installed lxml-4.2.1

C:\>python
Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from lxml import html, etree

>>> etree.__version__
'4.2.1' 
Reply
#6
Update.

So i can install requests completely:

C:\>pip install requests
Requirement already satisfied: requests in c:\python\lib\site-packages (2.18.4)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in c:\python\lib\site-packages (from requests) (3.0.4)
Requirement already satisfied: certifi>=2017.4.17 in c:\python\lib\site-packages (from requests) (2018.4.16)
Requirement already satisfied: urllib3<1.23,>=1.21.1 in c:\python\lib\site-packages (from requests) (1.22)
Requirement already satisfied: idna<2.7,>=2.5 in c:\python\lib\site-packages (from requests) (2.6)

So i think i resolved an issue there, but when i run requests for python im back to the main issue:

>>> import requests
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'requests'
>>>



For lxml:

C:\>pip install lxml
Collecting lxml
Downloading https://files.pythonhosted.org/packages/..._amd64.whl (3.6MB)
100% |████████████████████████████████| 3.6MB 924kB/s
Installing collected packages: lxml
Successfully installed lxml-4.2.1


When i run it for import:

>>> import lxml
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'lxml'
>>>


>>> from lxml import html, etree
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'lxml'
>>>

Really confused here.


Thanks
Reply
#7
(Apr-17-2018, 02:16 AM)DiceMann Wrote: Requirement already satisfied: requests in c:\python\lib\site-packages (2.18.4)
Why dos it say c:\python\lib\site-packages
In your previous post:
DiceMann Wrote:Requirement already satisfied: requests in c:\python36\lib\site-packages (2.18.4)
There it say c:\python36\lib\site-packages

Do you have two Python installation?
You have to figure this out,what python and pip version used anywhere from cmd is set in Environment Variables(Path)
Reply
#8
snippsat,

I really appreciate and am thankful for your help!!

So..i ended up uninstalling and re installing python again.
I just re ran the command to show that it was, in fact, installed.

Im not really sure if i have two python installations or not.
I thought i had thoroughly uninstalled python but i did notice that the uninstaller doesnt uninstall every thing.


C:\>python -V
Python 3.6.5

and

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





I did not see the option for "Disable Path Length Limit" during the installation.

ADD PYTHON 3.6 TO PATH was selected during installation.
Reply
#9
The only other thing i can think of is a fresh install of windows.
Otherwise, none of this makes since.
Reply
#10
Upgrade pip to v. 10 and try again. There was some improvements for Windows.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
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