I'm trying to make my python script executable file. However, when I convert it to exe with pyinstaller or py2exe, executable file does not work. I opened in cmd, no error but still does not work as i expected. On the other hand, when I start the actual python script, it works without a problem.
Here is what my folder structure looks like:
account_details.json
posts.xls
actual_python_script.py
What could be the problem and how can I solve this?
Related
stack overflow has been a great source since I first started learning Python, so wanted to thank the community... anyways first time poster.
I'm new to python so excuse me as my terminology may be a bit off.
I have a script that uses pandas read excel. I give it a xlsx doc name and it finds the file in the same folder as the script.
I can run my script fine from my terminal.
Using pyinstaller, I can run the script fine from a windows pc as an exe.
When I try to run the pyinstaller's unix executable, on mac, the read excel function fails to find the doc and cwd function returns (user/myname), rather then using the same directory as the executable.
Am I doing something wrong here or should I be adding something to help the executable find the file? Any help would be greatly appreciated!
Script works fine if I move the file to my user/myname folder, but I would assume since the pandas function isn't given a specific directory to check, it should just be checking the folder I run the executable from?
I need to make executable file on OSX/Mac. I have python3 script that uses excel file. Executable file also should be able to work just by double clicking the icon and also have python packages. I mainly work with Ubuntu18 but have access to Mac for few days.
What I've tried so far:
I've written a short bash script that activates python environment (with "source activate" command) and runs python script. Appified the script with this: https://gist.github.com/anmoljagetia/d37da67b9d408b35ac753ce51e420132
I know that terminal commands work but double-clicking the app in Mac does nothing.
With pyinstaller converted bash+python script to exe, then with wine tried converting that to executable program but that double-clicked program does nothing.
Tried py2app, but in the mac terminal it says "cannot execute binary file".
Does someone have any recommendations for my problem? As I've mentioned there are few main requirements:
works by double-clicking
works on mac
has all python packages
is able to read specific excel file (I will know the name of it, but just path may be confusing in some versions, because I would like to use relative path or something like [pwd]/file.xlsx)
Anyway, I'm having most problems with the first two points but don't want to forget the last two.
Thank You for help!
I'm trying to run a fairly simple Windows Python 3.7 script that uses Webbot. The script works beautifully from within Python's IDLE, so I know the code that I've written works and there's nothing wrong with it, but I want to run it as an .exe instead. However after packaging it with Pyinstaller (which normally works wonderfully), although the Pyinstaller process runs, the actual program produced won't run at all.
I had a look here but this didn't help much. If I compile using:
pyinstaller file.py
as suggested, when I run the resulting .exe, the program closes instantly, with no error message.
If I instead try:
pyinstaller --onefile file.py
or:
pyinstaller file.py -F
Then when I run the compiled .exe I get this message:
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\\Users\\KimJiwoo\\Appdata\\Local\\Temp\\_MEI51362\\drivers\\chrome_windows.exe'
So I guess I need chrome_windows.exe?
I figured I could just give the program this file, but the _MEI folder is a temp directory that seems to be created each time. I've tried putting chrome_windows.exe in other places, like in System32 or the same directory where file.py or the created .exe is, the same error occurs.
So I guess I have to make this program see chrome_windows.exe somehow but I'm not sure how. I do already have
from webbot import Browser
in my script, but clearly I need something more than this. Not sure what.
Note that I'm not that fussed whether the Python program includes chrome_windows.exe within its own created .exe or not. I mean, that would be nice, but if it's simpler coding-wise to just shove chrome_windows.exe into a directory on the computer the program is running from, and have something in the program pointing to it there, then that would also be fine. I feel like the answer to this is probably simple so I'm after the most simple, elegant solution possible.
The path for the webdriver in the Webbot source seems to be driverpath = os.path.join(os.path.split(__file__)[0] , 'drivers{0}{1}'.format(os.path.sep , driverfilename)) (when you compile to exe, the files directory is in TEMP).
You can use the source to make your own class and change the directory path (github.com/nateshmbhat/webbot/blob/master/webbot/webbot.py).
I have written small code in python for data scraping using selenium, and BeautifulSoup.
The code is working great in pyCharm but when I convert my file from .py to EXE using pyinstaller example.py command, it converts correctly but the EXE file flashes and terminates and the code doesn't execute.
This is the result of the pyinstaller command:
This happens when there is an error being faced by the python script. Try running the .py module file in IDLE or by simple double clicking the .py .
I guess pyCharm creates a virtual environment which might be causing the issue.
Maybe try adding try/except for the code so that it doesn't flick away, rather shows the error.
I have been working on a python GUI based project using PyQt5. I am done with that and it runs perfectly on my PC but I want to make an executable out of it. So, i'm using cx_freeze to convert my python file to an executable. I have python version 3.5 and PyQt5.
When I build the script the build folder is made and when I run the executable it get the missing modules error as shown in the image attached.
Kindly, help me out i am stuck on this for ages now.
Copy all the modules in the same directory as the file you are converting to exe, then try it again.