简体   繁体   中英

Embeddable Python - ModuleNotFoundError for project folders

I'm trying to create an embedded python for my project.

  1. I downloaded the portable python 3.7.6
  2. Copied the folders from my main python installation (Lib, Scripts, include, DLLs etc..)
  3. Added them to the PTH file like so:

     python37.zip. Lib Lib/site-packages Scripts include DLLs doc libs Tools tcl # Uncomment to run site.main() automatically #import site

and when I tested it, I tried to run a project with the following structure:

文件夹结构

By running the command (using the embedded python): G:\GitHub\VRoscopy\VRoscopy\Conversion\python\python.exe main.py

I get the following error:

> Traceback (most recent call last):   
>   File "mymain.py", line 1, in <module>
>     import folder.module as m ModuleNotFoundError: No module named 'folder'

However, when I try running the system python everything works normally.

Hope anyone can help me, thanks

The problem was solved by adding the project files to the PTH file, and uncommenting the "import site" like follows:

python37.zip . ../invesalius
../invesalius/*  # <----- added this line
Lib 
Lib/site-packages
Scripts
include
DLLs
doc
libs
Tools
tcl
# Uncomment to run site.main() automatically 
import site

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