Python Importing Modules

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • aruni
    New Member
    • Sep 2007
    • 4

    Python Importing Modules

    Hi
    I am aruni.I have just started to use the python.I tried to import os in my program.but it is giving me an error as "no Module named OS".I thought it as similar to sys.Can anyone tell me an sugesstion.How to use the os in my python program.
  • bvdet
    Recognized Expert Specialist
    • Oct 2006
    • 2851

    #2
    Originally posted by aruni
    Hi
    I am aruni.I have just started to use the python.I tried to import os in my program.but it is giving me an error as "no Module named OS".I thought it as similar to sys.Can anyone tell me an sugesstion.How to use the os in my python program.
    Python is case-sensitive:[code=Python]>>> import OS
    Traceback (most recent call last):
    File "<interacti ve input>", line 1, in ?
    ImportError: No module named OS
    >>> import os
    >>> os.getcwd()
    'C:\\SDS2_7.0\\ macro\\macrolib '
    >>> [/code]

    Comment

    • aruni
      New Member
      • Sep 2007
      • 4

      #3
      Originally posted by bvdet
      Python is case-sensitive:[code=Python]>>> import OS
      Traceback (most recent call last):
      File "<interacti ve input>", line 1, in ?
      ImportError: No module named OS
      >>> import os
      >>> os.getcwd()
      'C:\\SDS2_7.0\\ macro\\macrolib '
      >>> [/code]
      Hi..
      Again i am getting error.
      what i have to do to avoid this.

      Comment

      • bartonc
        Recognized Expert Expert
        • Sep 2006
        • 6478

        #4
        Originally posted by aruni
        Hi..
        Again i am getting error.
        what i have to do to avoid this.
        small "os". Not Capital "OS".

        Comment

        • aruni
          New Member
          • Sep 2007
          • 4

          #5
          Originally posted by bartonc
          small "os". Not Capital "OS".

          Hi
          For both the os and OS i getting error.when i opened my python exe my first statement is " 'import site' failed; use _v for traceback"

          Comment

          • malashree
            New Member
            • Nov 2018
            • 1

            #6
            Hi aruni,

            Is the issue resolved now?? Im also having same issue

            'import site' failed; use -v for traceback
            Traceback (most recent call last):
            File "path of file", line 51, in ?
            import os, os.path, subprocess, pwd, re, socket, string, sys, syslog, time, traceback,rando m
            ImportError: No module named os

            Comment

            • rodnaz
              New Member
              • Nov 2018
              • 3

              #7
              Hi, This has been seen if you run python 2.x when you were intending to run python v3.x eg "python myfile.py" instead of "python3 myfile.py" Cheers Nigel see https://stackoverflow.com/questions/...-for-traceback
              Last edited by rodnaz; Nov 13 '18, 09:35 AM. Reason: typo fix

              Comment

              Working...