I suddenly have a problem with file main.py .
I am using pycharm with python version 3.6 from anaconda.
I had a full project that run fine and now the 'main.py' became text file.
If I open a new project and name a new python file as 'main' it automatically turn into text file (any other name remains .py file).
What is the problem?
Related
I'm a newbie to programming. I want to switch my code from Jupyter to Spyder as I find the debugger better.
I'm trying to do something simple and open a file and I keep getting the "No such file or directory message". My text file is in the same directory as my .py file
file_palette = open(r"C:\Users\Myname.spyder-py3\palette.txt", 'r')
I have written a "random movie suggester" code that will basically read the files of the directory where the .py file is stored and randomly pick one of them and print it out.
My problem is -
How to make .py file simple to run for non-technical person?
(e.g. I tried .bat but i had to hard code the path of the file).
Other solutions ask to install IDEs and run it.
First you have to install python on your computer.
Then you can type in your terminal:
python [the file name or the path to access it]
But I don't think this is what you are looking for...
You can create a .exe file with your python program using the pyinstaller module then running this in your terminal.
pip pyinstaller
pyinstaller --onefile [the name of the file]
The first line installs the module using pip.
The second line will create a .exe file that does exactly the same as your python code.
I made a .py file and was looking how to convert it into an .exe file. I found pyinstaller and while messing around with it I was able to create a basic exe file with pyinstaller. The problem is that I didnt have a copy of my .py file as backup because I'm a beginner and now I can't look at my source code. Is there a way for me to decompile the pyinstaller files to attempt to recover some of my code?
My .py file was created in python 3.8 if that is relevant
As you can read in the headline, my .exe file doesn't do his job. After converting the .py file to an .exe file using PyInstaller, the file opens and closes a second later.
To create an .exe file I use:
pyinstaller --onefile --icon="pong.ico" pong.py
Any other files work fine. I use Python 3.8 and PyInstaller 3.6.
Thanks for answers.
So I made a huge mistake and deleted my code file (python). The only thing I have is my python file as .exe that I created with pyinstaller. Is there a way to reverse this and to extract my code file from .exe?
You can extract the contents of the .exe file using PyInstaller Extractor. Run it like this:
python pyinstxtractor.py executable.exe
You will then get a bunch of files, including your original python file.