ModuleNotFoundError Only when EXE (Python) - python

I am trying to make a program using PySimpleGUI and whenever I run it as a .py (Python) file I get 0 errors and it runs exactly how I want it to, but when I use pyinstaller to compile the .py file to an EXE I get this error:
Traceback (most recent call last):
File "guitest.py", line 2, in <module>
ModuleNotFoundError: No module named 'PySimpleGUI'
[14792] Failed to execute script guitest
I am not sure why it is saying that, I have it installed. As I said before as long as it's a .py file it runs perfectly.

Related

How to solve the output problem with CodeRunner in vscode?

I have my own project with virtual environment. When I am trying to debug code everything executes flawlessly and I get the expected output, but when I am trying to run it with run code option from Code Runner extension I receive the error:
[Running] python -u "c:\Users\slikm\Pulpit\ytapi\yt_api.py" Traceback (most recent call last): File "c:\Users\slikm\Pulpit\ytapi\yt_api.py", line 2, in <module> from googleapiclient.discovery import build ModuleNotFoundError: No module named 'googleapiclient'
I have the library which the module is taken from installed on my venv. I read that the problem might be with the interpreter the extension uses, but I don't really know how to figure it out.

rpy2 is working fine in console but not working in executable file

i'm using rpy2 in spyder 4. all commands are working fine in console. i created an executable with pyinstaller and i got this error in exe file.
Traceback (most recent call last):
File "kopa.py", line 12, in <module>
ModuleNotFoundError: No module named 'rpy2'
[13148] Failed to execute script kopa
I will give an example to be short;
import os
os.environ['R_HOME'] = 'C:/Program Files/R/R-3.6.3'
os.environ['R_USER'] = 'C:/ProgramData/Anaconda3/Lib/site-packages/rpy2'
import rpy2.robjects as ro
ro.r("x=c(1,2,3,4,5)")
ro.r("y=c(11,12,13,14,15)")
ro.r("z=mean(x)+mean(y)")
print(ro.r("z"))
all working fine in console. when i create executable file then i'm getting the above error. where is the problem?

ModuleNotFoundError on jenkins build cannot be replicated locally

Running an exe file which gives the below error on win10 build agent but not when the same script is ran on win10 locally:
16:06:50 Traceback (most recent call last):
16:06:50 File "C:\ProgramData\Anaconda3\envs\conda_venv\lib\site-packages\cx_Freeze\initscripts\__startup__.py", line 14, in run
16:06:50 File "C:\ProgramData\Anaconda3\envs\conda_venv\lib\site-packages\cx_Freeze\initscripts\Console.py", line 26, in run
16:06:50 File "package.py", line 98, in <module>
16:06:50 File "C:\ProgramData\Anaconda3\envs\conda_venv\lib\site-packages\testing_framework_sdk\__init__.py", line 15, in <module>
16:06:50 ModuleNotFoundError: No module named 'test_case_sdk'
Both files are ran from the same downloaded package with no changes in contents between the two.
Script does not require additional programs such as Python in order to operate.
Given that library files(.pyc) are contained within the downloaded directory I assume that this exe was generated using pyinstaller. python36.dll is also contained within the downloaded package
I don't have access to the source for this exe.
The file test_case_sdk.pyc does exist in the same directory for both the jenkins agent and local machine.
Do anyone know what is causing this discrepancy?
Edit: Turns out the filepath to test_case_sdk exceeded windows default limit of 260, this was why the module could not be found. I condensed the file path, error has gone.

How do I make pyinstaller identify my custom imports?

I'm trying to create an exe out of a small Python Project. I have a main.py which imports packages from other subdirectories. After building the exe using pyinstaller when I run the executable I am facing import problems, its failing to identify the relative imports.
I tried modifying the .spec file but am unable to rectify the issue.
This is the current directory structure of my project
Link to project structure image
When I run the executable dist\cli\cli.exe it gives me this import error
Traceback (most recent call last):
File "cli.py", line 3, in <module>
from packages.__main__ import main
ImportError: No module named __main__
[5964] Failed to execute script cli

Tkinter not including in pyinstaller

Actually I'm trying to make a local search engine .The code works fine when running in pycharm but after created exe file using pyinstaller with options like --hidden-import=Tkinter --windowed, while try to execute the exe file it shows error like this
D:\untitled\tk\dist\scroll>scroll.exe Traceback (most recent call
last): File "scroll.py", line 28, in ImportError: No module
named Tkinter
Traceback (most recent call last): File "scroll.py", line 219, in
NameError: name 'Frame' is not defined Failed to execute
script scroll
D:\untitled\tk\dist\scroll>
The code written in python 2.7 is attached below I've also tried with python 3 but same problem
http://pastebin.com/4XWfcnzf

Categories