I am trying to use the urllib library as part of a python program for web scraping. It contains the module request.py which has to import http.client. However I keep on getting this message:
ModuleNotFoundError: No module named 'http.client'; 'http' is not a package.
However, my Python libraries folder "Lib" contains both http folder and urllib folder. The http folder also contains client.py file. What could possibly be wrong? Please help I'm a beginner.
Use the pip command as follows to install missing or old packages:
py -m pip install --upgrade http
You can also try uninstalling / reinstalling modules in hopes of fixing corrupted packages:
py -m pip uninstall http
py -m pip install --upgrade http
If all that doesn't work, try running a Command Prompt and running your file with the following command:
python file_name.py
Related
I get this error when I run my python project(I'm using python 3.10.5 on Windows 10):
ModuleNotFoundError: No module named 'requests'
Despite the fact that I do infact have the module installed. I also tried uninstalling it and installing it again, but that didn't work. I had a conflict on my other computer again with requests and installing discord.py, but I can't seem to get it to work here. I installed discord.py v2 using:
pip install -U git+https://github.com/Rapptz/discord.py
In Command Prompt Type: py -3 -m pip install requests
If it doesn't install, go to the given address and delete all the folders that say requests and upload again.
I'm having trouble importing modules such as pandas and BS4 in python on VScode, after pip installing them through terminal.
I receive the same error message "ImportError: No module named bs4" every time.
Any suggestions are greatly appreciated
Uninstall your Python and install it again.
Don't install packages through the VSCode terminal.
Install them outside the VSCode and then import them into your program.
For installing bs4, use the following command:
pip install beautifulsoup4
I am getting ImportError: No module named 'Crypto' error when trying to run. I have installed pycrypto using pip install pycrypto and updated it also. Everything I have tried to far has been unsuccessful.
Tried:
reinstalling pycrypto,
updating both python and pycrypto
Any suggestions?
The error messages says, it does not able to find the module so please try to run below command,
#pip list -- # what does it show to you, if it would have installed successfully it will show you up there.
if "pip install pycrypto" doesn't work so try to download the source tar ball and try to install it from prompt.
pip download pycrypto
it will download tar.gz file.. so you can install using with pip install --no-index --find-links /path/to/some/dir/ pycrypto
for python3.5 version
python3.5 -m pip install pycrypto
this will install in python3.5 environment and after that you can able to import pycrypto module
Is python defined properly on your machine?
Make sure PATH environment variable has python's installation folder in it
I know there are many posts on this, and I've tried using the solutions provided, but to no avail. I tried pip install requests and pip install requests --upgrade:
pip install requests --upgrade
You are using pip version 7.1.0, however version 7.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Requirement already up-to-date: requests in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
I then tried running pip install --upgrade pip, yet when I run my file I still get
Import Error: No module named requests
I am able to use requests in PyCharm, so I don't know what's causing this. Can someone please help?
You installed requests into a different Python installation. The /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages is the site-packages directory for the Mac OS X /usr/bin/python installation.
PyCharm is not currently configured to use that Python installation; check what Python is being used either by looking at your PyCharm settings, or by asking Python directly with:
import sys
print(sys.executable)
Note that PyCharm can handle package installations for you as well; rather than use the command line pip consider using PyCharm, as it'll use the currently configured Python installation in that case.
install package name "request" from pychram package setting. then it will be work fine.
If you are having this issue in Pycharm and you have configured your Pycharm to create projects in virtual environments, then you can use the Terminal in Pycharm to run the
pip3 install requests
to resolve this issue. This is by design to ensure you control dependencies.
I'm not experienced in Python, and I need the requests module.
I've tried installing it using pip install requests
The installation went successfully, but when I try to import the module, I get an error like "no module named requests".
Should I add the install location to PYTHONPATH? If yes, how can I find the location where pip installed the files? I don't know about virtualenv, and I am using Ubuntu.
You should install pip for python3 first
How to install pip with Python 3?
then with the pip-3.X install the required module.