[英]Cant import gspread when using python 3.4.3
I downloaded gspread the other day using pip. 我前几天用pip下载了gspread。 I manage to import it into a python file and run the file when using python 2.7.6 but when using python 3.4.3 it returns error no module named gspread .
我设法将它导入python文件并在使用python 2.7.6时运行该文件但是当使用python 3.4.3时它返回错误没有名为gspread的模块 。 I did see that when I go to where gspread is installed its under 2.7.6 meanwhile I have discord api under 3.4.3.
我确实看到当我去gspread安装在2.7.6以下的同时我在3.4.3下有disord api。 Anything I can do to get gspread to work with python3?
我可以做些什么让gspread与python3一起工作? Thank you!
谢谢!
I dont have problem with importing anymore but when running very simple code I get an error: 我没有导入问题但运行非常简单的代码时出现错误:
Traceback (most recent call last):
File "test.py", line 11, in <module>
sheet = client.open('Test').sheet1
File "/home/marbj634/.local/lib/python3.4/site-packages/gspread/client.py", line 82, in open
feed = self.get_spreadsheets_feed()
File "/home/marbj634/.local/lib/python3.4/site-packages/gspread/client.py", line 155, in get_spreadsheets_feed
r = self.session.get(url)
File "/home/marbj634/.local/lib/python3.4/site-packages/gspread/httpsession.py", line 73, in get
return self.request('GET', url, params=params, **kwargs)
File "/home/marbj634/.local/lib/python3.4/site-packages/gspread/httpsession.py", line 65, in request
response = func(url, data=data, params=params, headers=request_headers, files=files, json=json)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 467, in get
return self.request('GET', url, **kwargs)
TypeError: request() got an unexpected keyword argument 'json'
My code is only: 我的代码只是:
import gspread
from oauth2client.service_account import ServiceAccountCredentials
import pprint
scope = ['https://spreadsheets.google.com/feeds']
creds = ServiceAccountCredentials.from_json_keyfile_name('client_secret.json', scope)
client = gspread.authorize(creds)
pp = pprint.PrettyPrinter()
sheet = client.open('Test').sheet1
values = sheet.get_all_values()
pp.pprint(values)
Seems like you have used wrong version of pip. 好像你使用了错误版本的pip。 To install packages for Python3, you must use
pip3
. 要安装Python3的软件包,必须使用
pip3
。 To install gspread, simply use pip3 install gspread
. 要安装gspread,只需使用
pip3 install gspread
。
In case you are missing pip3, you can install it using this command: 如果您缺少pip3,可以使用以下命令安装它:
sudo apt-get update && sudo apt-get install python3-pip
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.