I am just at the very start of what I think is gonna be a long journey exploring the world of applications in Google App Engine using Python.
I have just downloaded Python 2.6.4 from the Python official website and installed it on my computer (I am using Windows XP). I also downloaded the App Engine Python software development kit (SDK) (from this page) and installed it, too. Both of these steps were suggested on the second page of Google App Engine's Getting-Started Guide.
However, when I moved on to the third page, which is titled as "Hello, World!", I ran into a sort of complication. It is written there:
"Create a directory named helloworld.
All files for this application reside
in this directory. Inside the
helloworld directory, create a file
named helloworld.py, and give it the
following contents..."
I am kind of puzzled here: How do I create a .py file? Is it like I need to create a notepad file (.txt) and name it helloworld.py (when I did so, it didn't change into any different file of any different, but rather stayed an ordinary .txt file) or should I somehow create that file using Google App Engine Launcher that I have installed?
When you downloaded and installed Python, you also installed IDLE. You can use this to easily write, run, debug and save .py files with syntax highlighting. To get started, just open IDLE, and select File -> New Window.
A .py file is a text file containing Python syntax. Use your favourite programming editor, or even NotePad.
Regarding your second problem, there's an option in Windows Explorer about hiding file extensions. Make sure it isn't checked -- you might well actually have renamed your file helloworld.py.txt but only seen helloworld.py
You will need a better editor than Notepad. With Notepad, use Save As..., and type "helloworld.py" in the dialog, including quotes so that the file extension is .py instead of .txt
I am kind of puzzled here: How do I create a .py file? Is it like I need to create a notepad file (.txt) and name it helloworld.py?
I'm not on windows, but thats how it works on other operating systems: Create a file with an editor, then save as ...
ps. and .py is the extension (like .docx, .bat, ...), but it's just a convention (although a highly recommended one) ..
pps. heard the http://www.e-texteditor.com/ has more capabilities than notepad ..
You have to be aware that the ending signifies recognition of files, not content. Name a file .py simply hints to the user (and the GUI) that it most likely is a python file.
That being said, python files are merely text files. You can simply create a text file with Notepad (or your editor of choice) and rename the ending to .py and work from there. Most modern editors will also highlight the syntax based on file endings.
Related
I would like to have my program's associated file types open up directly into my Text Editor created using python's as well as incorporate a drag-and-drop functionality into the core of my program. How would i do this?
Also when trying to open up the associated file type directly using the file.ext link it just opens up a blank screen of my application window. How do i fix this?
I am using Python 2.7.12 for programming and PyInstaller for converting to exe
The files are already associated to my Text Editor via Inno Setup Compiler however I would like them to actually open up properly within the Text Editor itself.
Your program needs to accept parameters, the parameter in this case is going to be the file that will open with the editor that you created.
Drag and drop depends on the GUI framework that you are using. Google the framework that you are using and add "Drag and drop". There is definitely a documentation on how to implement it in the desired framework.
File association usually is done via installers such as the NSIS installer NSIS installer file association
Ok, so I'm looking to switch to PyCharm from PyScripter for OS independent development. I also wanted to mention that I'm using Perforce for version control.
So what I currently do is double click a .py for editing in Perforce, and PyScripter opens up and I edit to my hearts desire. I can click on an imported function, and it'll open up the corresponding .py file and bring me right to the function. Awesome.
So I have yet to be able to achieve that on PyCharm. I'm using the community version which should be just fine for what I want, which is just an editor with some python checking & built in console.
When I set the default .py program to use in Perforce to PyCharm, I click on the .py and PyCharm fires up. Good so far. But my problem arises when I try to "ctrl + click" a function or method. I get the "Cannot find declaration to go to." I import the associated class & file.
(Just an example, not actual code). So in Transportation.py I have "import Cars", which is a .py. I do Cars.NumberOfDoors() and I get the above error. My folder structure is:
Scripts (folder)
Population.py (General support script)
Citybudget.py (General support script)
MassTransit (folder)
Transportation.py
Cars.py
So question boils down to, is how do I properly setup the root to be the Scripts folder when I click on a file from Perforce? How do I set it up that it recognizes where it's at in the folder structure? So if I'm in the MassTransit it'll set the root as Scripts folder, and same for if I'm accessing the general support scripts like Population.py?
Go to
File --> Open
in Pycharm and select your Scripts(folder) and open it. Then the Pycharm will treat it as a project and you will be able to ctrl + click a function.
I am following a very simple tutorial for google app engine and at a point, after having installed Google sdk for python, it is asked to deploy the hello world app using the command from windows CMD:
>dev_appserver.py helloworld
My problem is: when I type this command, my Pycharm automatically pop up and open a tmp folder containing dev_appserver.py, as if I wanted to edit the file. I think that, when pycharm is installed, it forces a redirection of every command of the form >test.py to open the corresponding file in pycharm instead of executing the command.
What can I do to get rid of this?
Fixing the file association problem means removing the .py file association (likely created at pycharm's installation), which depends on your Windows version.
This official suggestion can be applied to several Windows versions.
For alternate solution search for "file association remove delete" and your Windows version, plenty of advice out there.
Note: after removing the association you'll need to manually select the application to use when you actually want to edit a .py file (which is not a big deal for one which typically opens the files from pycharm project windows).
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.
Hi as a python newbie I have written a small python application that can convert an excel worksheet into a sqlite database table. Its not a terribly complex application but it does make use of external modules/package like xlrd (http://pypi.python.org/pypi/xlrd) which I had to download and install when writing my app.
Now that is all done I would like to distribute it amongst my friends, all windows users, while they have python on their machines, they may or may not have the xlrd modules.
I would like to package my app, make sure it includes everything that it needs to run, and share the final .zip file with my friends so they can use the application. Is there a good tutorial that covers how to package a python application, with all the necessary external modules/packages, so that another windows user, can easily run my application.
I keep hearing about disutils, can anyone point me to some good tutorials, or any other python packaging tutorials that show how to get everything into a simple easy to distribute file.
Many thanks
Note: I also want to include the sqlite database file with my application, so the end user doesn't have to worry about anything
First download Pyinstaller and save it somewhere. Then, if you're running Python 2.6 or 2.7 go and install pywin32.
Go create a directory for your output file.
Open Command prompt and enter the fallowing:
python path/to/pyinstaller/pyinstall.py file/to/be/converted.py --onefile
If you want to add an icon, add the --icon argument.
If you want it to hide the CMD window add the --windowed argument.
So if you wanted it to use an icon and hide the CMD window it would look like this:
python path/to/pyinstaller/pyinstall.py file/to/be/converted.py --onefile --icon="path/to/icon.ico" --windowed
The --onefile argument makes the saves everything into one file, without it, the output would be would be a lot of files.
The output is saved in the "dist" folder in the directory it was using.
After you convert the python script in to an .exe, put it in a .zip file along with any other files you need (in your case the squite database file) and you can give it to anyone without them needing to have Python at all.
If you want a program to do this all for you, you can download a program called PTEC.