我有一天使用pip下載了gspread。我設法將它導入python文件並在使用python 2.7.6時運行該文件,但是在使用python 3.4.3時它會返回錯誤沒有名爲gspread的模塊。我確實看到,當我在2.7.6下安裝gspread的時候,我在3.4.3下有不合理的api。我能做些什麼來讓gspread與python3一起工作?謝謝!使用python時無法導入gspread 3.4.3
我沒有與進口了,但運行非常簡單的代碼時的問題,我得到一個錯誤:
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'
我的代碼是唯一的:
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)
你使用PIP的正確版本:
如果你缺少PIP 3,你可以使用這個命令安裝它?有PIP和PIP3。 –
是否有可能將gspread文件夾從python2.7複製到python3.4? –
我用pip,python3是pip3嗎? –