1

I'd like to get a little insight for this issue I'm running into. I'm a rookie when it comes to python, and I'm not even sure how to properly identify my issue so I can research better answers.

I'm using windows 10, and running python 3.8 (same issues arose with 3.7, before I did a clean install)

I've written an API call in Jupyter and after a week of struggling, I finally got it to execute and save the data into a nice csv into a folder on my hard drive. I saved the code as a .py. My next step was to automate this API call by using Windows Task Scheduler for everyday 2pm to run the .py script from the command line.

I noticed it wasnt running, and tried to run it manually, but all that happens is a command prompt opens and closes faster than I can see whats going on. There is no output in the destination folder.

I wanted to make sure python was correctly installed, and set to PATH, and after double checking everything I got a successful 'Hello World' printed from the command line just fine. But when I try to run the .py script all it does is return the name of the script I am trying to run, with no error or kickback message. I'm not sure where things are going wrong.

To further complicate things, I am unable to get this code to run in Visual Studio.

To further further complicate things, I was worried these issues arose because I didn't have the necessary modules installed (such as pandas, or json). Attempts a pip install returned synatx errors.

TylerH
  • 20,799
  • 66
  • 75
  • 101
Moondoggy
  • 11
  • 2
  • Please open the command prompt by pressing `Super+R` and typing `cmd` and enter your command there. This way the window doesn't `close faster than you can see what's going on`. – csabinho Nov 07 '19 at 00:50
  • Forgive my ignorance here. What is Super? Also, the only time the command prompt opens and closes is when i directly double click on the .py file i want to run. – Moondoggy Nov 07 '19 at 00:54
  • Oh, super is just the Windows key. Yes, this is how I've been running the script. – Moondoggy Nov 07 '19 at 01:12
  • So a second command prompt opened? That sounds weird. – csabinho Nov 07 '19 at 15:13

1 Answers1

2

Dealing with the same damn thing right now.

from datetime import datetime, date
print("Your date of birth (dd mm yyyy)")
dateOfBirth = datetime.strptime(input("Enter your date of birth: "), "%d %m %Y")

def calculateAge(born):
    today = date.today()
    return today.year - born.year - ((today.month, today.day) < (born.month, born.day))

age = str(calculateAge(dateOfBirth))
print("You're " + age + " years old")

Let me know if you ever come across any solution. Note my code runs perfectly fine in jupyter notebook but not in the command line.

Ahmed Q.
  • 57
  • 8