Import error for Oauth - python

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>

Related

Problems installing package email in Python on Windows

I am using Windows 10.
I just tried in my Anaconda prompt: pip install email
I got the following error:
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Anaconda\lib\site-packages\setuptools-27.2.0-py3.6.egg\setuptools\__init__.py", line 10, in <module>
File "C:\Anaconda\lib\site-packages\setuptools-27.2.0-py3.6.egg\setuptools\extern\__init__.py", line 1, in <module>
File "C:\Anaconda\lib\site-packages\setuptools-27.2.0-py3.6.egg\pkg_resources\__init__.py", line 35, in <module>
File "C:\Users\DIMITR~1.LIA\AppData\Local\Temp\pip-build-1vvnmrhi\email\email\parser.py", line 10, in <module>
from cStringIO import StringIO
ModuleNotFoundError: No module named 'cStringIO'
Looks like there is no need to install email via pip. Just import it in your Python code.
The error is saying that you do not have the package cStringIO.
To resolve this use following:
pip install cStringIO
if this does not help, try:
pip install StringIO
Here is more documentation about the packages StringIO and cStringIO https://docs.python.org/2/library/stringio.html

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

cannot import name is_secure transport

I tried to reinstall and reinstall three times, I tried to pip3 install --upgrade as well, simply no method I tried didn't worked. When I try to import twython or python twitter, I get this error message:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/user/Documents/Project Lib/python-twitter/twitter/__init__.py", line 56, in <module>
from .api import Api # noqa
File "/home/user/Document/Project Lib/python-twitter/twitter/api.py", line 29, in <module>
from requests_oauthlib import OAuth1
File "/usr/local/lib/python3.4/dist-packages/requests_oauthlib/__init__.py", line 3, in <module>
from .oauth2_auth import OAuth2
File "/usr/local/lib/python3.4/dist-packages/requests_oauthlib/oauth2_auth.py", line 3, in <module>
from oauthlib.oauth2 import is_secure_transport
ImportError: cannot import name 'is_secure_transport'
ps: This only happens on Python3, on Python2x all works fine.

No module named ouathlib.common

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.

ImportError: cannot import name ResourceError

I'm trying to install couchdb app on debian using the following command
couchapp push http://user:pass#localhost:5984/acra-appname
and I'm having the following error output:
Traceback (most recent call last):
File "/usr/local/lib/python2.6/dist-packages/restkit/__init__.py", line 9, in <module>
from restkit.conn import Connection
File "/usr/local/lib/python2.6/dist-packages/restkit/conn.py", line 14, in <module>
from socketpool import Connector
ImportError: No module named socketpool
Traceback (most recent call last):
File "/usr/local/bin/couchapp", line 7, in <module>
from couchapp.dispatch import run
File "/usr/local/lib/python2.6/dist-packages/couchapp/dispatch.py", line 10, in <module>
import couchapp.commands as commands
File "/usr/local/lib/python2.6/dist-packages/couchapp/commands.py", line 15, in <module>
from couchapp import clone_app
File "/usr/local/lib/python2.6/dist-packages/couchapp/clone_app.py", line 15, in <module>
from couchapp.errors import AppError
File "/usr/local/lib/python2.6/dist-packages/couchapp/errors.py", line 7, in <module>
from restkit import ResourceError
ImportError: cannot import name ResourceError
As far as I understand the error is:
ImportError: No module named socketpool
How can I install this module or how to resolve the problem?
As Ifthikhan sugessted: Install it using a package manager such as apt-get and thereafter using pip you can install socketpool.
I had this problem when installing couchapp. I used pip to install it, and I thought it completed, but when I ran it I had the ImportError problem. Turns out the pip install didn't succeed and I first needed to:
apt-get install python-dev
Then when I did a
pip install couchapp
all of the dependencies were installed and couchapp ran without a problem.

Categories

Resources