Module faled on school computers [solved]

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bellum
    New Member
    • Sep 2006
    • 23

    Module faled on school computers [solved]

    I got my teacher to intall python on one of the computers, but python doesn't seem to want to compile modules. I used the same code I use at home, but I get

    ImportError: No module named password

    or something like that. Might this have something to do with some of the ungodly settings schools use to lock down computers? Or is there something else I'm missing?
  • bartonc
    Recognized Expert Expert
    • Sep 2006
    • 6478

    #2
    password doesn't seem to be a library module in windows.
    Maybe it's in you personal stuff in a folder in the sys.path?

    import sys
    print sys.path

    or it could be in Lib\site-packages folder.

    Comment

    • Bellum
      New Member
      • Sep 2006
      • 23

      #3
      Password is another part of the program I'm writing in the same folder, which is like 'Python Programs' or something on the desktop. From what I've seen so far, Python should automatically compile that and use it, right? That's what it does on my computer. D:

      Comment

      • bartonc
        Recognized Expert Expert
        • Sep 2006
        • 6478

        #4
        type
        import sys
        print sys.path

        if the folder you are working in isn't in there you can insert it like this:

        sys.path.insert (0, r"D:\My Documents\Pytho n\database")

        or you can set an environment variable (advanced windows topic) called
        PYTHONPATH which points to you folder

        or you can save a file with the .pth extension somewhere where Python look by default with a path name in it.

        Comment

        • Bellum
          New Member
          • Sep 2006
          • 23

          #5
          Hmm, thanks. I suppose I should be doing that all the time, if that's the proper way to go about it. D: I'll reserve all my thinking for tomorow. 'Tis late.

          But, yeah, thanks for the help. I think I should read that section again.

          Comment

          • bartonc
            Recognized Expert Expert
            • Sep 2006
            • 6478

            #6
            Also, if you use IDLE as your editor, when your choose Run>Run Module (F5)from the menu, IDLE automatically inserts the path of the file that you are running.

            Comment

            • Bellum
              New Member
              • Sep 2006
              • 23

              #7
              UPDATE: Ok, it's Monday. I tried sys.path.append ('blahblah'), which added the directory, but still didn't help create the module.


              Also, sys.path doesn't show the the path on my computer, either, though the program I'm importing (or really a library of functions) is in the same folder. This isn't any different than on the school computer...

              I'll remember the sites URL tomorrow (or the day after, which seems more likely) so I can try out your other suggestions. (I'm using PythonWin)

              Comment

              • bartonc
                Recognized Expert Expert
                • Sep 2006
                • 6478

                #8
                It turns out that PythonWin doesn't insert the current working directory into sys.path but works anyway. Here's what did:

                File>New
                Python Script <OK>

                print "hello"

                File>Save
                My Documents/Python
                Script1.py

                File>New
                Python Script <OK>

                import Script1

                File>Save
                My Documents/Python
                Scrip2.py

                File>Run...
                D:\My Documents\Pytho n\Script2.py <OK>

                Then switch to Interactive Window and see the output of Script1.
                So, for now, if you keep it simple - any module that imports another module in one folder it should work.

                Comment

                • Bellum
                  New Member
                  • Sep 2006
                  • 23

                  #9
                  It didn't work because I named the program Password.py where the .py was unnecessary. X_X

                  Comment

                  Working...