I have recently downloaded some models for blender but when I unzipped it the file was in .py format I want to add them to my project but I cant I tried "open in" method but no results..... can anyone tell me how to fix it
You can simply change its format from .py to .blend
you can do this with help of notepad.
open .py file in notepad and save as .blend format.
Please specify what the content of the .py file is.
A .py file is a python script, and you can't just "convert" it in a blender file. They are two different things.
It might be the case that the .py file is just a text file (saved as a .py file) that contains the coordinates of a mesh. In this case, just change .py in .obj and import it in blender.
Related
I have written code in python which opens up a template excel file. Everyday, a midnight, it copies that template into a new excel file where the code will record data into it for that day. My goal is to create a single executable file containing my code AND the template excel file using pyinstaller.
Basically I want to be able to open the template excel file regardless of whether the computer contains the file or not by bundling the excel file into the exe file obtained from pyinstaller:
Right now I open the excel file as shown below:
import os
import openpyxl
theFile = openpyxl.load_workbook(os.getcwd()+"\templateExcel.xlsx")
currentSheet = theFile[theFile.sheetnames[0]]
However, when I include the excel file to the pyinstaller command as --add-data "templateExcel.xlsx;templateExcel.xlsx, and run the exe file, it is not able to detect the location of the templateExcel file. I understand that by running on a different computer, the os.getcwd() gives a different path so it would obviously not be able to open the excel file. Hence I needed a way to bundle the excel file into the exe file such that the python code can find it regardless of the computer.
You can use;
Adding a data file in Pyinstaller using the onefile option
Summarly:
pyinstaller --onefile --nowindow --add-data text.txt;included winprint.py --distpath .
and sample python script:
import os
import sys
os.chdir(sys._MEIPASS)
os.system('included\\text.txt')
Please note:
When using "getcwd()" you won't receive the desired outcome you were looking for, it will get you the place from which you have executed your exe file.
For example, look at the following long module:
from os import getcwd
print(getcwd())
If you execute it from different locations, you will get different results:
Had PyInstaller worked like you assume it would (placing the file relative to some module) you could have used file instead of getcwd() as it indicated where the module resides (which is constant, unlike the location from which the exe is executed), but it doesn't.
Any way, #Sezer BOZKIR's answer should suffice, note the comment I added there.
I want to make .py as standard filetype in Visual Studios Code, so I don´t have to search "Python" every time I save files. I only learn python so it would be very nice.
Presumably you're on Windows and trying to choose the file type when going through the Save dialog. You actually don't have to change the file type; all it does is save you from having to type .py at the end of your file name. If you write the whole file name out with file extension then VS Code will not add the default .txt file type extension.
I wrote a program in Python that includes external files, including images and a GUI .ui file.
I want to convert the Python script to a single executable (.exe) file using PyInstaller. When I try to open the .exe file, the program does not open.
You will need more information on why the application is closing immediately in order to solve your problem. To view the error messages associated with running your executable, run the .exe file from the command prompt: /path/to/app/dist/MyApp.exe. This will allow you to observe any errors that may exist after the app was bundled. If the program fails during an import statement, you may need to add a package to the hiddenimports list in the .spec file. Check the PyInstaller documentation for instructions on modifying the .spec file.
https://drive.google.com/file/d/0BwR0ium7uufRWnhXWWNFcVJ3S2c/edit?usp=sharing
The files that are blank and say "Credit Card Balance" and "mine" are the files which I created by opening up a new document in IDLE and creating a file. The ones with the little pictures and say ps2_newton are programs which I downloaded off of the internet. I can't open my files which I created like they are regular programs and have to open them under notepad to see the code. Why is this? How can I change my files to look and act like the ones I downloaded?
The files you downloaded have an extension of ".py", which tells Windows to open them with the Python launcher, while the ones you created have no extension, or an extension of ".txt", which tells Windows to open them in Notepad.
Since ".py" and ".txt" are both "known extensions", and you have Explorer configured to hide known extensions (which I believe is the default in all versions of Windows), it doesn't show them to you. However, you can see the difference in the icons.
You can configure Explorer to show all extensions, but this site is not the place to ask about that—try SuperUser.
Meanwhile, when you save your scripts, make sure you save them with a .py extension (or, if they're Tkinter or other GUI apps, with a .pyw extension).
I had the same problem. But I just deleted all of the é's and á's etc. And it worked! So try that IF it is an .py file. Otherwise I understand if it does not work becouse it isn't a python file. You change that by doing this: Save as. Just simply type .py after the file name.
PS Sorry for my bad english...
I have .ui, .py and .pyc files generated. Now, when I edit the .py file, how will it reflect changes in the .ui file? How do I connect .the ui and .py files together as QT designer allows only .ui files for running purposes?
Don't edit the generated .py file. Create another .py file for the Python code you need to write. This module should load the UI. This would also be the module to run, if these are the only files in the project. See a tutorial from here: http://diotavelli.net/PyQtWiki/Tutorials
the .py file generated from pyuic is not supposed to be edited by the user, best way it is intended to use is to subclass the class in .py file into your own class and do the necessary changes in your class..