Task Scheduler for running python script done in PyCharm - Anaconda environment - python-3.x

I have created several scripts in PyCharm, inside an Anaconda3 environment. The thing is that I would like to run them with the task scheduler during the night, so hopefully by the time I get up they have done their stuff.
I have read a million post in Microsoft support and in here, and I haven't found an answer for this issue.
This is a print of the set-up for the Task Scheduler:
For the program, I use the path to python.exe inside anaconda ( I take this path from cmd / where python).
Start in: the route to the script: C:\Users\oper\PycharmProjects\MyProject
It doesn't run, and it brings the error: 0x1. Opens a CommandPrompt windows and immediately closes it. I see the error in: Last Run Result.
I have been able to run a much simpler code that prints a .txt in a specified folder - but not this one.
Additional info:
this script runs a Selenium WebDriver and navigates some websites, connects with Google's OCR, etc. All these steps are written in several other modules for ease of coding.
All the libraries used were installed using pip inside PyCharm's terminal. Might be related to not having the libraries in sync? Don't know how to check that.
I would also like to set up a wake-up from sleep for the computer. Probably a different problem for another question.
Thanks in advance.

Related

I am facing issues printing things on repl.it

I am new to repl.it and I was trying to print the python version using this code Print Version of the Python Running on the Machine
Here's the code:
import sys
print("Python version")
print (sys.version)
print("Version info.")
print (sys.version_info)
but it prints absolutely nothing. Trying to do the same thing onto Jupyter Notebook and my code works. While I know I can print the version directly from the shell tab out there but I was wondering what's wrong with my code and why it isn't working with repl.it
This seems to be the same for user input as well where I try to do
name = input("Print my name?\n")
but it prints absolutely nothing onto the console. I am sure someone here must know what am I missing here. Sorry if this is a noob question.
"Help! 🙋 My REPL won't run"
Here are six reasons your Python REPL.it environment may not be working. 📃
Checklist to fix common problems
Have you configured your Run ▶️?
Repl.it doesn't automatically run your current working document. Configuring your Run ▶️ button will enable replit to know what to do when you hit the button.
Configuring the "Run" Button
A file named .replit can be added to any repl in order to customize the behavior of the "Run" button. Written in toml, a .replit file looks something like:
run = "<run command here>"
language = "<repl language>" # optional
In the snippet above, run is a string which will be executed in the shell whenever you hit the "Run" button. The language helps the IDE understand how to provide features like packaging and code intelligence. This is normally configured for you when you clone from a Git repository.
The .replit file can also provide other configuration hints. The full specification is provided below:
run: Command that is executed when the run button is clicked
language: Reserved
onBoot: Command that is executed once when the repl first starts up
packager.afterInstall: Command that is executed after a new package is installed
packager.ignoredPaths: List of paths to ignore while attempting to guess packages (More about installing packages)
packager.ignoredPackages: List of modules to never attempt to guess a package for, when installing packages (More about installing packages)
Example .replit File
run="python main.py"
language="python3"
onBoot="echo Booting up!"
[packager]
afterInstall="date >> package_install_log"
ignoredPaths=[".git"]
ignoredPackages=["twitter", "discord"]
Attempt running the *.py script through the interactive shell instead of console. If the script runs in console, you may be needing to diagnose the shell. See choices below.
Check that the Browser Developer Console is not showing any errors If you see errors, you may be having issues with your browser or extensions. Try disabling browser extensions temporarily.
REPL.it relies on Google Cloud Platform services for its backend functionality and sometimes those servers are unresponsive. Check the REPL.it status page or the REPLIT Twitter account to see if they're having a GCP backend service outage. If they haven't updated recently, they may be responding to an unreported outage. Check Google's own GCP status page here. You can also Tweet at the CEO of Repl.it here.
Try refreshing the REPL.it environment locally. Clear the console output and scroll-back by using the ✖️ next to the search icon 🔍. Also, try exiting the Python REPL with exit() to see if it will respond.
If #5 doesn't work, try an empty-cache hard reload. This can help to expunge unresponsive javascript, broken html, misbehaving css, and any unmetabolized toxins from the bowels of your browser.

Python automation project to run in the background

i just started working with python and with some scripts to automate some tasks. I manage to create a web scraper using selenium that notifies me daily with the latest news via a mail . Now the script works great if i run it manually , but my question is : How can i make the script to run automatically every day , and what option would you recomand . I know that you can use TaskScheduler and program it , but i was wondering if you know any options to run it directly in the cloud ? Also , i found some tutorials where they say to wrap all the code in an infinite loop and add a timer , and once you run the script it will stay active as a background process,
I just started working with scripts and automation , so i would really like to know your opinion on the best way to run the script automatically . Thanks a lot
If this is on a unix-based OS, check out cron (this is a pretty good guide). You can schedule it to run your python script daily.
Im not sure if that is what you are looking for, but (if you are on windows) you could attach your program to your autostart. Probably your Startup Folder: C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup
If you schedule in your computer, i think it may not be proper solution. It's better to deploy it on any cloud platforms & schedule at any particular time.
I personally suggest Heroku, I'm using it for running multiple scripts for free. You can use scheduler addon for scheduling scripts to run at particular time as well. Please refer to heroku documentation & get started! Note: The script may run more time than you expected, please refer here to fix this.

nltk.download() wont open a GUI to chose the list of downloads. It dont download data and the cursor blinks forever

I am trying to install nltk and download the nltk data. I am trying this on python 3.7.3 and my pip is up to date. my PC is windows 10 and given by the company.
My Installation of nltk is succesfull but it wont downlaod the data. It dont give me GUI to chose downloads nor finishes the download. The cursor keeps blinking forever.
I have tried this running it as a an admin, ran it through Jupyter Notebook. Never saw the GUI at all/
Who knows what's going on? Maybe the download window is hidden behind other windows; I've seen that a lot. Or maybe it really doesn't come up. Either way, if you can't find the window you can largely work around the problem by using the non-GUI form of the downloader:
nltk.download("book") will download all the resources you'll need while reading the book. I recommend you just run this one and move on to exploring the nltk.
nltk.download("all") will download everything in the download store. Probably overkill.
nltk.downlead(<name>) will download resource <name> (e.g., 'average_perceptron_tagger' for the tagger data, etc.) If you try to use a module and it's missing a resource, it will usually tell you what you need to download.
There are some other collective names including all-corpora, popular, and third-party, but the most useful ones are the above, I believe.
This has been resolved. I had to bypass web connection proxy server at my work. Instead, they added permissions for the http://files.pythonhosted.org and this worked fine.

Package Python 3 executable that does not require programming knowledge

I would like to send my Python3 script to my father-in-law and grandmother. Each has their own Windows machine, one is running Windows 7 and the other is running XP.
Not sure how to package it up for them to run on their respective machines. Is there such a method?
My script prompts, while in the IDE environment, for Keyword, path, filename. So there are some inputs, the user has to type in. Not sure if that will affect the portable script creation.
After reading through some responses here on StackOverFlow, I found py2exe does not work with Python 3.
Also Pytonw, suggested here as well, looks very complicated. I don't think either of my relative could carry out those steps.
Lastly CX-Freeze site I get ublock filters-Badware risks and a big warning window when I visit their website.
I've used cx-freeze to deploy python apps compiled to windows .exe files for us by computer novice users for several years and it has worked well. you will occasionally run into issues with dependencies you will have to take extra steps for (Datetime for example) but nothing that isn't surmountable. The easiest way to handle it is to install the folder on the computer yourself and create a desktop shortcut to it for the user. That keeps it simple for them. If you are not close to them you can always use a program like team viewer to gain access to their computer like remote desktop.

AutoHotkey Run command issue in Windows 8.1

this is my first time on such a prestidigious site, so please welcome me by assisting me. I am doing independent development and am primarily a music designer. So that is why I may not sound like a real pro coder but nevertheless truly love creating my music through automative processes.
My present issue is this:
Windows 8.1 Pro
AutoHotkey 1.0.48.5 32bit (running as Admin)
Everytime I attempt to use the command 'RUN' with an .ahk target, I get the expected result except that the .ahk residing folder is opened by MS Explorer. I suspect that something like the fact that AutoHokey is an unsigned app, windows does not want it to run flawlessly. I am now trying a number of Administrative Tool Services disabling, but with no success yet.
RUN C\:XZN\Mecanisms\AnyAHK_script.ahk
;;or
RUN AnyAHK_script.ahk, C\:XZN\Mecanisms
;;or
RUN C\:XZN\Mecanisms\BactchfileLaunchingAboveScript.bat
;;or
RUN AnyAHK_script.ahk, C\:XZN\Mecanisms
Would there be a workaround this at the OS settings level or another way to run/start an .ahk file?
I tried the 'Comspec' approach as well as running an .ahk from within a batchfile, but the .ahk always get intercepted whenever it contains a 'RUN' command requesting an .ahk target.
Thanks.
You are using outdated version of AutoHotkey which is more than 5 years old. Always use AutoHotkey and its documenatation from http://ahkscript.org/ (current uptodate version, new official website)! AutoHotkey and its documentation from autohotkey.com is outdated and you may have some problems using them!
One thing to try if you only have this problem on win 8 is to Enable interaction with administrative programs http://www.autohotkey.com/board/topic/70449-enable-interaction-with-administrative-programs/
That script modifies the executable file's embedded manifest, then creates and installs a self-signed certificate and uses it to sign the file. The executable will not run on any other system, unless you install the certificate used to sign the file.
But lets see some script code that way we have something to test with and can better help you out...

Resources