Google カレンダー API を使用していくつかのイベントをフェッチし、venv を使用して必要なすべてのパッケージを格納しています。パッケージがインストールされていないgoogle.auth.transport.requests
ため、正しく機能しないという単純な問題が発生しました。requests
コードとエラー:
この問題は、1 行のコードを使用して確認できます。
from google.auth.transport.requests import Request
google.auth.transport.requests
次のエラーが(2 つのトレースバックの下部にある)からコンソールにダンプされます。
File "<string>", line 3, in raise_from
ImportError: The requests library is not installed, please install the requests package to use the requests transport.
試行の失敗
- venv の削除と再作成。
- --no-cache-dir および --ignore-installed を使用してモジュールをインストールします。
情報
import requests
またはfrom google.auth.transport.requests import Request
コンソールからの実行はenv\Scripts\python
問題なく動作します。- 次のディレクトリ内に配置されたファイル
temp.py
に配置された同じ行は、次のように実行されます。AutoMate\
: 安全AutoMate\src\
: 安全AutoMate\src\sources\
: エラーAutoMate\src\sources\temp\
: 安全 (sources\temp はデバッグ用にのみ作成)AutoMate\src\sources\util\
: 安全。
env\Scripts\python
注: ここと以下のすべてのテストは、 と を使用して AutoMate\ から実行されましたenv\Scripts\pip
。
venv の外側の pip には、Google 認証モジュールはどれもインストールされていません。
プロジェクトの構造は次のとおりです。
AutoMate
| temp.py
├───env
│ ├───Include
│ ├───Lib
│ └───Scripts
└───src
│ AutoMate.pyw
│
└───sources
│ calendar.py --> Problematic file
│ whatsapp.py
│ __init__.py
│
└───util
- の出力
env\Scripts\pip list
:
Package Version
------------------------ ---------
cachetools 4.2.1
certifi 2020.12.5
chardet 4.0.0
google-api-core 1.26.1
google-api-python-client 2.0.2
google-auth 1.27.1
google-auth-httplib2 0.1.0
google-auth-oauthlib 0.4.3
googleapis-common-protos 1.53.0
httplib2 0.19.0
idna 2.10
oauthlib 3.1.0
packaging 20.9
pip 21.0.1
protobuf 3.15.5
pyasn1 0.4.8
pyasn1-modules 0.2.8
pyparsing 2.4.7
pytz 2021.1
requests 2.25.1
requests-oauthlib 1.3.0
rsa 4.7.2
selenium 3.141.0
setuptools 49.2.1
six 1.15.0
uritemplate 3.0.1
urllib3 1.26.3