首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >使用python 3.4.3时不能导入扩展

使用python 3.4.3时不能导入扩展
EN

Stack Overflow用户
提问于 2017-08-15 23:20:03
回答 1查看 2.6K关注 0票数 3

前几天我用pip下载了gspread。我设法将它导入到python文件中,并在使用python 2.7.6时运行该文件,但在使用python 3.4.3时,它返回错误,不返回名为gspread的模块。我确实看到,当我去安装go的地方时,它的下2.7.6,同时,我在3.4.3下有不和谐的api。我能做些什么让python3发挥作用呢?谢谢!

导入不再有问题,但在运行非常简单的代码时,我会得到一个错误:

代码语言:javascript
运行
复制
    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'

我的代码是:

代码语言:javascript
运行
复制
    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)
EN

回答 1

Stack Overflow用户

发布于 2017-08-15 23:25:16

好像你用错了pip的版本。要安装Python3软件包,必须使用pip3。要安装扩展,只需使用pip3 install gspread

如果您缺少pip3,可以使用以下命令安装它:

代码语言:javascript
运行
复制
sudo apt-get update && sudo apt-get install python3-pip
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45702910

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档