installing and using python-oauth2 - python

I installed oauth2:
$ pip install oauth2
But running the python-oauth2/example/client.py returns:
Traceback (most recent call last):
File "client.py", line 31, in <module>
import oauth.oauth as oauth
ImportError: No module named oauth.oauth
I tested pip freeze:
oauth2==1.5.211
Thanks in advance

As it turns out, the example directory in the oauth2 package should be ignored. It is broken code as far as the package is concerned.
See these issues for examples of other people discovering this:
https://github.com/simplegeo/python-oauth2/issues/33
https://github.com/simplegeo/python-oauth2/issues/12
https://github.com/simplegeo/python-oauth2/pull/64
The last one is a pull request that includes new examples to use instead.

Related

ModuleNotFound error even pip is already used

I am a new at Python and I have a roblem with installing one framework.
https://github.com/zalando/connexion
I have already used the command in the terminal 'pip install connexion'
But still when I try to start a programm I get such error:
PS C:\Users\fele\OneDrive\Desktop\Python\Uebergabe\pYTHON_BACKEND_2020_03_12> & "C:/Program Files (x86)/Python37-32/python.exe" "c:/Users/fele/OneDrive/Desktop/Python/Uebergabe/pYTHON_BACKEND_2020_03_12/test_local/test_local_application_hook.py"
Traceback (most recent call last):
File "c:/Users/fele/OneDrive/Desktop/Python/Uebergabe/pYTHON_BACKEND_2020_03_12/test_local/test_local_application_hook.py", line 9, in <module>
from cwsm import connexion_manager
ModuleNotFoundError: No module named 'cwsm'
Cannot anybody give me a suggestion why is it happening?
Thanks in advance
The github page shows:
import connexion
So your import is wrong, try using connexion.
Source:
https://github.com/zalando/connexion#running-it

How to manually import a module in python

When i try to run ovirt downloads_disk_snapshot from this link i am getting error as
Traceback (most recent call last):
File "download_disk_snapshots.py", line 22, in <module>
import ovirtsdk4 as sdk
ImportError: No module named ovirtsdk4
Link is https://github.com/oVirt/ovirt-engine-sdk/blob/master/sdk/examples/download_disk_snapshots.py
This guide gives some very useful information on installing python packages.
In your case, you will have to install the oVirt Engine SDK itself before being able to run the example.
Installation instructions are given within the same Github project that you are mentioning:
https://github.com/oVirt/ovirt-engine-sdk/blob/master/sdk/README.adoc#installation

codeanywhere.com Python doesn't see virtualenv

I use codeanywhere.com try to create application with Python werkzeug and jinja2.
I install those library utilize virtualenv. Now I face the problem
Traceback (most recent call last):
File "manage.py", line 4, in
from werkzeug import Request
ImportError: No module named 'werkzeug'
virtualenv activated but nothing is works.
Does anybody has experience with codeanywhere.com?
Oh I solve this problem. In the container config file add instruction "source venv3/bin/activate" as shown on a picture add path to python as well.
enter image description here

python v 2.7.13 with twilio v 6.5.2 cannot find module named urllib3 when importing Client

I'm using python version 2.7.13 and twilio version 6.5.2 and I'm trying the simple example from twilio website which begins with
from twilio.rest import Client
then goes on to send a text message to a phone number. Executing that first line within idle produces this error message:
Traceback (most recent call last):
File "C:\Users\...\send_text.py", line 1, in <module>
from twilio.rest import Client
File "build\bdist.win32\egg\twilio\rest\__init__.py", line 14, in <module>
File "build\bdist.win32\egg\twilio\http\http_client.py", line 1, in <module>
File "C:\Python27\lib\site-packages\requests-2.18.4-py2.7.egg\requests\__init__.py", line 43, in <module>
import urllib3
ImportError: No module named urllib3
I have found similar questions in this forum but the details are slightly different and the solutions do not apply to my situation.
First, check this link: https://matthewhorne.me/how-to-install-python-and-pip-on-windows-10/
Second, on your console, execute: pip install urllib3
This steps maybe can help you. Good luck.
Make sure you have installed the module using pip install urllib3 before you import it.
Thank you to Jose Moreno and Colin Ricardo.
Re-installing twilio using pip rather than easy_install was step one. Then, as suggested by Jose and Colin, the next step was to pip install urrlib3.
Turned out to be two more things that were missing, but pip installing them worked.
Then I was able to get a trial phone number from twilio and their sample send_text.py program actually worked for me!

cannot import Python-Twitter

I recently started out with python and i'm right now looking to do an app that shows my Twitter feed. So I downloaded a module(not sure if its called that) called Python-Twitter and installed it. But now everytime I try to import it I just get this error:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import twitter
File "build\bdist.win32\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 4, in <module>
from requests.utils import to_native_string
ImportError: cannot import name to_native_string
Does anyone know what I might have done wrong with the install or something? Thx
In my case installing requests-oauthlib fixed it
sudo pip install requests-oauthlib
This is because of requests version.
requests.utils.to_native_string is available since requests 2.0.0
So just update requests:
pip install -U requests
See more details here on another thread
This sounds like an issue with your install. The method to_native_string should be defined in the requests\utils.py in your Python install.
I'm on Ubuntu, and installed the Twitter module, and can import it without any errors. When I look in my install, in /usr/lib/python2.7/dist-packages/requests/utils.py, there is a to_native_string method defined there.
The implication from the error you're getting is that in your installation, there is either no utils.py, or, if there is, it does not contain that method.
I would recommend checking your install to see if that is the case. If it is indeed missing, I would recommend axing your install and reinstalling. You might want to try a virtualenv environment instead, so it can act as a sandbox (in that case you can leave your current install as is, as long as it is intact enough to run virtualenv and pip).
If utils.py is actually there and does contain a method with that name, I would recommend running a debugger such as pudb or pdb (pudb isn't built in, but it's more full featured), and step through the import to see if that sheds any additional light.

Categories

Resources