When I run the code through an extension in Visual Studio Code, it runs fine. But the real problem is when I open the program without the extension it errors and closes instantly. I traced the error back to this line right here.
import os
import pyautogui #Line Right here
from time import sleep
Having the import pyautogui breaks the whole script, and I really do not know why?
This closes out when I import pyautogui
Related
I used auto-py-to-exe to convert my .py to a .exe and why my py works as expected, my exe does not work. The console just springs up for a split second, before closing again and the code does not execute.
In case anyone wonders, these are the modules used in the code:
import os
from tkinter import *
from tkinter import ttk
from tkinter.filedialog import askdirectory
import cv2
import numpy as np
I do not understand where the error occurs...
EDIT:
"Open cmq and run the .exe on the terminal. In this way you can see the error message"
The Console throws no error, it looks like everything worked properly, but it clearly didn`t.
I have made a python app in one python file with the following import statements:
import numpy as np
import PySimpleGUI as sg
import cv2
from PIL import Image, ImageTk
import sys
import os
import pydicom as dicom
from io import BytesIO
import matplotlib.pyplot as plt
from pydicom.pixel_data_handlers import convert_color_space
from scipy.optimize import curve_fit
When I run my app (in spyder), it gives simply a window telling the user to select a folder:
When the user chooses a folder and click ok, the app starts to open other window with buttons to click on etc. I have tested in spyder many times that my code does not contain error and in particular will not crush. My goal is to convert this one single python file into an exe such that the user can just double click on exe (without python environment) such that the code starts to run and they should see the window telling them to select folders immediately after double click.
I use pyinstaller for the task (with command pyinstaller --onefile main.py, where main.py is the my file. The process is slow (and produces a lot of text) but there does not seem to have errors. When I click on the final exe file, I get two empty windows:
What can there possibly go wrong? Is there any workaround to this? That is, is there anything other than pyinstaller to help me with the task?
I am trying to write a code that allows me to make a keyboard press to trigger an output. I am trying to use the keyboard module to do this, but every time I try to run it I get an error that says:
File "/Users/julietdenapoli/Desktop/keyboard.py", line 10, in from msvcrt import getch ModuleNotFoundError: No module named 'msvcrt'
I kept noticing that the issue was coming from the import keyboard, so I literally just tried to run a one line code:
import keyboard
And I still get that same error. I did pip install keyboard, not really sure why I am running into this error?
I am trying to write a code that allows me to make a keyboard press to trigger an output. I am trying to use the keyboard module to do this, but every time I try to run it I get an error that says:
File "/Users/julietdenapoli/Desktop/keyboard.py", line 10, in
from msvcrt import getch ModuleNotFoundError: No module named 'msvcrt'
I kept noticing that the issue was coming from the import keyboard, so I literally just tried to run a one line code:
import keyboard
And I still get that same error. I did pip install keyboard, not really sure why I am running into this error?
I've tried installing PyGame and it just crashes with the window closing too fast to see the error when I import it. I've tried every package, using the installer or wheel file, but none have worked.
The code I have so far is thus:
import pygame
input()
The program does not wait for a key press and still just closes at execution.
I am aware there are similar questions already, but none of those solutions have seemed to work.
The issue is not with installation. If there is nothing in your program, the program will just open and close really quickly.
You can test out your pygame module this way.
On Windows, open up the Python command line interpreter. Run:
>>> import pygame
>>>
You should see just a blank >>> if it loaded correctly.
Same for Linux and OS X, but just type python in a terminal to run the interpreter.
If it gives an error, comment the error below and we can go from there.