Distributing Python Programs

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Funpolice
    New Member
    • Mar 2008
    • 5

    Distributing Python Programs

    Hello,

    I have written a program that requires some modules from pyxml to run. It will run fine on my pc but if I try to run it on another pc with python but without the pyxml modules, I will get import errors. What is the best way to run my program on other pc's without having to install dependent modules on them?

    I have tried cx_freeze, freeze.py and am having issues with those. Is there any other alternatives? I am using python 2.5 and OpenSuse 10.1. Thanks.
  • jlm699
    Contributor
    • Jul 2007
    • 314

    #2
    You can either try building a distributable program, or literally taking the inherited functions that you use and put the code into your own program...

    Why are you trying to do this? If you would like to create distributions (like .exe ) you should look into py2exe

    Comment

    • Funpolice
      New Member
      • Mar 2008
      • 5

      #3
      I have tried cx_freeze and freeze.py to create standalone programs but am having issues with those two methods that I am still working on. I cannot use py2exe because I am running linux.

      Comment

      • jlm699
        Contributor
        • Jul 2007
        • 314

        #4
        Oh yeah, sorry.. missed that.

        Have you tried this... ?

        Comment

        • Funpolice
          New Member
          • Mar 2008
          • 5

          #5
          I'll try to clarify my situation and what I am trying to achieve...
          I would like to put my script on a shared directory where all pc's on the network will be able to access. They should all be able to execute the script without having to install additional modules. All the pc's have python installed but do not have pyxml, which the script needs. I don't want to install pyxml on each pc. In this situation distutils is not the ideal solution.

          Is it possible to copy the entire pyxml module into the same folder as my script and modify the import statements? Will the scirpt then look in this folder as opposed to the default python install directory? And how exactly will the import statement look like?

          Thanks for the help so far.

          Comment

          • jlm699
            Contributor
            • Jul 2007
            • 314

            #6
            Originally posted by Funpolice
            Is it possible to copy the entire pyxml module into the same folder as my script and modify the import statements? Will the scirpt then look in this folder as opposed to the default python install directory? And how exactly will the import statement look like?
            I'm not entirely positive but I'm pretty sure that the import command will look in the current working directory before looking elsewhere (python install dir)... so you shouldn't have to change the import command at all. As long as it's in the working directory it'll work without a hitch.

            It may not look there FIRST per say, but if it finds it there after a fail in the default install directory it'll still work seamlessly. You could always modify the sys.path variable before doing the import.

            ie,
            [CODE=python]
            import sys, os
            sys.path.insert (0, os.getcwd()) # this could also be another path where pyxml is contained
            import pyxml
            ...
            [/CODE]

            Comment

            • Funpolice
              New Member
              • Mar 2008
              • 5

              #7
              Well that was pretty straight forward... Thanks jlm699!

              Comment

              Working...