No module named ouathlib.common - python

I downloaded the and installed the twitter wrapper for python from:
https://python-twitter.googlecode.com/files/python-twitter-1.1.tar.gz
This is all i have in my code now:
import simplejson
import httplib2
import twitter
This is the error i get:
Traceback (most recent call last):
File "C:\Python27\Scripts\tweets.py", line 3, in <module>
import twitter
File "build\bdist.win-amd64\egg\twitter.py", line 38, in <module>
File "C:\Python27\lib\site-packages\requests_oauthlib-0.4.0-py2.7.egg\requests_oauthlib\__init__.py", line 1, in <module>
from .oauth1_auth import OAuth1
File "C:\Python27\lib\site-packages\requests_oauthlib-0.4.0-py2.7.egg\requests_oauthlib\oauth1_auth.py", line 3, in <module>
from oauthlib.common import extract_params
ImportError: No module named oauthlib.common
Which module can i install to stop this error?

https://github.com/idan/oauthlib
Try to install oauthlib to fix the error.

https://github.com/idan/oauthlib
Try to install oauthlib to fix the
error. answered Oct 11 at 12:32 by xiaowl
The above worked for me. I was installing python-twitter and its dependencies in a web2py application /modules subdirectory and was getting a similar error. I installed oauthlib from the above link and all is happy.
Thanks, Xiaowl.

Related

ModuleNotFoundError: No module named '_brotli' when trying to install dash

I try to install dash on a mac OS, and I have the following error when running 'import dash' on a python script:
Traceback (most recent call last):
File "app.py", line 16, in <module>
import dash
File "/Users/manuel/Library/Python/3.9/lib/python/site-packages/dash/__init__.py", line 5, in <module>
from .dash import Dash, no_update # noqa: F401,E402
File "/Users/manuel/Library/Python/3.9/lib/python/site-packages/dash/dash.py", line 17, in <module>
from flask_compress import Compress
File "/Users/manuel/Library/Python/3.9/lib/python/site-packages/flask_compress/__init__.py", line 1, in <module>
from .flask_compress import Compress
File "/Users/manuel/Library/Python/3.9/lib/python/site-packages/flask_compress/flask_compress.py", line 14, in <module>
import brotli
File "/Users/manuel/Library/Python/3.9/lib/python/site-packages/brotli.py", line 8, in <module>
import _brotli
ModuleNotFoundError: No module named '_brotli'
I can't figure it out what is the problem. I use python 3.7. I saw on the internet a similar issue on windows, but not on mac. I would be really grateful if you could help me.
You seem to have a broken installation of the brotli module (missing its native code component _brotli).
Try uninstalling it with pip uninstall brotli, then reinstall it; pip install brotli.
Going forward, I would heavily recommend you learn and use virtualenvs instead of installing everything into your Python's site-packages.
After uninstalling and installing again brotli it worked! Moreover, working in virtual environments is really more appropriate. Thank you a lot, AKX.

"No module named zlib" error anytime I use pip

I'm using terminal on mac, and anytime I attempt to use pip, I get the following error message telling me that it cannot find a module named zlib:
$ pip --version
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/pip/_vendor/requests/packages/__init__.py", line 27, in <module>
from . import urllib3
File "/usr/local/lib/python3.6/site-packages/pip/_vendor/requests/packages/urllib3/__init__.py", line 8, in <module>
from .connectionpool import (
File "/usr/local/lib/python3.6/site-packages/pip/_vendor/requests/packages/urllib3/connectionpool.py", line 42, in <module>
from .response import HTTPResponse
File "/usr/local/lib/python3.6/site-packages/pip/_vendor/requests/packages/urllib3/response.py", line 3, in <module>
import zlib
ModuleNotFoundError: No module named 'zlib'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.5/bin/pip", line 7, in <module>
from pip import main
File "/usr/local/lib/python3.6/site-packages/pip/__init__.py", line 21, in <module>
from pip._vendor.requests.packages.urllib3.exceptions import DependencyWarning
File "/usr/local/lib/python3.6/site-packages/pip/_vendor/requests/__init__.py", line 62, in <module>
from .packages.urllib3.exceptions import DependencyWarning
File "/usr/local/lib/python3.6/site-packages/pip/_vendor/requests/packages/__init__.py", line 29, in <module>
import urllib3
File "/usr/local/lib/python3.6/site-packages/urllib3/__init__.py", line 8, in <module>
from .connectionpool import (
File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 36, in <module>
from .response import HTTPResponse
File "/usr/local/lib/python3.6/site-packages/urllib3/response.py", line 3, in <module>
import zlib
ModuleNotFoundError: No module named 'zlib'
I've read several SO posts with the same error message, and have tried their solutions, including attempting to install zlib using homebrew, which fails, and updating my Xcode developer tools. I also installed pip earlier using python get-pip.py, and it said it installed successfully.
The reason I need pip is to install a package for use on python 2.7, but doing $ pip install "package-name" produces the same error as above. I have both Python 2 and 3 installed on my machine, if that helps. I'm kind of new to pip and using the command line in general, and I'm super confused; if anyone could help me out I'd really appreciate it.
This is the OP. I was able to fix the issue, and wanted to post my solution here in case it would help others.
Essentially I believe it occurred because Python2 is default on my machine, but pip is by default pointing to resources pertaining to Python3, or something like that. Doing pip2 --version instead provided the expected response.

Can't import the py-translate 1.03 package

Is someone familiar with these package?
I tried easy install and many things I saw in imports problems solution
>>> import translate
output:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import translate
File "C:\Python27\lib\site-packages\translate\__init__.py", line 8, in <module>
from .translator import *
File "C:\Python27\lib\site-packages\translate\translator.py", line 13, in <module>
import requests
ImportError: No module named requests
Moreover, in the directory of the package there is a test file.
I tried to run it but I got this:
Traceback (most recent call last):
File "C:\Python27\Lib\site-packages\translate\tests\test_translator.py", line 10, in <module>
from ..translator import translator
ValueError: Attempted relative import in non-package
How have you installed py-translate.
It requires: requests
My advice is pip install requests (or easy_install requests)
Their latest release is 1.0.2, but also goes by 1.0.3.
Pip install the package, don't just download the archive as you will miss the dependancies

ImportError from python-fitbit

I'm trying to use the python-fitbit package with Python 3.4 to get information from Fitbit (https://github.com/orcasgit/python-fitbit).
Whenever I run it, I get the following error. Right now oauthlib is installed, and I've tried uninstalling and reinstalling it to no avail. Any thoughts would be appreciated.
File "/usr/local/lib/python3.4/dist-packages/fitbit/__init__.py", line 10, in <module>
from .api import Fitbit, FitbitOauth2Client
File "/usr/local/lib/python3.4/dist-packages/fitbit/api.py", line 12, in <module>
from requests_oauthlib import OAuth2, OAuth2Session
File "/usr/local/lib/python3.4/dist-packages/requests_oauthlib/__init__.py", line 1, in <module>
from .oauth1_auth import OAuth1
File "/usr/local/lib/python3.4/dist-packages/requests_oauthlib/oauth1_auth.py", line 6, in <module>
from oauthlib.common import extract_params
ImportError: No module named 'oauthlib'
Where in your file system did you install oauthlib?
Please make sure that oauthlib is in your python path.
In order to check your python path you can execute:
import sys; print sys.path

Import error for Oauth

I am using Python on windows having working the same code it was working fine now it has suddent change for the updating the programme I found the error ImportError: cannot import name to_native_string can you help me why this error is occuring.
Traceback (most recent call last):
File "C:\Users\inla\Desktop\tweepy2\tweepy1.py", line 1, in <module>
from tweepy import Stream
File "C:\Users\inla\Desktop\tweepy2\tweepy\__init__.py", line 16, in <module>
from tweepy.auth import OAuthHandler, AppAuthHandler
File "C:\Users\inla\Desktop\tweepy2\tweepy\auth.py", line 9, in <module>
from requests_oauthlib import OAuth1Session, OAuth1
File "C:\Python27\lib\site-packages\requests_oauthlib-0.4.1-py2.7.egg\requests_oauthlib\__init__.py", line 1, in <module>
from .oauth1_auth import OAuth1
File "C:\Python27\lib\site-packages\requests_oauthlib-0.4.1-py2.7.egg\requests_oauthlib\oauth1_auth.py", line 10, in <module>
from requests.utils import to_native_string
ImportError: cannot import name to_native_string
Check your installed requests version.
requests.utils.to_native_string is available since requests 2.0.0.
Upgrading requests to latest version will solve your problem.
C:\Users\falsetru>pip install requests==1.2.3
Downloading/unpacking requests==1.2.3
...
Successfully installed requests
Cleaning up...
C:\Users\falsetru>python -c "from requests.utils import to_native_string"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: cannot import name to_native_string
C:\Users\falsetru>pip uninstall -y requests
Uninstalling requests:
Successfully uninstalled requests
C:\Users\falsetru>pip install requests==2.0.0
Downloading/unpacking requests==2.0.0
...
Successfully installed requests
Cleaning up...
C:\Users\falsetru>python -c "from requests.utils import to_native_string"
C:\Users\falsetru>

Categories

Resources