[{"element_type":"text","content":"\n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n        \u003cp\u003eThis article is for Circuit Python developers that use PIP and CircuitPython-Stubs in a Windows environment.\u0026nbsp;\u003c/p\u003e\n\u003cp\u003eStubs are helpers for code completion hints with IDE's such as PyCharm, VSCode, and others.\u003c/p\u003e\n\u003cp\u003eUnfortunately PIP \u0026amp; CircuitPython-Stubs do not automatically stay updated.\u0026nbsp; These are things you must manually update when a new version of Circuit Python is released or whenever your heart dictates you want to update it.\u0026nbsp; This is a problem because I never remember to keep them updated and recently found out my version of stubs was last updated in Circuit Python 7.3.3 (we're now at Circuit Python 9.0.1).\u0026nbsp;\u003c/p\u003e\n      \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n","metadata":{}},{"element_type":"user_image","content":"https://cdn-learn.adafruit.com/user_assets/assets/000/000/765/original/Manually_Updating_Stubs.JPG?1711689775","metadata":{"caption":"Updating circuitpython-stubs manually for Windows"}},{"element_type":"text","content":"\n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n        \u003cp\u003eThis is assuming you already have PIP and CircuitPython stubs installed.\u003c/p\u003e\n\u003cp\u003eThe manual way to update them is:\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003epython -m pip install --upgrade pip\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003epip install circuitpython-stubs --upgrade\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eThese are the types of things I do not want to be required to remember to update.\u0026nbsp; I consider these things minutia that should automatically stay updated.\u003c/p\u003e\n\u003cp\u003eWindows Task Scheduler can automate the process of keeping both PIP and circuitpython-stubs up to date every time you log into Windows.\u0026nbsp; First we need to create a batch script and put it in a directory/folder that will always be available to Windows.\u0026nbsp;\u003c/p\u003e\n\u003cp\u003eI chose to put it in the following folder:\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003e\\Downloads\\CircuitPython-Stubs_Updater\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eYou can name the script whatever you'd like.\u0026nbsp; You can edit a .bat file as easly as a .txt file, you don't need a special IDE to do it, Notepad works fine for it.\u003c/p\u003e\n\u003cp\u003eI named my batch file:\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003ecircuitpython-stubs.bat\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eIt resides inside of the CircuitPython-Stubs_Updater folder and includes the following code in the .bat file.\u003c/p\u003e\n      \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n","metadata":{}},{"element_type":"code","content":"@echo off\nset mydate=%date:~10,4%-%date:~4,2%-%date:~7,2%\n\necho --------------------------------------\necho Date: %mydate%\necho Windows PIP and Circuit Python Stubs Updater\necho Use this batch file with Windows Task Manager for automation.\necho This window will automatically close when done\necho --------------------------------------\necho.\necho.\necho Upgrading PIP...\ntimeout /T 5 \nstart \"\" python -m pip install --upgrade pip\necho.\necho.\necho Updating Circuit Python Stubs...\ntimeout /T 5 \nstart \"\" py -m pip install --upgrade circuitpython-stubs\necho.\necho.\necho Finished Updating\necho This window will automatically close in 10 seconds.\ntimeout /T 10 \necho.\nexit","metadata":{"language":"terminal","linenums":false}},{"element_type":"text","content":"\n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n        \u003cp\u003eNext you must go into Task Scheduler and create a task that will automatically launch the batch file on a regular schedule.\u0026nbsp; There are many options in how/when to choose to launch the task. On the right side of Task Scheduler click on Create Task.\u003c/p\u003e\n      \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n","metadata":{}},{"element_type":"user_image","content":"https://cdn-learn.adafruit.com/user_assets/assets/000/000/767/original/Creating_Task.JPG?1711691317","metadata":{"caption":"Windows Task Scheduler"}},{"element_type":"text","content":"\n  \n  \n  \n  \n  \n        \u003cp\u003eGive your task a name and description.\u0026nbsp; You can choose to specify the version of Windows but leaving at default configuration for your OS is fine for this purpose. Other configurations are available if you want to run something in compatibility mode.\u003c/p\u003e\n      \n\n\n\n\n","metadata":{}},{"element_type":"user_image","content":"https://cdn-learn.adafruit.com/user_assets/assets/000/000/775/original/Task_Scheduler_General.JPG?1711696290","metadata":{"caption":"Creating a New Task with Windows Task Scheduler"}},{"element_type":"text","content":"\n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n        \u003cp\u003eIn the Triggers tab you can customize it to run at a specific time, day of the week, a specific user, etc..\u0026nbsp; You can setup multiple triggers too. The most general purpose Trigger is to run the script \u003ccode\u003eAt log on\u003c/code\u003e\u003c/p\u003e\n      \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n","metadata":{}},{"element_type":"user_image","content":"https://cdn-learn.adafruit.com/user_assets/assets/000/000/776/original/Task_Scheduler_Triggers.JPG?1711782407","metadata":{"caption":"Setup Task Triggers"}},{"element_type":"text","content":"\n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n        \u003cp\u003eNext we'll setup Actions.\u0026nbsp; This is where you'll specify the file you want executed for the task.\u003c/p\u003e\n\u003cp\u003eWindows will automatically replace %USERNAME% here with the current logged in user. You want to paste this literally into the path and don't replace %USERNAME% with your actual username.. unless you want to. This is much easier to copy and paste as it will apply to any Windows user logged in.\u003c/p\u003e\n\u003cp\u003eFill in the Program/script: field with the filename\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003ecircuitpython-stubs.bat\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eFill in Start in (optional): field with the path to the file.\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003eC:\\Users\\%USERNAME%\\Downloads\\CircuitPython-Stubs_Updater\\\u003c/code\u003e\u003c/p\u003e\n      \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n","metadata":{}},{"element_type":"user_image","content":"https://cdn-learn.adafruit.com/user_assets/assets/000/000/771/original/Task_Scheduler_Actions.JPG?1711692474","metadata":{"caption":""}},{"element_type":"text","content":"\n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n        \u003cp\u003eThe tabs for Conditions | Settings | History can all be left at defaults.\u0026nbsp; There isn't any necessary configuration to do in those tabs for something like this.\u0026nbsp; Click OK and your task should be all setup and ready to go!\u003c/p\u003e\n\u003cp\u003eYou can test your task by right-clicking on it in task manager and choosing Run.\u003c/p\u003e\n      \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n","metadata":{}},{"element_type":"user_image","content":"https://cdn-learn.adafruit.com/user_assets/assets/000/000/772/original/Manual_Run.JPG?1711693111","metadata":{"caption":"Manually running a task now"}},{"element_type":"text","content":"\n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n        \u003cp\u003eWhen the task runs it will pop up a command prompt and show the batch script running. \u003c/p\u003e\n      \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n","metadata":{}},{"element_type":"user_image","content":"https://cdn-learn.adafruit.com/user_assets/assets/000/000/766/original/Task_Run.JPG?1711690407","metadata":{"caption":"Scheduled Task Run (visible mode)"}},{"element_type":"text","content":"\n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n        \u003cp\u003eA common question for scheduled tasks is \"How can I prevent the command prompt from popping up every single time?\u003c/p\u003e\n\u003cp\u003eYou can suppress/hide the command prompt by choosing the logged in Windows user you want it to run as and enter your login credentials.\u0026nbsp;\u003c/p\u003e\n      \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n","metadata":{}},{"element_type":"user_image","content":"https://cdn-learn.adafruit.com/user_assets/assets/000/000/774/original/Credentials.JPG?1711695684","metadata":{"caption":"Running with Credentials for Background Tasking"}},{"element_type":"text","content":"\n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n        \u003cp\u003eSimply check the \"Hidden\" checkbox and it will run invisibly as a Windows background task staying updated forever without ever having to worry about remembering to manually update these things again.\u003c/p\u003e\n\u003cp\u003ePIP and CircuitPython-Stubs will now automatically update every time you log into Windows.\u003c/p\u003e\n      \n\n\n\n\n\n\n\n\n\n\n\n\n\n","metadata":{}}]