简体   繁体   中英

pdoc3- ValueError: File or module not found

I'm using pdoc to generate documentation for one of my projects. This is my file structure-

my_project
|- files
|- logs
|- scripts
   |- __init__.py
   |- main_script.py
   |- script_one.py

..where the main_script.py imports script_one.py and a few other libraries. And the __init__.py is empty.

From inside my_project/ directory , I run pdoc3 --html scripts and face the following error-

ValueError: File or module 'scripts.main_script' not found

. . .

I run pdoc3 --html scripts/main_script.py and face the following error-

ImportError: Error importing 'scripts/script_one.py': No module named 'random_module'

. . .

From inside scripts/ directory , when I run pdoc3 --html main_script.py , it throws me an import error like-

ImportError: Error importing 'main_script.py': No module named 'some_module'

But it generates the doc as soon as I remove the some_module from my main_script.py .

What's wrong here?

I am having a similar problem.

My folder structure is similar to that of the original question, but with extra script folders. When running pdoc script_name.py inside each of those folders some files gave me the error

ImportError: Error importing 'module_name.py': No module named 'module_name'

I was able to fix those by making sure all the routes were right and, for some reason, changing the order of imports. Try importing first all your files and then the rest (such as numpy, pandas, ...)

The one thing I haven't been able to solve is that, althought I can generate the documentation for all individual files, one (and only one) of the folders still gives me the error

ValueError: File or module 'script_folder..module_name' not found

Make sure the PYTHONPATH env variable includes the folder with the modules. See pdoc-no-module-named-xxx

make sure pdoc3 is installed in separate virtual environment. set environment variables for the root folder example folderx After exporting the path of the folderx use this

pdoc3 --html folderx

to generate pyfiles of folderx as documents in a folder called html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM