I am looking to take a .exe file I've built using cx_Freeze, move it to my desktop, and have the ability to execute it while allowing it to reference the necessary directory. When I copy and paste the application, it tries to find its necessary files on the desktop rather than in the original directory.
Currently, all my files (including the .exe file) for this program are in the directory C:\Users\my_name\PycharmProjects\PROGRAM_DIRECTORY\build\exe.win32-3.4. I would like to take the file PROGRAM.exe, move it to my desktop (for more accessible execution) while still permitting it to reference all of the necessary files in the C:\...\exe.win32-3.4 directory. Is this possible?
Copying the .exe file from the directory and pasting it to the desktop will create a shortcut that has a default reference directory of its new location (the desktop), and this cannot be changed. A way around this is:
-Right click on the desktop
-Select "New > Shortcut"
-Browse for the .exe file or copy the directory into the field and add \PROGRAM.exe after it
-Name the shortcut
This shortcut will direct the execution to the parent file which remains in its necessary directory (C:\...\exe.win32-3.4) rather than trying to reference the desktop as the directory.
Related
I am using an executable file generated with Pyinstaller from my Python script.
Every time I open it, it creates a folder named (for example) _MEI12345 in \AppData\Local\Temp.
How can I prevent the creation of that folder? Are there other (better) ways to create an executable file if I have to distribute it?
I created an executable with pyinstaller. The file is in the directory Build and I need to have several shortcuts of this .exe in many different directories. The problem is, my program uses an Excel table which will be accessed through a relative path. So when I use a shortcut of my .exe, the Excel table can't be found because the relative path works for the original .exe but not for the shortcut.
How can I access the Excel table?
I'm writing a script that will download an executable from the internet, which will create more files. Now, if I download the file, it will be downloaded to the directory I told it, but when I open it using os.startfile(), it creates the files to the directory where the python script is located. How can I avoid that?
Either you can move the .py file to any other directory.
or
You can use os.chdir() to change the current working directory of the script during the runtime.
os.chdir('/path/to/directory')
Do a os.chdir() before trying to run the executable:
os.chdir('<the target folder where you want the files to be created>')
...
os.startfile('<path to where the executable was downloaded>')
After weeks of reading and experimenting, I still cannot figure out how to run Python3 programs, using batch files, from the WIN-R Run Window on Windows 10, if the batch files are saved in a different directory than the home directory.
It seems to work fine if I save both the .py file and the .bat file to the "C:\Users\Name" directory. But I would like to save my programs to Dropbox so they can be used from different PCs.
My first issue was caused by a space in the Dropbox file path. I learned that putting quotation marks around the path addresses this issue.
But I still cannot figure out how to run batch files from anywhere other than my home directory from the WIN-R Window. Is it possible to run batch files from a Dropbox folder using the WIN-R Run Window? Is it possible to change the directory in WIN-R? I've tried creating a new shortcut as suggested by others here so that WIN-R opens in my Dropbox directory, but nothing I've done to date has worked.
To change the directory from the Win-R Window, you can refer to this link:
http://www.sthda.com/english/wiki/running-rstudio-and-setting-up-your-working-directory-easy-r-programming
Hope this helps!
I have a project that uses COM and 'Python' scripting. Earlier we were using 'ComTypes' now we use Win32Com. To keep backward compatibility I need to change name of some of the interfaces. So here is what I do
1) Use the 'makepy' utility to create a python file from my .tlb file, this creates a .py file at ..\Lib\site-packages\win32com\gen_py folder
2) I change the name of the interface that I am interested in changing in the created python file.
3) When I load my application a corresponding .pyc file gets created and everything works fine.
Now I don't want to repeat this exercise on every machine where my software is deployed. So through the installer I copy the .py and .pyc files to ..\Lib\site-packages\win32com\gen_py
But when my application is launched it does not recognize the changed interface. Behaves as if there is no .py or .pyc file. All other interfaces work, but the changed name one does not work. It dynamically seem to create compiled python behind the scene, ignoring the .pyc file.
If I delete the .dat file and .pyc file at those locations, it does create the .pyc file again when the application is launched. However its not utilized, because my changed interface does not work.
If I use the steps 1,2 and 3 everything works again !! I am puzzled.
Please help.
OK. I found out what is the problem. When you create a python file using makepy tool it updates the dicts.dat file in gen_py directory. So you need to copy over that file as well to other machines.