0

我会先说我仍然熟悉 Python。我的代码执行得很好,没有错误。我已经安装了我需要的所有软件包。但是,当我尝试使用 为我的代码创建文档时pdoc --html <filename>,我收到此错误...

Traceback (most recent call last):
  File "/home/mike_bowerman_puzzle_consulting/.pyenv/versions/3.7.2/lib/python3.7/site-packages/pdoc/__init__.py", line 225, in import_module
    module = importlib.import_module(module_path)
  File "/home/mike_bowerman_puzzle_consulting/.pyenv/versions/3.7.2/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/dev_test/python_reports/Sample_Expansion.py", line 8, in <module>
    from couchbase.n1ql import N1QLQuery
ModuleNotFoundError: No module named 'couchbase'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/mike_bowerman_puzzle_consulting/.pyenv/versions/3.7.2/bin/pdoc", line 11, in <module>
    load_entry_point('pdoc3==0.9.2', 'console_scripts', 'pdoc')()
  File "/home/mike_bowerman_puzzle_consulting/.pyenv/versions/3.7.2/lib/python3.7/site-packages/pdoc/cli.py", line 534, in main
    for module in args.modules]
  File "/home/mike_bowerman_puzzle_consulting/.pyenv/versions/3.7.2/lib/python3.7/site-packages/pdoc/cli.py", line 534, in <listcomp>
    for module in args.modules]
  File "/home/mike_bowerman_puzzle_consulting/.pyenv/versions/3.7.2/lib/python3.7/site-packages/pdoc/__init__.py", line 609, in __init__
    module = import_module(module)
  File "/home/mike_bowerman_puzzle_consulting/.pyenv/versions/3.7.2/lib/python3.7/site-packages/pdoc/__init__.py", line 228, in import_module
    .format(module, e.__class__.__name__, e))
ImportError: Error importing 'Sample_Expansion.py': ModuleNotFoundError: No module named 'couchbase'

这是我尝试在其上运行 pdoc 的文件开头的导入语句。

import sys
import os
from subprocess import Popen
import json
import time
import csv
import datetime
from couchbase.n1ql import N1QLQuery

我认为这是路径问题,我需要对我的 PYTHONPATH 变量做一些事情,但我不确定。任何帮助将非常感激

4

1 回答 1

1

这看起来您没有couchbase在运行 pdoc 的 Python 环境中安装。您需要在与脚本及其依赖项相同的 Python 环境中安装 pdoc。:)

于 2021-05-06T17:36:48.217 回答