Python Forum
New to Python - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: New to Python (/thread-20548.html)



New to Python - ourek - Aug-17-2019

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?


RE: New to Python - buran - Aug-17-2019

Please read
https://python-forum.io/Thread-How-to-Execute-python-code
https://python-forum.io/Thread-VS-Code-from-start