I use pycharm on a windows 11
I made a text file and then copypaste my code in there
After i saved the file as .py everytime i ran the file it said that pyper clip module
was missing
when i run the code it just appears and exit
Related
I am trying to turn a .py file into .exe so that it's runnable on other computers without python. I followed this tutorial, installed pyinstaller then ran the command pyinstaller --onefile IRV.py without the -w since my program runs in the console. It successfully built the .exe file but when I run it it immediately closes even though the program itself asks for input at the beginning. It uses a bunch of .txt and .xslx files from the folder of the .py file so I dragged the .exe out of the dist folder but it still gives the same error. I managed to make a quick print screen before it closes and it gives me this error: https://imgur.com/a/w7TVjaN
The script doesn't even work if I double click the .py file. However it runs perfectly fine if I open up the .py file in an IDE like Spyder. When I run the .exe file it opens up the cmd for a few seconds with nothing written on it and then quickly writes that error I managed to screenshot and then closes. If I double click the .py though it instantly closes without the wait or the error message.
Pyinstaller didn't find the libraries or modules you imported. In the build folder that was deleted in the tutorial, there's a text document that shows warnings for libraries that aren't found by the pyinstaller. You may need to check that.
This Q&A mentioned a problem that is related to your Question: No module error when running python script from command prompt
I've been trying to convert a .py file to a .exe file for 2 days now with no luck. I've gotten the farthest with pyinstaller but went I launch the .exe it closes (import errors). In the warning file it has errors such as
missing module named _scproxy - imported by urllib.request
If you need the entire list I can give it to you but it's over 300 lines. I've tried the following with pyinstaller with no luck
Creating a single file exe
Creating a single directory exe
Removing all path altering code
Creating a exe with the noupx option
Putting just the files I need in a directory and creating it (I had other related files that I thought it might be messing up on)
I am using the following
Windows 7 pro
Python 3.6 Anaconda 5.2.0
VS code (is this relevant?)
My .py file basically runs a pre-made sklearn classifier. The classifier for the .py is in the same directory exported and imported using pickle (file name is clf.pickle). Any help would be appreciated and if you need more info please ask. Thanks.
Wrote a game and compiled it with pyinstaller. An EXE file was created but when I go to run it, it thinks for 3-4 seconds and then it returns to command prompt.
Clicking from the folder in Windows does nothing.
No errors, nothing! Do I need something in my code to allow this to run? The only imports are tkinter and random.
Edit 1: tested a "hello world" script to see if there were issues with pyinstaller, it ran fine.
I understand that the post is older, but it may be useful for other member who may come across the similar problem.
I had created a script using Jupiter notebook and it creates ipynb file.
When I create an exe file using pyinstaller, the exe was doing nothing.
I resolved it by first converting ipynb file to py file using below command:
pyinstaller my_script.py
It will create the py file under same location.
Now, execute below command to create exe file:
pyinstaller my_script.py
It will create exe file under dist folder.
And it works.
i have used pyinstaller to create a single .exe for windows using a single .py file and it worked fine. now i have gotten a bit more complex and have created multiple .py files stored in folders beneath my main.py. i've read through the pyinstaller guides , yet something doesn't seem to be working on my part..
my folder structure in windows is as follows, i'm just using a simple example for illustration :
app_root\main.py
app_root\__init__.py
\library\__init__.py
\library\app_ext1.py
\library\app_ext2.py
\library\test\__init__.py
\library\test\app3.py
in main.py i am importing code from
from library.app_ext1 import get_info
from library.app_ext2 import get_data
from library.test.app3 import get_test
so i run pyinstaller to my main.py using my .spec file.
in the .spec file i have
hiddenimports=['library']
pyinstaller finishes no errors and creates my single .exe, but when i run my single .exe i get the following error
C:\Users\user1\Desktop\1_file\dist>main.exe
Traceback (most recent call last):
File "app_root\main.py", line 2, in <module>
ImportError: No module named 'library'
Failed to execute script main
i wrote a test script just using a single .py file and it was doing some simple work with openpyxl (a python excel library) so in my test .py file i had "import openpyxl" , so in my spec file i used
hiddenimports=['openpyxl']
that worked fine but openpyxl is python lib that was installed using pip , i guess i'm not fully understanding how to import my own modules/scripts that i have created and stored in a folder structure beneath my main .py script file that i'm referencing between my .py script files as in my example above.
how can i make pyinstaller recognize my .py scripts i'm importing?
ok not sure why , but i just created a new folder in windows , copied all my .py files using same folder structure as before and then it worked. the only thing missing was all the Pycharm folders like .git, .idea, and pycache
i did notice in troubleshooting that if i renamed library to something else like "test" and updated my import lines it would still reference module "library" when i executed the .exe that was built.
i knew i was doing all this correctly but seems there might have been something in one of the other folders that py charm puts in there.
so i am just going to copy all my files to new folder each time and delete any folders/files i see other than the .py required.
In my case I replaced from library.app_ext1 import get_info to from your_newly_created_folder_name.library.app_ext1 and it worked :D
I noticed app_root name must be changed with new created folder name. just created a new folder, copy all .py files and keep folder structure. I hope you no one else will waste his time like me on this anymore
I have a GUI script, called ui.py, created in PySide that uses functions from another script, called DataFunctions.py. When I run the ui.py file in python it all works perfectly, and when I run the ui.exe file it will all work fine apart from the button that runs the DataFunctions.py file, which does nothing.
In my ui.py file I am importing DataFunctions.py with:
import DataFunctions.py
buttonAction = DataFunctions.writeFile(filename, data)
I am using the following code to create the .exe:
pyinstaller ui.py -w -F
Am I importing the DataFunctions.py file in a way that pyinstaller doesn't support?
Drop the .py extension in the import line
import Datafunctions
Make sure the Datafunctions.py code is in the same folder.
It turns out that the DataFunctions.py file was included in the .exe, however some file paths relative to the DataFunctions.py file inside it were not set correctly due to the .exe being created in another folder. If anyone else is having similar problems, make sure you don't specify -w so that you can use the console to debug your .exe. Look here for how to find the location of the .exe file when it is run.