【问题标题】:Script returns ModuleNotFoundError despite installing simple-smartsheet尽管安装了 simple-smartsheet,脚本仍返回 ModuleNotFoundError
【发布时间】:2020-10-29 16:09:03
【问题描述】:

我正在使用 Python 3.7 运行 Anaconda,并且我想在脚本中使用 simple_smartsheet 模块。我用

安装了Smartsheet
!pip install simple-smartsheet

它显示成功(见下文),但在运行我的脚本时,我得到一个ModuleNotFoundError为什么找不到模块?

这是脚本:

import logging
import csv
import os
import sys
from pprint import pprint
import pandas as pd
from datetime import date

logging.basicConfig(filename='rwsheet.log', level=logging.INFO)

SheetID="Smartsheet Sheet Name"

# simple_smartsheet is a more user friendly tool to allow for everyday transactions with
# Smartsheet's API.  Believe it or not, it is much better than what Smartsheet provides.
from simple_smartsheet import Smartsheet
from simple_smartsheet.models import Sheet, Column, Row, Cell, ColumnType

# Add SMARTSHEET_ACCESS_TOKEN to environment .bashrc.  It holds the token assigned
# from Smartsheet to access remotely.
TOKEN = "*****************"

# Name of the Smartsheet being updated
SHEET_ID = SheetID

smartsheet = Smartsheet(TOKEN)

print("SHEET_ID: ", SHEET_ID)

sheet = smartsheet.sheets.get(SHEET_ID)

运行后,它发出的确切错误如下:

Traceback (most recent call last) <ipython-input-3-e2d38a84d6b8> in <module>
     13 # simple_smartsheet is a more user freindly tool to allow for everyday transactions with
     14 # Smartsheet's API.  Beleive it or not, it is much better that what Smartsheet provides.
---> 15 from simple_smartsheet import Smartsheet
     16 from simple_smartsheet.models import Sheet, Column, Row, Cell, ColumnType
     17 

ModuleNotFoundError: No module named 'simple_smartsheet'

这是安装命令的输出:

!pip install simple-smartsheet

Requirement already satisfied: simple-smartsheet in c:\users\cabbs\anaconda3\envs\p37workshop\lib\site-packages (0.5.0)
Requirement already satisfied: attrs in c:\users\cabbs\anaconda3\envs\p37workshop\lib\site-packages (from simple-smartsheet) (19.3.0)
Requirement already satisfied: requests in c:\users\cabbs\anaconda3\envs\p37workshop\lib\site-packages (from simple-smartsheet) (2.24.0)
Requirement already satisfied: cattrs in c:\users\cabbs\anaconda3\envs\p37workshop\lib\site-packages (from simple-smartsheet) (1.0.0)
Requirement already satisfied: mypy-extensions in c:\users\cabbs\anaconda3\envs\p37workshop\lib\site-packages (from simple-smartsheet) (0.4.3)
Requirement already satisfied: aiohttp in c:\users\cabbs\anaconda3\envs\p37workshop\lib\site-packages (from simple-smartsheet) (3.7.2)
Requirement already satisfied: marshmallow<4,>=3 in c:\users\cabbs\anaconda3\envs\p37workshop\lib\site-packages (from simple-smartsheet) (3.8.0)
Requirement already satisfied: idna<3,>=2.5 in c:\users\cabbs\anaconda3\envs\p37workshop\lib\site-packages (from requests->simple-smartsheet) (2.10)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\cabbs\anaconda3\envs\p37workshop\lib\site-packages (from requests->simple-smartsheet) (2020.6.20)
Requirement already satisfied: chardet<4,>=3.0.2 in c:\users\cabbs\anaconda3\envs\p37workshop\lib\site-packages (from requests->simple-smartsheet) (3.0.4)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in c:\users\cabbs\anaconda3\envs\p37workshop\lib\site-packages (from requests->simple-smartsheet) (1.25.9)
Requirement already satisfied: async-timeout<4.0,>=3.0 in c:\users\cabbs\anaconda3\envs\p37workshop\lib\site-packages (from aiohttp->simple-smartsheet) (3.0.1)
Requirement already satisfied: yarl<2.0,>=1.0 in c:\users\cabbs\anaconda3\envs\p37workshop\lib\site-packages (from aiohttp->simple-smartsheet) (1.6.2)
Requirement already satisfied: multidict<7.0,>=4.5 in c:\users\cabbs\anaconda3\envs\p37workshop\lib\site-packages (from aiohttp->simple-smartsheet) (5.0.0)
Requirement already satisfied: typing-extensions>=3.6.5 in c:\users\cabbs\anaconda3\envs\p37workshop\lib\site-packages (from aiohttp->simple-smartsheet) (3.7.4.2)

【问题讨论】:

  • 你是如何运行脚本的?我们需要看到脚本实际在您暗示的环境 (p37workshop) 中执行的证据。例如,考虑添加一个import sys; print(sys.prefix) 来显示它的运行位置。请编辑问题以包含此信息,因为这是提问的必要条件。
  • import logging import csv import os import sys print(sys.prefix)

标签: python pip conda smartsheet-api


【解决方案1】:

我最终放弃了 p37workshop 环境并在 Anaconda 默认设置下运行。它运行没有问题!我试图运行 Python 3.7 版本,这就是我创建 p37workshop 的原因。不过,我刚刚了解到我可以使用最新的 Python 版本,所以我不需要继续尝试让 p37workshop 工作。

感谢您观看。我使用 simple_smartsheet 的时间越长,我就越惊讶于它让这与 Smartsheet 的交互变得多么容易。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-01-03
    • 2020-05-24
    • 2021-01-26
    • 2014-05-11
    • 2020-04-27
    • 2021-03-20
    • 2017-02-17
    • 1970-01-01
    相关资源
    最近更新 更多