Python Forum
could you please help how to run this file on command prompt
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
could you please help how to run this file on command prompt
#1
code is as shown below, saved as ynb.py

def get_cube_root(num):
	return num ** (1. / 3)
i tried to run in command prompt

Error:
C:\Users\s\Documents>python -c get_cube_root(27) ImportError: No module named site C:\Users\s\Documents>python -c 'from footbar import *; print get_cube_root(27) ImportError: No module named site C:\Users\s\Documents>python ynb.py ImportError: No module named site C:\Users\s\Documents>ynb.py C:\Users\s\Documents>python ynb.py ImportError: No module named site C:\Users\s\Documents>print ynb.by Unable to initialize device PRN
any suggestion
Reply
#2
run
pyton ynb.py
on command line from directory where file resides
Reply
#3
apart from all these errors that don't make sense with the code you show (e.g. ImportError: No module named site) your code will not produce any visible result - it just define a function which you don't call at all
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#4
yes that didnot produce any result. sorry maybe wrong question
Reply
#5
(Mar-24-2018, 04:41 PM)m123 Wrote: yes that didnot produce any result. sorry maybe wrong question
so what would be the right question then?
did it run without errors and no result too?
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#6
It looks to me, that your Python installation is broken.

Quote:Help on module site:

NAME
site - Append module search paths for third-party packages to sys.path.

The module site comes with Python.
Give us some details about your OS.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply
#7
64 bit ,Windows , intel core TM ,i7-6500UCPU 2.5GHz , 8GB RAM

i also installed sypder python(3.6)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to Randomly Print a Quote From a Text File When User Types a Command on Main Menu BillKochman 13 775 4 hours ago
Last Post: Bronjer
  What is the difference between Command Prompt and Sublimes yaoyao22 1 640 Jul-09-2023, 02:56 PM
Last Post: snippsat
  Facing Problem while opening a file through command prompt vlearner 4 1,909 Jan-30-2022, 08:10 AM
Last Post: snippsat
  Dynamic File Name to a shared folder with open command in python sjcsvatt 9 6,050 Jan-07-2022, 04:55 PM
Last Post: bowlofred
  Noob warning: trying to use pip to install pytest and pep8 in Command Prompt adifrank 4 5,328 Dec-20-2020, 04:23 AM
Last Post: adifrank
  Running Python in Command Prompt Anwar 3 3,084 Nov-15-2020, 03:15 PM
Last Post: snippsat
  starting python from windows command prompt MaartenRo 4 2,821 Sep-04-2020, 12:25 PM
Last Post: MaartenRo
  Will not print in command prompt PandaCode 12 13,116 May-06-2020, 03:48 AM
Last Post: PandaCode
  Script works when executed from command prompt but not when executed in SDP Tippex 0 2,009 Apr-07-2020, 04:26 PM
Last Post: Tippex
  can we write command output to new csv file using Panda package? PythonBeginner_2020 3 2,384 Mar-13-2020, 12:38 PM
Last Post: ndc85430

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020