So I just created a simple script with selenium that automates the login for my University's portal. The first reaction I got from a friend was: ah nice, you can put that on my pc as well. That would be rather hard as he'd have to install python and run it through an IDE or through his terminal or something like that and the user friendliness wouldn't be optimal.
Is there a way that I could like wrap it in a nicer user interface, maybe create an app or something so that I could just share that program? All they'd have to do is then fill in their login details once and the program then logs them in every time they want. I have no clue what the possibilities for that are, therefore I'm asking this question.
And more in general, how do I get to use my python code outside of my IDE? Thusfar, I've created some small projects and ran them in PyCharm and that's it. Once again, I have no clue what the possibilities are so I also don't really know what I'm asking. If anyone gets what I mean by using my code further than only in my IDE, I'd love to hear your suggestions!
The IDE running you program is the same as you running your program in the console. But if you dont want them to have python installed (and they have windows) you can maybe convert them to exe with py2exe. But if they have linux, they probably have python installed and can run you program with "python script.py". But tell your friends to install python, if they program or not, it will always come in handy
Related
I have only just begun to learn to code in Python. I have a bit of experience in HTML, but that's about it.
I am current taking the Intro to Programming nanodegree from Udacity.
The lessons I am working on is introducing students to using interactive mode via command line to test bits of code. The problem is that I have to use the python -i command to get into interactive mode, and I am unable to scroll through the history. The bigger problem, however, is that running things like the turtle module are spotty.
Following the instructions in the lesson, I am trying to run the following code:
import turtle
amy = turtle.Turtle()
amy.forward(100)
amy.left(90)
amy.forward(100)
etc...
What ends up happening is I am able to import the turtle, assign it the name "amy", but then when I try to give it movement commands, nothing happens. the >>> disappears and Git Bash stops responding. I have to close the terminal and start a new terminal everything.
Also, being unable to use the arrow keys to cycle through command history is frustrating and retyping the code over and over again any time a mistake is time consuming.
Are there any better ways to go about using the CLI to fulfill the requirements of the course? (I didn't say which requirements, because I'm not entirely sure to what extent the course will require me to utilize the CLI on upcoming projects.)
This problem has frustrated me so much and I am not able to get any useful information from the "mentors" on the Udacity forums, so I have basically stopped progressing through the course.
Any help is much appreciated.
One possible alternative would be to use, instead of a git bash shell, a true Linux session through WSL2 if you are using a recent enough Windows version.
That way, you would benefit from a regular shell, in which history would be available through arrow keys to cycle through.
I'm doing the same course and had the same problem. Found a solution at https://granatguitar.com/why-can't-i-run-python-in-git-bash-on-windows/
I tested it first from the $ prompt and it seemed to work OK, so then I set it up in .bash_profile.
I didn't have a .bash_profile file so I created one in ~ and edited it as granat suggested.
I added the line alias pythoni="winpty python" and saved the file. (I used pythoni rather than python because, well, it's python interactive.)
Now, when I enter pythoni at the $ prompt it starts python in interactive mode....and it works! All the problems with hanging and not moving the turtles have gone.
I'm trying to run a python program in the online IDE SourceLair. I've written a line of code that simply prints hello, but I am embarrassed to say I can't figure out how to RUN the program.
I have the console, web server, and terminal available on the IDE already pulled up. I just don't know how to start the program. I've tried it on Mac OSX and Chrome OS, and neither work.
I don't know if anyone has experience with this IDE, but I can hope. Thanks!!
Can I ask you why you are using SourceLair?
Well I just figured it out in about 2 mins....its the same as using any other editor for python.
All you have to do is to run it in the terminal. python (nameoffile).py
Antonis from SourceLair here.
In SourceLair, you get a fully featured terminal, plus a web server for running your Python applications.
For simple files, as you correctly found out, all you have to do is save the file and run it through your terminal, using python <your-file.py>.
If you want to run a complete web server, you can check out our server configuration guide here: https://help.sourcelair.com/webserver/configure-your-web-server/
Happy hacking!
I created a new Python workspace in Cloud 9 IDE.
I was able to run the included hello-world.py without any issues, using the terminal.
As for a Run button as described by all documentation, and referred to as missing or bugged in exactly zero Google search results, there is nothing. I've scoured the entire interface and cannot find this magical Run button anywhere.
I created a node.js workspace and the Run button was there, working perfectly.
Even hello-world.py says "# click the 'Run' button at the top to start this application"
Is this something that only appears if you pay?
You have to run most of everything through the terminal by either putting
#!/usr/bin/python at the top of your code or by calling $> python programName.py in the terminal.
I found this a little strange so I went and experimented a bit myself.
As you said, a node.js project has a run button in the status bar as it's supposed to have, but a python project does not.
This made me wonder which other languages do or don't have this button. I tried a couple others (C, C++, Ruby) and none of these had a run button either.
I did come across this in the docs on Running and Debugging
Note: Currently, only Javascript/Node.js applications can make use of
the debugger. You can also execute Javascript/Node.js, Python, Ruby,
and Apache+PHP applications.
I read this before I even began to experiment, but after having created apps for other non Javascript/Node.js projects only to find they did not have a run button either, I think we can assume that by saying this
only Javascript/Node.js applications can make use of the debugger.
the C9 team also meant that currently only only Javascript/Node.js applications can make use of the run function. If so, this could and perhaps should have been stated more clearly though.
Also, a little futher below on that same documentation page it says
Run in debug mode indicates that you want to run the current code
through the debugger. Auto show & hide debug tools will reveal (or
collapse) the debugging tools panel described below. You can also work
with this presentation by going to View > Panels, and configuring the
debugger there.
So I figured I'd try what would happend if I clicked View>Panels, but that option isn't even available, not for JavaScript/Node.js projects either. I'm not sure what's up with that.
So I'm trying to setup the terminal in conjunction with Notepad++ and I'm a little confused. I've managed to download Python 2.7 and load it up in Powershell but I don't really know where to go from there. Do I even need to use a terminal? I know it says you can't use IDLE but it would be a lot easier. If anyone can guide me through getting the right setup to go on with the book I'd appreciate it a lot.
If you managed to get python running in the powershell following the Exercice 0, and you read the "Warning For Beginners" section, you can proceed to Exercice 1.
Why do they recommend that setup? Notepad++ is on Windows a powerful text editor very similar to other text editors, so you will soon get familiar with it. You will need to save your scripts in files and type a special line in the powershell to run and test them. That way you will get accustomed to running programs with arguments and if you make a failure, you can edit your code, save it and run it again.
In IDLE, you are already in a Python environment, so you cannot give arguments to your program inside it (actually you can but it's complex). You can also get an editor, save your file and run the script but also here it's a harder and less obvious way than Notepad++. When you get comfortable with the environment in that book you may change to get something that suits better your way of doing.
I apologize for such a basic question. I've done some research online and still cannot figure out for the life of me how to turn a python folder into something like an actual app I can open in OS X. I am using Mac OS X, Terminal and Coderunner for my Python project.
Here are a few options:
Platypus is not Python-specific. It lets you wrap a simple GUI around a command line tool.
py2app is Python-specific and a good choice if you have a GUI, or need to run in the background.
PyInstaller is similar to py2app but cross-platform; I've never used it, so I don't know how well it works.
The right choice depends on what your program does; who is the expected audience — do you need to redistribute it, if so how, and so forth. If you want to make the application entirely self-contained — not dependent on anything else beyond the OS — then things get more complicated (though certainly not insoluble; there are several commercial Mac desktop apps written in Python.)
Typically you would make the script executable by putting
#!/usr/bin/env python
as the first line, and then in a terminal window typing
chmod u+x myscript.py
You might also want to put it in a special scripts folder and then add that to your PATH by editing .bash_profile. (I am putting a lot of buzz-words here to help you find the tutorials explaining how these things work.)
You can wrap your script into an Automator object if you want to try running it that way, but in the long run you will be better off getting comfortable working in a terminal window.
It would also help to know what your app does: Process files, generate a GUI, do a calculation, etc...