简体   繁体   English

在 Python 中运行 pdoc 时如何解决 ModuleNotFoundError?

[英]How do I resolve ModuleNotFoundError when running pdoc in Python?

I will preface this by saying I'm still getting familiar with Python.我会先说我仍然熟悉 Python。 My code executes just fine, with no errors.我的代码执行得很好,没有错误。 I have all the packages installed that I need.我已经安装了我需要的所有软件包。 But when I try to create the documentation for my code using pdoc --html <filename> , I receive this error...但是当我尝试使用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'

Here are the import statements at the beginning of my file that I tried running pdoc on.这是我尝试在其上运行 pdoc 的文件开头的导入语句。

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

I'm thinking this is an issue with pathing, and I need to do something with my PYTHONPATH variable, but I'm not sure.我认为这是路径问题,我需要对我的 PYTHONPATH 变量做一些事情,但我不确定。 Any help would be much appreciated任何帮助将非常感激

This looks like you don't have couchbase installed in the Python environment you're running pdoc in. You need to have pdoc in the same Python environment as your script and its dependencies.看起来您没有在运行couchbase的 Python 环境中安装 couchbase。您需要在与脚本及其依赖项相同的 Python 环境中安装 pdoc。 :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何让 pdoc 保留空格? - How do I make pdoc preserve whitespace? Python Github pdoc - ModuleNotFoundError:没有名为 mainFile 的模块 - Python Github pdoc - ModuleNotFoundError: No module named mainFile 如何解决 ModuleNotFoundError:虚拟环境中没有名为“skimage”的模块 - How do i resolve ModuleNotFoundError: No module named 'skimage' in virtual environment 运行 python 时出现 ModuleNotFoundError - ModuleNotFoundError appears when running python 我如何修复这个 Python ModuleNotFoundError - How do I fix this Python ModuleNotFoundError 当我运行我的 flask 应用程序时收到此错误,我什至安装了轮子然后烧瓶 bcrypt。 如何解决以下 ModuleNotFoundError? - I am receiving this error when I run my flask app, I have even installed wheel then flask-bcrypt . How do I resolve the following ModuleNotFoundError? 在anaconda提示符下运行Python脚本时发生ModuleNotFoundError - ModuleNotFoundError when running Python script in anaconda prompt Anaconda 提示:运行 Python 脚本时出现 ModuleNotFoundError - Anaconda prompt: ModuleNotFoundError when running Python script Atom在运行python脚本时显示ModuleNotFoundError - Atom shows ModuleNotFoundError when running python script 如何解决 ModuleNotFoundError? - How to resolve ModuleNotFoundError?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM