I'm on ParrotOS and trying to code a script that brings up a people lookup website (like intelius) and based on information you put, it prints the results and if you see your information, you can remove it.
But when I try to import Mechanize it gives me this error:
"ModuleNotFoundError: No module named 'mechanize' "
It seems you haven't installed mechanize
Try :
pip install mechanize
Or
pip3 install mechanize for python 3
Related
i'm having this error could someone help me with it.
File "/Users/king/Desktop/dash1-env/DASH/lib/python3.7/site-packages/rest_framework_social_oauth2/views.py", line 7, in
from oauth2_provider.ext.rest_framework import OAuth2Authentication
ModuleNotFoundError: No module named 'oauth2_provider.ext'
I was facing the same error.
Here is the solution:
pip install django-rest-framework-social-oauth2
instead of:
django-rest-framework-social-oauth2==1.0.4
...this version caused the error
(I'm guessing outh2_provider.ext is a module)
The ModuleNotFoundError comes if you did not properly download the module, not download it at all, or mistyped it.
Go to the terminal inside of your script editor or IDE
to download with python 3 and above:
pip3 install OAuth2 Provider
to download with python 2:
pip install OAuth2 Provider
It should download and the at the top instead of import oauth2_provider.ext you write:
import oauth2
I'm using a Python upload file to connect an Apple News Format JSON file to my publisher. I've installed Python 3.6.1 and (I believe) 2.7 via Homebrew, and have used the following command to install requests:
$ pip3 install requests
This successfully installed the requests package. When dragging my "upload.py" file into Terminal, followed by "article.json", I receive the following error:
import requests
ImportError: No module named requests
Here is a screenshot to corroborate that these requests are, in fact, installed:
I have no idea what the problem is. Considering that I'm just doing this to change my article formatting, this is one hell of a job. I even downloaded the requests zip file to be certain. Can anyone tell me what the problem is?
I am trying to import urllib.request for python 2.7.10 on PyCharm 4.5.4 on Window 10 but getting the error "ImportError: No module named request".
The urllib.request modules have been deprecated ..
just use
import urllib
And for your function if you were earlier writing say
urllib.request.urlretrieve
Now you just write
urllib.urlretrieve
I have also faced the same error and Googled to solve it.
urlib.request is for Python 3.0.
You may use the code below:
import urllib
urllib.urlopen(url)
You'll get this error if you try running a python 3 file with python 2.
Try to use this in Python3
try:
x = urllib.request.urlopen('https://www.google.com/search?q=test')
print(x.read())
except Exception as e:
print(str(e))
It may happen sometimes, usually in the Linux environment. You have both 2.x and 3.x versions of python installed.
So, in that case, if you are using the command python "file.py"
then by default, it will python 2.x will run the file.
So, use the command python3 "file.py"
I was facing this issue. Maybe it can resolve someone's issue.
Try this:
#!/usr/bin/env python3
import urllib
response = urllib.urlopen("http://google.com")
html = response.read()
print(html)
The first line "#!/usr/bin/env python3" is important, as it let python know that this is Python 3 file, not 2.
Hope everything works.
Use > Path\easy_install.exe requests if you have a windows machine, where easy_install can be found in your Python*\Scripts folder, if it was installed. (Note Path\easy_install.exe is an example, mine is C:\Python32\Scripts\easy_install.exe)
If you don't have easy install and are running on a windows machine, you can get it here:
http://www.lfd.uci.edu/~gohlke/pythonlibs/#distribute
If you manually want to add a library to a windows machine, you can download the compressed library, uncompress it, and then place it into the Lib folder of your python path.
OR
You need to install pip first and then install django-request using pip
pip install django-request
also install,
python setup.py install
then import
from urllib.request import urlopen
Helpful Tips:to chech this
I am trying to use BeautifulSoup, and despite using the import statement:
from bs4 import BeautifulSoup
I am getting the error: ImportError: cannot import name BeautifulSoup
import bs4 does not give any errors.
I have also tried import bs4.BeautifulSoup and just importing bs4 and creating a BeautifulSoup object with: bs4.BeautifulSoup()
Any guidance would be appreciated.
The issue was I named the file HTMLParser.py , and that name is already used somewhere in the bs4 module.
Thanks to everyone that helped!
I found out after numerous attempts to solve the ImportError: cannot import name 'BeautifulSoup4' that the package is actually called BeautifulSoup so the import should be:
from bs4 import BeautifulSoup
Make sure the directory from which you are running your script does not contain a filename called bs4.py.
I solved it by installing beautifulsoup4, the "4" is essential.
pip install beautifulsoup4
I experienced a variation of this problem and am posting for others' benefit.
I named my Python example script bs4.py
Inside this script, whenever trying to import bs4 using the command:
from bs4 import BeautifulSoup, an ImportError was thrown, but confusingly (for me) the import worked perfectly from an interactive shell within the same venv environment.
After renaming the Python script, imports work as expected. The error was caused as Python tries to import itself from the local directory rather than using the system copy of bs4
Copy bs4 and beautifulsoup4-4.6.0.dist-info from C:\python\Lib\site-packages to your local project directory. It worked for me. Here, python actually looks for the library in local directory rather than the place where the library was installed!
The bs4 and beautifulsoup4 folders might be in the site-packages folder. So copy BeautifulSoup4 folder in bs4 and then try the below code. It worked for me.
from bs4 import BeautifulSoup
Since you were importing BeautifulSoup from bs4 and in bs4 there was no BeautifulSoup folder. That is why it was showing ImportError: cannot import name BeautifulSoup.
One of the possible reason: If you have more than one python versions installed and let's say you installed beautifulsoup4 using pip3, it will only be available for import when you run it in python3 shell.
I was also facing this type error in the beginning even after install all the modules which were required including pip install bs4 (if you have installed this then no need to install beautifusoup4 | BeautifulSoup4 through pip or anywhere else it comes with bs4 itself)
Solution : Just go to your python file where it is installed C:\python\Lib\site-packages
and then copy bs4 and beautifulsoup4-4.6.0.dist-info folders and paste it to your project folder where you have saved your working project.
The best way to resolve is, while creating your interpreter select your global python path on your system(/usr/local/bin/python3.7).
Make sure that in pycharm shell, python --version appears as 3.7. It shouldn't show 2.7
There is no problem with package just need to Copy bs4 and
beautifulsoup4-4.6.0.dist-info into your project directory
When I used
pip3 install beautifulsoup4
instead of
pip install beautifulsoup4
it returned that all requirements already satisfied but I ran it again and it worked, I'm using a virtualenv which uses python 3.8.10, I don't really know the logic behind it but hey it worked.
I had the same problem. The error was that the file in which I was importing beautifulsoup from bs4 was in another folder. Just replaced the file out of the internal folder and it worked.
For anyone else that might have the same issue as me. I tried all the above, but still didn't work. issue was 1 was using a virtual environment so needed to do pip install in the pycharm terminal instead of a command prompt to install it there. Secondly I had typed import Beautifulsoup with the S not capitalized. changed to BeautifulSoup and it worked.
For me it was a permissions issue. Directory "/usr/local/lib/python#.#/site-packages/bs4" was only 'rwx' by root and no other groups/users. Please check permissions on that directory.
I've unpacked BeautifulSoup into c:\python2.6\lib\site-packages, which is in sys.path, but when I enter import BeautifulSoup I get an import error saying no such module exists. Obviously I'm doing something stupid... what is it?
You might have more than one python version installed? Check the version you are running.
Also, I found using easy_install worked well for installing BeautifulSoup.