0

I'm creating a program that I would like to use as a normal program as well as continue to code it on the side. To do this I first tried creating a shortcut of the .py file in my PyCharms project folder and sent it to desktop. When I double-clicked the shortcut the command prompt would open for a second and then shut. It's a PyQt4 program so I'm not sure if this has any bearing. The program has been coded in Python 3.4. I've noticed that when I open the command prompt and type 'python' it shows Python 3.5 for some reason so I'm not sure if this has any bearing on the situation.

If you've ever programmed in C# I'd like to be able to build a solution and then rebuild the solution when I've updated the code so that I can access the program as a normal program as well as continue to improve the code of it.

Thanks for any help.

WewLad
  • 717
  • 2
  • 11
  • 22
  • 1
    have a look at: http://stackoverflow.com/questions/49146/how-can-i-make-an-exe-file-from-a-python-program – apomene May 18 '16 at 11:17
  • You should state which operating system you are using because it does make a difference whether you have Linux, Windows etc. – rbaleksandar May 18 '16 at 12:31

2 Answers2

0

Managed it thanks to the link above. Uninstalled Python 3.5 and set my PATH variable to C:\Python34. Downloaded pyinstaller and installed it using PIP. Then navigated to Python34/Scripts and dragged myFile.py (the one to be made an .exe) into it. Ran pyinstaller.exe --windowed myFile.py to create the exe which then went to my dist folder. Created a shortcut and it worked perfectly.

WewLad
  • 717
  • 2
  • 11
  • 22
  • You don't need to uninstall Python 3.5. Just make sure your path doesn't point to python 3.5 and instead point your path to Python 3.4 or your virtual environment that has all of your python libraries that the script uses. Just have a shortcut on your desktop that points to your the .py file that you are working on. – justengel May 18 '16 at 12:03
0

Go to your environmental variables (Right click on Computer > Properties > Advanced system settings > Environment Variables...). Find Path in System variables, select it, and click edit. Remove the Python 3.5 path and replace it with your python 3.4 or virtual environment folder that has python.exe in it.

Make a shortcut on your desktop that points to the .py file that you are editing.

If you have all of the dependencies right then double clicking the .py file's shortcut should run your program.

Other wise you can pip install cx_freeze and use cx_freeze like setuptools. Create a setup.py file and build the executable.

If you want to install this executable I suggest using Inno Setup. It is pretty straight forward on how to use and has an easy wizard that helps you build a basic installer.

justengel
  • 6,132
  • 4
  • 26
  • 42