4

When importing requests in python3, I'm getting the following error:

Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:06:47) [MSC v.1914 32
bit  (Intel)] on win32 Type "help", "copyright", "credits" or
"license" for more information
>>>> import requests 
Traceback (most recent call last): File "<stdin>", line 1, in <module> File
"C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\requests-2.19.1-py3.7.egg\requests\__init__.py", line 44, in <module> 
import chardet 
ModuleNotFoundError: No module named 'chardet'

This is a fresh install, but because of the env I'm working in, I couldn't use pip to install requests. I had to download the source and install via the setup.py install file.

Doing some searches yields some results, but nothing that seems to be a solution for my situation.

Thanks

JLarrimore
  • 169
  • 1
  • 2
  • 16
  • `requests` has dependencies - if you couldn't install it, how did you install those? You might have to go through recursively to get everything. Why can't you `pip install`? – jonrsharpe Aug 09 '18 at 20:44
  • 1
    @jonrsharpe I'm not sure why pip doesn't work. something about the lab env I'm in maybe? "pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available." – JLarrimore Aug 09 '18 at 21:15
  • 1
    Then see e.g. https://stackoverflow.com/q/44290926/3001761 – jonrsharpe Aug 09 '18 at 21:26

3 Answers3

8

It is a dependency and is missing from you site-packages. Since you said you can't use pip you have to install the dependencies manually.

requires = [
    'chardet>=3.0.2,<3.1.0',
    'idna>=2.5,<2.8',
    'urllib3>=1.21.1,<1.24',
    'certifi>=2017.4.17'

]

this is what requests setup files mentioned as requirements for requests. Try installing all of these and try again.

hope this helps!

kartheek
  • 690
  • 6
  • 9
6

Try installing chardet module using this command:

pip3 install chardet
Kevin
  • 16,549
  • 8
  • 60
  • 74
user12240555
  • 71
  • 1
  • 1
2

I got many attempt for ModuleNotFoundError: No Module named **** when i wanna use dirsearch

I solved it with:

sudo pip3 install dirsearch

Collecting dirsearch
  Downloading dirsearch-0.4.3.post1-py3-none-any.whl (139 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 140.0/140.0 kB 3.4 MB/s eta 0:00:00
Collecting Jinja2>=3.0.0
  Downloading Jinja2-3.1.2-py3-none-any.whl (133 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 133.1/133.1 kB 14.6 MB/s eta 0:00:00
Collecting PySocks>=1.7.1
  Downloading PySocks-1.7.1-py3-none-any.whl (16 kB)
Collecting beautifulsoup4>=4.8.0
  Downloading beautifulsoup4-4.11.2-py3-none-any.whl (129 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 129.4/129.4 kB 6.8 MB/s eta 0:00:00
Requirement already satisfied: certifi>=2017.4.17 in ./.pyenv/versions/3.11.2/lib/python3.11/site-packages (from dirsearch) (2022.12.7)
Requirement already satisfied: cffi>=1.14.0 in ./.pyenv/versions/3.11.2/lib/python3.11/site-packages (from dirsearch) (1.15.1)
Requirement already satisfied: chardet>=3.0.2 in ./.pyenv/versions/3.11.2/lib/python3.11/site-packages (from dirsearch) (5.1.0)
Collecting charset-normalizer~=2.0.0
  Downloading charset_normalizer-2.0.12-py3-none-any.whl (39 kB)
Collecting colorama>=0.4.4
  Using cached colorama-0.4.6-py2.py3-none-any.whl (25 kB)
Requirement already satisfied: cryptography>=2.8 in ./.pyenv/versions/3.11.2/lib/python3.11/site-packages (from dirsearch) (39.0.2)
Collecting defusedxml>=0.7.0
  Downloading defusedxml-0.7.1-py2.py3-none-any.whl (25 kB)
Requirement already satisfied: idna>=2.5 in ./.pyenv/versions/3.11.2/lib/python3.11/site-packages (from dirsearch) (3.4)
Collecting markupsafe>=2.0.0
  Downloading MarkupSafe-2.1.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (27 kB)
Collecting ntlm-auth>=1.5.0
  Downloading ntlm_auth-1.5.0-py2.py3-none-any.whl (29 kB)
Collecting pyopenssl>=21.0.0
  Downloading pyOpenSSL-23.0.0-py3-none-any.whl (57 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 57.3/57.3 kB 18.3 MB/s eta 0:00:00
Collecting pyparsing>=2.4.7
  Downloading pyparsing-3.0.9-py3-none-any.whl (98 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 98.3/98.3 kB 10.4 MB/s eta 0:00:00
Requirement already satisfied: requests>=2.27.0 in ./.pyenv/versions/3.11.2/lib/python3.11/site-packages (from dirsearch) (2.28.2)
Requirement already satisfied: requests-ntlm>=1.1.0 in ./.pyenv/versions/3.11.2/lib/python3.11/site-packages (from dirsearch) (1.2.0)
Requirement already satisfied: urllib3>=1.21.1 in ./.pyenv/versions/3.11.2/lib/python3.11/site-packages (from dirsearch) (1.26.15)
Collecting soupsieve>1.2
  Downloading soupsieve-2.4-py3-none-any.whl (37 kB)
Requirement already satisfied: pycparser in ./.pyenv/versions/3.11.2/lib/python3.11/site-packages (from cffi>=1.14.0->dirsearch) (2.21)
Requirement already satisfied: pyspnego>=0.1.6 in ./.pyenv/versions/3.11.2/lib/python3.11/site-packages (from requests-ntlm>=1.1.0->dirsearch) (0.8.0)
Installing collected packages: soupsieve, PySocks, pyparsing, ntlm-auth, markupsafe, defusedxml, colorama, charset-normalizer, Jinja2, beautifulsoup4, pyopenssl, dirsearch
  Attempting uninstall: charset-normalizer
    Found existing installation: charset-normalizer 3.1.0
    Uninstalling charset-normalizer-3.1.0:
      Successfully uninstalled charset-normalizer-3.1.0
Successfully installed Jinja2-3.1.2 PySocks-1.7.1 beautifulsoup4-4.11.2 charset-normalizer-2.0.12 colorama-0.4.6 defusedxml-0.7.1 dirsearch-0.4.3.post1 markupsafe-2.1.2 ntlm-auth-1.5.0 pyopenssl-23.0.0 pyparsing-3.0.9 soupsieve-2.4

[notice] A new release of pip available: 22.3.1 -> 23.0.1
[notice] To update, run: pip install --upgrade pip
S.B
  • 13,077
  • 10
  • 22
  • 49