By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,712 Members | 763 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,712 IT Pros & Developers. It's quick & easy.

Distributing Python Programs

P: 5
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.
Mar 11 '08 #1
Share this Question
Share on Google+
6 Replies


jlm699
100+
P: 314
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
Mar 11 '08 #2

P: 5
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.
Mar 11 '08 #3

jlm699
100+
P: 314
Oh yeah, sorry.. missed that.

Have you tried this... ?

http://www.linux.com/feature/118439
Mar 11 '08 #4

P: 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.
Mar 11 '08 #5

jlm699
100+
P: 314
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,
Expand|Select|Wrap|Line Numbers
  1. import sys, os
  2. sys.path.insert(0, os.getcwd()) # this could also be another path where pyxml is contained
  3. import pyxml
  4. ...
  5.  
Mar 11 '08 #6

P: 5
Well that was pretty straight forward... Thanks jlm699!
Mar 11 '08 #7

Post your reply

Sign in to post your reply or Sign up for a free account.