how to python-oauth2 - python

I install python-oauth2 with pip install oauth2 and I find the dir named 'oauth2' in /usr/lib/python2.7/dist-packages
But from pyoauth2 import Client,AccessToken say: no moudles named pyoauth2
Then, I changed pyoauth2 to oauth2, same status.
I download the source code from https://github.com/douban/douban-client

I think you are installing the wrong package. Try with pip install pyoauth2.
oauth2 is a different package and does not define AccessToken.
It that works you can pip uninstall oauth2

Have you had problems with pip in the past?
Also have you tried to simply import oauth2 without specifying Client and AccessToken.
I pip installed oauth2 (windows) and AccessToken wasn't not found.
Also, are you running python in a separate terminal from the one which you called the pip install? You will have to restart python.
Worst case scenario, restart your machine.
Does any of this help?

Related

Import Error: Missing optional dependecy 'openpyxl.'

I am familiar with using pip to install Python packages but there is no way to install it in the environment I am working in. We have to call the directory with python.exe to run any Python code. Therefore, it is impossible to use pip install because, since there is no python, there is no pip. How could we install packages without using pip or installing pip via the python.exe file? Here is an image of the error:
Packages like pip can be executed from the python executable using python.exe -m pip install openpyxl. If you don't have sufficient firewall permissions (as you mentioned high security) you may not be able to connect to the package servers, which you would need to discuss with admin.

Python3 module not found error after installation with pip3

I have been stuck on a module not found error of python3.
I have a VM on Microsoft Azure, a Centos 7. Then I installed python3 and pip3, and some packages I needed. But there’s one package that I just couldn’t find after I installed it
sudo pip3 install --user stockstats
But whenever i wanted to run a python script using this package, there’s
ModuleNotFoundError: No module named 'stockstats'
What I tried:
pip3 show stockstats
As I really want to see where it was installed. It shows nothing. What it is supposed to do is like this:
Name: openpyxl
Version: 3.0.7
Summary: A Python library to read/write Excel 2010 xlsx/xlsm files
Home-page: https://openpyxl.readthedocs.io
Author: See AUTHORS
Author-email: charlie.clark#clark-consulting.eu
License: MIT
Location: /usr/local/lib/python3.6/site-packages
…
Then I guess it might be something wrong with the installed path, so I uninstalled the package, and then did
sudo pip3 install stockstats --install-option="--prefix=/usr/local/lib"
(I am just guessing if openpyxl is installed there then stockstats should be there too, as python imported openpyxl successfully)
That didn’t work as well, the error still persists.
*I didn’t use any package manager other than pip3.
** some irregularities occurred when I was trying to use python3(see this post). It was resolved, but I am not sure if the error in this post is related to that.
Any help or hint would be appreciated ;)
Thanks all for the prompt reply.
After Guo Lei’s comment, I tried downloading the tar ball for this package and installing it myself without pip, which eventually told me what exactly happened: a module named int-date, required by stockstats, was not installed in the python library directory. After I installed it in the proper directory, the issue is resolved.
As Danila Vershinin and phd had pointed out, I really shouldn’t run pip as root, and that is the source of issue(curiously, however, that only one particular module required by stockstats is installed in /root/.local/lib/. All others are in the right place, maybe I added the prefix flag without remembering it...?)
Still, I am not sure, I ran pip using sudo because I received permission denied errors repeatedly — so should I use something like sudo --user? Or sth else?
This works for me.
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple stockstats
or
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
pip install stockstats
You can visit This website for Installing pip in centos 7 Pip Install In Centos 7
for maybe some errors in installing pip.
reinstall python.
check that the module name is correctly typed
install stockstats in pip like "pip install stockstats" (getten from pypi.com)

Flask app can't find google module

I'm using a virtual environment to run a flask app. When I run pip freeze, I get the following:
google-api-core==0.1.1
google-auth==1.2.1
google-cloud-core==0.28.0
google-cloud-speech==0.30.0
google-gax==0.15.16
googleapis-common-protos==1.5.3
However, during run time, I get the following error:
from google.cloud import speech
ModuleNotFoundError: No module named 'google'
I'm using the google speech APIs. They work just fine when I run them locally. I don't understand why the app can't find the modules even though they're listed as installed. Can someone suggest a fix? I've tried doing pip install google, and it downloaded a bunch of other stuff, but still no fix.
So there are a lot of places where the error could be coming from. Could you please provide more details?
For example, which python version are you using? Python 2 or 3? If you are calling the wrong interpreter you need to type
python3 -m pip install
or
python3 -m pip install
accordingly.
Secondly are you using conda? If so, you need to use
conda install
instead of pip install. You can find out by typing which python in your terminal.
Third, are you sure you installed the google module correctly? If not try using
pip install google --user
and see if that works.
Lastly, are you installing the correct package? Because I believe for the speech api you need to do:
pip install --upgrade google-api-python-client
Well, removing the virtual environment and reinstalling all the dependencies worked.
It might be easier to add to your flask.py the path to modules you already installed:
import sys
sys.path.append("/home/ubuntu/.local/lib/python3.6/site-packages/")
import google
import gspread
That worked like magic to me at AWS.

"ImportError: no module named 'requests'" after installing with pip

I am getting ImportError : no module named 'requests'.
But I have installed the requests package using the command pip install requests.
On running the command pip freeze in the command prompt, the result is
requests==2.7.0
So why is this sort of error happening while running the python file?
Run in command prompt.
pip list
Check what version you have installed on your system if you have an old version.
Try to uninstall the package...
pip uninstall requests
Try after to install it:
pip install requests
You can also test if pip does not do the job.
easy_install requests
I had this error before when I was executing a python3 script, after this:
sudo pip3 install requests
the problem solved, If you are using python3, give a shot.
One possible reason is that you have multiple python executables in your environment, for example 2.6.x, 2.7.x or virtaulenv. You might install the package into one of them and run your script with another.
Type python in the prompt, and press the tab key to see what versions of Python in your environment.
In Windows it worked for me only after trying the following:
1. Open cmd inside the folder where "requests" is unpacked. (CTRL+SHIFT+right mouse click, choose the appropriate popup menu item)
2. (Here is the path to your pip3.exe)\pip3.exe install requests
Done
if it works when you do :
python
>>> import requests
then it might be a mismatch between a previous version of python on your computer and the one you are trying to use
in that case : check the location of your working python:
which python
And get sure it is matching the first line in your python code
#!<path_from_which_python_command>
Opening CMD in the location of the already installed request folder and running "pip install requests" worked for me. I am using two different versions of Python.
I think this works because requests is now installed outside my virtual environment. Haven't checked but just thought I'd write this in, in case anyone else is going crazy searching on Google.

Cant import Eve module

Hello I recently installed Eve using pip3 install eve. But now I am having import problems. After installing eve from pip3. I can't import it. I tried it with Python3.3 and with Python2.7. When I try:
from eve import Eve
I get back Module not found error. Can you help me on this?
Are you using virtualenv? You probably should as it allows to you to isolate your Eve (or whatever) environment from others, and avoid conflicts in the process.
This said, installing Eve is as simple as hitting pip install eve(from inside the virtual environment if you're using virtualenv).
Try issuing a pip freeze, it will list the installed packages. Compare the list with Eve dependencies and make sure they have all been installed (you can use requirements.txt for comparison).
EDIT: you might also be facing privilege issues. Try installing with sudo pip install eve. But again, you should really be using virtualenv.
Good luck!

Categories