Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 New to Python
#1
Hello,

I'm new to Python (trying to learn it) and I have Win10 with VSC and with Python extension installed but when I try to run python file

import math
import requests

def calc_dist(lat1, lon1, lat2, lon2):
    lat1 = math.radians(lat1)
    lon1 = math.radians(lon1)
    lat2 = math.radians(lat2)
    lon2 = math.radians(lon2)

    h = math.sin( (lat2 - lat1) / 2 ) ** 2 + \
      math.cos(lat1) * \
      math.cos(lat2) * \
      math.sin( (lon2 - lon1) / 2 ) ** 2

    return 6372.8 * 2 * math.asin(math.sqrt(h))
Error:
PS C:\Python37> import requests import : The term 'import' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + import requests + ~~~~~~ + CategoryInfo : ObjectNotFound: (import:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
Can someone help with this?
ichabod801 wrote Aug-17-2019, 08:05 PM:
Please use python and output tags when posting code and results. I put them in for you this time. Here are instructions for doing it yourself next time.
Quote
#2
Please read
https://python-forum.io/Thread-How-to-Ex...ython-code
https://python-forum.io/Thread-VS-Code-from-start
Quote

Top Page

Forum Jump:


Users browsing this thread: 1 Guest(s)