[GH-ISSUE #309] [Bug] cannot import .py module in same folder as main .py #270

Closed
opened 2026-02-26 12:21:01 +03:00 by kerem · 7 comments
Owner

Originally created by @jdai on GitHub (Sep 8, 2022).
Original GitHub issue: https://github.com/brentvollebregt/auto-py-to-exe/issues/309

Originally assigned to: @jdai on GitHub.

Quick Checks For You

  • [x ] I have read/searched in the help post
  • I have searched other issues looking for an issue similar to mine
  • [ x] I have made sure my applicaiton/script runs before trying to package

Describe the bug
Traceback (most recent call last):
File "pyidm.py", line 11, in
File "PyInstaller\loader\pyimod02_importers.py", line 493, in exec_module
File "pyidm\PyIDM.py", line 24, in
from dependency import install_missing_pkgs
ModuleNotFoundError: No module named 'dependency'
[2416] Failed to execute script 'pyidm' due to unhandled exception!

above log shows pyidm\dependency.py is not found.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

If you have example code, please provide a minimal reproducible example.

Expected behavior
A clear and concise description of what you expected to happen.
whole project pyidm can be found in github, used to be in pysimplegui.
as I choose single folder to generate .exe, all .py in the folder or in the subfolder would be included. the structure of the project:
project folder is PyIDM, main code is pyidm.c, it just runs pyidm\PyIDM.py;
pyidm\PyIDM.pyhas "from dependency import install_missing_pkgs";
pyidm\dependency.py it has function "def install_missing_pkgs():" it reads PyIDM\requirements.txt which contains package like:
PySimpleGUI>=4.18
pyperclip
plyer
certifi
youtube_dl
pycurl
install_missing_pkgs() check and installs above packages.

Screenshots
If applicable, add screenshots to help explain your problem.

Your Environment:

  • Python version (python --version): 3.8.1 or 3.10
  • auto-py-to-exe version (pip show auto-py-to-exe): download from github on Sept 7 2022
  • PyInstaller version (pip show pyinstaller): 5.3
  • Eel version (pip show eel): 0.14.0

Additional context
The challenges are:
1.project folder contains main py code and subfolders contains icon and source code folder
2.main py is just one line to run sub-main code in subfolder, and the sub-main py code can run directly
3.sub-main code imports several local and public packages, and access requiremtns.txt in main folder
4.code check and install public packages via pip, including pycurl that need refers to Internet (still using pip cmd)
5.to make pyidm project running, I did change style of "from .<> import" to remove the '.' as it gives error:
from .version import version
ImportError: attempted relative import with no known parent package
In fact I don't know how to import packages in sub folders, with or w/o '.' sometimes work sometimes not

Originally created by @jdai on GitHub (Sep 8, 2022). Original GitHub issue: https://github.com/brentvollebregt/auto-py-to-exe/issues/309 Originally assigned to: @jdai on GitHub. **Quick Checks For You** - [x ] I have read/searched in the [help post](https://nitratine.net/blog/post/issues-when-using-auto-py-to-exe) - [x] I have [searched other issues](https://github.com/brentvollebregt/auto-py-to-exe/issues?q=is%3Aissue+) looking for an issue similar to mine - [ x] I have made sure my applicaiton/script runs before trying to package **Describe the bug** Traceback (most recent call last): File "pyidm.py", line 11, in <module> File "PyInstaller\loader\pyimod02_importers.py", line 493, in exec_module File "pyidm\PyIDM.py", line 24, in <module> from dependency import install_missing_pkgs ModuleNotFoundError: No module named 'dependency' [2416] Failed to execute script 'pyidm' due to unhandled exception! above log shows pyidm\dependency.py is not found. **To Reproduce** Steps to reproduce the behavior: 1. Go to '...' 2. Click on '....' 3. Scroll down to '....' 4. See error > If you have example code, please provide a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example). **Expected behavior** A clear and concise description of what you expected to happen. whole project pyidm can be found in github, used to be in pysimplegui. as I choose single folder to generate .exe, all .py in the folder or in the subfolder would be included. the structure of the project: project folder is PyIDM, main code is pyidm.c, it just runs pyidm\PyIDM.py; pyidm\PyIDM.pyhas "from dependency import install_missing_pkgs"; pyidm\dependency.py it has function "def install_missing_pkgs():" it reads PyIDM\requirements.txt which contains package like: PySimpleGUI>=4.18 pyperclip plyer certifi youtube_dl pycurl install_missing_pkgs() check and installs above packages. **Screenshots** If applicable, add screenshots to help explain your problem. **Your Environment:** - Python version (`python --version`): 3.8.1 or 3.10 - auto-py-to-exe version (`pip show auto-py-to-exe`): download from github on Sept 7 2022 - PyInstaller version (`pip show pyinstaller`): 5.3 - Eel version (`pip show eel`): 0.14.0 **Additional context** The challenges are: 1.project folder contains main py code and subfolders contains icon and source code folder 2.main py is just one line to run sub-main code in subfolder, and the sub-main py code can run directly 3.sub-main code imports several local and public packages, and access requiremtns.txt in main folder 4.code check and install public packages via pip, including pycurl that need refers to Internet (still using pip cmd) 5.to make pyidm project running, I did change style of "from .<> import" to remove the '.' as it gives error: from .version import __version__ ImportError: attempted relative import with no known parent package In fact I don't know how to import packages in sub folders, with or w/o '.' sometimes work sometimes not
kerem 2026-02-26 12:21:01 +03:00
Author
Owner

@brentvollebregt commented on GitHub (Sep 8, 2022):

Your script is named "pyidm.py" and the library you are importing is called "pyidm" - are you sure you really ran your script before packaging?

<!-- gh-comment-id:1240303466 --> @brentvollebregt commented on GitHub (Sep 8, 2022): Your script is named "pyidm.py" and the library you are importing is called "pyidm" - are you sure you really ran your script before packaging?
Author
Owner

@jdai commented on GitHub (Sep 8, 2022):

of course I run my file and it works w/o error. After use your tool:
1.my source folder becomes empty - terrible and I'm struggle to get them back
2.latest convert exe can run but w/o any result - run, done, nothing.
3" the library you are importing is called "pyidm" not that simple. source codes in base, pyidm and icon folders, code refers to many global packages.

<!-- gh-comment-id:1241068496 --> @jdai commented on GitHub (Sep 8, 2022): of course I run my file and it works w/o error. After use your tool: 1.my source folder becomes empty - terrible and I'm struggle to get them back 2.latest convert exe can run but w/o any result - run, done, nothing. 3" the library you are importing is called "pyidm" not that simple. source codes in base, pyidm and icon folders, code refers to many global packages.
Author
Owner

@jdai commented on GitHub (Sep 8, 2022):

I suggest you read all filenames of a project, then match them in all source codes, then you won't miss the usage. any local source code - I mean .py - can refer to sub,parallel level or base folder. Also handle all import statement. If your code is smart, it shall handle common requirements.txt or similar.

<!-- gh-comment-id:1241074501 --> @jdai commented on GitHub (Sep 8, 2022): I suggest you read all filenames of a project, then match them in all source codes, then you won't miss the usage. any local source code - I mean .py - can refer to sub,parallel level or base folder. Also handle all import statement. If your code is smart, it shall handle common requirements.txt or similar.
Author
Owner

@brentvollebregt commented on GitHub (Sep 9, 2022):

I suggest you read all filenames of a project, then match them in all source codes

What source code??? You have no reproduction steps. Please provide proper reproduction steps otherwise I will need to close this.

<!-- gh-comment-id:1242314912 --> @brentvollebregt commented on GitHub (Sep 9, 2022): > I suggest you read all filenames of a project, then match them in all source codes What source code??? You have no reproduction steps. Please provide proper reproduction steps otherwise I will need to close this.
Author
Owner

@jdai commented on GitHub (Sep 22, 2022):

https://github.com/P3NG3R/pyIDM
please try to convert it to exe thus you can find lots of errors. In another thread I already told you how to install pucurl.

<!-- gh-comment-id:1254502231 --> @jdai commented on GitHub (Sep 22, 2022): https://github.com/P3NG3R/pyIDM please try to convert it to exe thus you can find lots of errors. In another thread I already told you how to install pucurl.
Author
Owner

@github-actions[bot] commented on GitHub (Oct 23, 2022):

This issue is stale because it has been open for 60 days with no activity. Remove stale label or comment on this issue or it will be closed in 5 days.

<!-- gh-comment-id:1287973761 --> @github-actions[bot] commented on GitHub (Oct 23, 2022): This issue is stale because it has been open for 60 days with no activity. Remove stale label or comment on this issue or it will be closed in 5 days.
Author
Owner

@jdai commented on GitHub (Oct 28, 2022):

pls close it, not pysimplegui problem

<!-- gh-comment-id:1295318619 --> @jdai commented on GitHub (Oct 28, 2022): pls close it, not pysimplegui problem
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/auto-py-to-exe#270
No description provided.