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 believe this has something to do with having multiple versions of python but after fiddling for many hours I am just plain lost. I am on OSX Yosemite. I have tried installing and reinstalling the twilio libraries multiple times.
The script won't run past line 1 without throwing this error.
ImportError: No module named twilio
from twilio import twiml
from twilio.rest import TwilioRestClient
Basic info for Twilio and python
twilio==4.5.0
/Library/Frameworks/Python.framework/Versions/2.7/bin/python
/usr/local/bin/python
/usr/bin/python
Thanks to anyone that can help.
I had this same problem, and found the solution here: Import error in twilio
It could be that you simply already have a file named twilio.py that is being imported instead of the library, twilio-python. Remove your twilio.py and twilio.pyc and hopefully it will solve your problem.
Since you're using Python 2.7 try installing twilio with pip2 (the python 2.7 pip version)
sudo pip2 install twilio
And remember to always keep you main pip version the same as your python version
i had the same problem, the problem was emanating from naming conflict. Had named my project file "twilio.py" thus
from twilio.rest import Client
gave an error
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 had installed the python package named requests. (pip install -i http://pip.kennethreitz.com/simple requests)
First, I tried using the common user ($) but didn't worked, so, i tried the root one (#) and worked.
The problem was in the use. When I try a simple code like
$python
>>>import requests
>>>r = requests.get('http://www.google.com')
>>>r.content
I got a incridble annoying result (see this pastebin link.)
But using root
$sudo python
>>>import requests
>>>r = requests.get('http://www.google.com')
>>>r.content
I got the correct and reasonable result: pastebin.
How can I fix this? This happens with urllib.urlencode too. (Maybe installed using sudo easy_install, but I don't remember anymore).
I tried chmod -R 777 in /usr/local/lib/python2.6/dist-packages and /usr/local/lib/python2.6/site-packages but still with the same problem.
I really think the problem is with python packages because this codes are extremly simply.
System details:
Python 2.6.5
Ubuntu LTS 10.04.4
requests package 0.7.5
It looks like your problems have to do with unicode. Try r.content.decode('utf-8').
I have written a utility script for some of my colleagues' Mac OSX with Python 2.6.1. Since they don't have all the required modules installed, I have a try-except import clause:
try:
import argparse
except ImportError:
print "argparse module missing: Please run 'sudo easy_install argparse'"
sys.exit(1)
I'm pretty sure there are more elegant ways to handle this. Any ideas?
Your best shot is to freeze your python code with all modules needed and distribute it as binary; it worked for me with Windows and Linux, however on Linux, make sure you have a compatible glibc version
There are some freeze tools for Mac OS X, but I have not used them. I only used Windows and Linux tools.
check out this link for more info
http://hackerboss.com/how-to-distribute-commercial-python-applications/
That is the common idiom but you can use setuptools and pip to automate the installation of dependencies (example).
This is actually the best way to do it. The same approach is for example used to select different json libraries depending on what's installed on the machine:
try:
import simplejson as json
except ImportError:
import json