Running Python Scripts Outside of IDLE - python

1- i want someone to help with this part
https://automatetheboringstuff.com/appendixb/
about Running Python Scripts Outside of IDLE and sending command line args .
2- i converted my code to .exe by pyinstaller ; what's the difference between this and running it
as a script .
3-how scripts are done . i see experienced people says :"i made a script to do something for me " how is that done >?
*i'm a beginner so try to make answers simple as possible.

If you're wondering about command line arguments, look into the "argparse" library https://docs.python.org/3/library/argparse.html.
The difference in the .exe and the normal script is that that the .exe versions (conventionally) are able to be redistributed to other sytems that don't have python installed whilst still being able to run the script. If you're only making the script for yourself the only real benefit is that you dont have to enter your IDE (code editor) every time you want to run the code, however if it's still in development then you'd have to compile the code every time you made a modification if you're wanting to run the code as an executable, which is very impractical.
Your third part is very, very vague. Python can be very versatile and i recommend you continue looking at the automatetheboringstuff.com website if you're interested in making scripts that can complete repetitive activities (although i must strongly advise you against using scripts maliciously).

Related

Python Input function in atom prevents code from running [duplicate]

I created a script which just asks a user for their name and age using Python's input() function.
I installed the package Script. This ran the script well but couldn’t deal with the input.
I have also tried a number of other options but haven’t had any success.
Any ideas how to build and execute scripts from within Atom? I don’t mind if it just simply saved the script and opened Pythons IDLE at a minimum.
Add Terminal-Plus and run the code with the python name_file.py command
Script Runner can run scripts and supports input, unlike Script. It's the simplest full terminal package that I know of. To run a script, press Alt+X
For more advanced usage, you might look at Hydrogen.
The atom-python-run package gets around the input("") freeze problem by opening a terminal window and running the code in that.
Doing it within Atom has eluded me too, but this works OK.

running a python script when i turn my pc on

I created a python script to control the RGB of my keyboard and my mouse and i want it to start when i turn my computer on. I have 2 solutions but i don't know which is the best.
the first solution is to build my script and run the executable on startup
the second solution is to run directly the python script with python.
the first solution is a little bit annoying because is i want to change the code, i need to rebuild my script. and also when i tried to run the exe (created with pyinstaller), it didn't work (because of the dlls i think)
the second solution is better if i want to change the code later, but i don't know how it would react if i run another python script (i don't even know if it's possible to run 2 python instances at the same time.)
so if you have any idea on which solution to choose, how to build a script using dlls with pyinstaller or if i can run multiple python instances (maybe i can run multiple venvs), feel free th help me.
PS: I tried to be clear but as i didn't speak english very well i don't know if you understood my issue.
Using windows : https://www.geeksforgeeks.org/autorun-a-python-script-on-windows-startup/
Using Linux : follow this https://stackoverflow.com/questions/24518522/run-python-script-at-startup-in-ubuntu#:~:text=Put%20the%20command%20python%20startuptest,and%20put%20the%20command%20there

Python Shell memory management for always running script

I have written a python (python version is 3) script that runs 24/7. The way I run my script in my Windows machine is the following. I right click on the .py file, then click on "Edit with IDLE" and then "Run". The script has no issue but, due to the many instructions printed in the python shell (I use a logger), after a couple of days this python shell gets very heavy. My newbie question is the following. Is there to limit the number of rows temporarily saved in the python shell to a specific number? Or perhaps somebody has a better suggestion to run this constantly running script that prints a lot of the script steps in the shell? Please, notice how I'm not asking how to run a script 24/7, it's my understanding the best way to do it is though a VPS. My problem is that the data saved in the displayed python shell gets bigger and bigger every day, so I only wonder how to limit the data temporarily displayed/saved in it. Thanks

Issue with Python Batch file to run Python through Notepad++

EDIT: The code I wrote in my Python file was just this:
print "foo"
I'm using Windows XP Home Premium on this tiny little HP Mini 1000, and I want to run Python files, since we're learning it in school. I am aware of this topic, so I tried to run Python files using a batch file (python.bat), and I'm getting an error that says, "Can't find 'main' module in ''" whenever I run the batch file. I followed the instructions given here. All I did was change "Python26" to "Python33" because of the difference in versions.
Any idea what's wrong here? I really want to run Python files from Notepad++, so I don't want any alternative ways to run them.
This sounds like you don't have PYTHONPATH set up correctly. I suggest you review the documentation here:
http://docs.python.org/2/using/windows.html
Instead of calling Python, call cmd.exe and then use the set command to inspect which variables are set and how they are set. Run the exit command to leave the command shell. When you think you have the variables set up correctly, try again to run Python.
Good luck and have fun!
I use the command line interpreter or IDLE mostly (Win 8.1 now, but I've done so since Win XP SP2), but NPP is my main text editor, so I was curious about this issue.
When I was reproducing this, I was able to generate several errors, but the only one I got that was an exact match was when I failed to configure the Run option correctly.
You need to make sure to follow this step exactly in the instructions you were following. When you navigate to Run -> Run in Notepad++, you have to enter this exactly:
C:\Python33\python.bat "$(FULL_CURRENT_PATH)"
I am pretty sure you left out the "$(FULL_CURRENT_PATH)", or otherwise didn't add it correctly, as failing to do so causes exactly the same error on my end. Failing to include this means that when you run the batch script, you get the wrong input to the Python interpreter, causing the error.

Run a Python script from PackageMaker in OSX

I'm having a difficult time finding any decent documentation for packaging on OSX. My package needs to run a Python script that will do some launchd magic right after the app is installed. I tried using -s scripts with packagemaker and put my script in the directory scripts, but I had no luck. Is there something I'm missing? More importantly, where is all the packagemaker documentation? How can I get my Python script to run? The only thing I've seen is this, which is way outdated and doesn't cover the command line version.
I don't want to use the GUI; it makes my life too difficult.
I've resolved this issue.
The script needs to be named postflight and have a proper shebang line.
The script needs to exit with specific status codes (0 for success, which is the default, I believe).

Categories