Re: possible to run a python script without installing python?
i need to run a python script on any arbitrary server and don't want to do an actual installation. i figured i could do a clean install on my machine and install whatever libraries would be needed, then zip them all up for remote deployment. to avoid bloating, i am wondering which files i can safely omit. On Tue, Mar 15, 2011 at 8:48 PM, Katie T wrote: > > On Tue, Mar 15, 2011 at 8:58 PM, davidj411 wrote: > >> it seems that if I copy the python.exe binary and the folders >> associated with it to a server without python, i can run python. >> does anyone know which files are important to copy and which can be >> omitted? >> >> i know about py2exe and have had no luck with it. > > > What's the reason for wanting to avoid installing Python? - are you just > trying to save disk space? > > If it's a case of not having admin rights, you can just copy the Python > directory, I don't believe it has any dependencies anywhere else. > > Katie > -- > CoderStack > http://www.coderstack.co.uk > The Software Developer Job Board > -- http://mail.python.org/mailman/listinfo/python-list
import
Hi all, I'm a real beginner with python but have what I think is a simple question. I am writing some simple modules and would like to place them into a subdirectory. But then I cannot seem to import them. I have tried the following. I wrote a module called fibo.py with some definitions in it (one called fibo). In the same directory, I wrote another file (test.py) and began with import fibo. This worked fine and I was able to use the function fibo as fibo.fibo. Then, I made a directory called test and placed the file fibo.py in this directory. I also placed a blank file called _init_.py into this directory. I went back to the original directory and tried to import test.fibo but this fails. I get the following error message: Traceback (innermost last) File "...test.py", line 1, in ? import test.fibo File "...test.py", line 1, in ? import test.fibo ImportError: No module named fibo Any help would be greatly appreciated. If it makes any difference, I'm working on a Mac, OSX 10.3.9 Thanks, David -- http://mail.python.org/mailman/listinfo/python-list
Re: import
Indeed you are correct...that is indeed TWO underscores and everything works fine now. Thanks for pointing out the obvious...I thought it was a simple problem. --DJ "faulkner" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > that should be __init__.py [TWO underscores]. > and you might want to import sys and check sys.path [the list of > directories searched by the import mechanism]. > > > David Jackson wrote: >> Hi all, >> >> I'm a real beginner with python but have what I think is a simple >> question. >> I am writing some simple modules and would like to place them into a >> subdirectory. But then I cannot seem to import them. I have tried the >> following. >> >> I wrote a module called fibo.py with some definitions in it (one called >> fibo). In the same directory, I wrote another file (test.py) and began >> with >> import fibo. This worked fine and I was able to use the function fibo as >> fibo.fibo. Then, I made a directory called test and placed the file >> fibo.py >> in this directory. I also placed a blank file called _init_.py into this >> directory. I went back to the original directory and tried to import >> test.fibo but this fails. I get the following error message: >> >> Traceback (innermost last) >> File "...test.py", line 1, in ? >> import test.fibo >> File "...test.py", line 1, in ? >> import test.fibo >> ImportError: No module named fibo >> >> Any help would be greatly appreciated. If it makes any difference, I'm >> working on a Mac, OSX 10.3.9 >> >> Thanks, >> David > -- http://mail.python.org/mailman/listinfo/python-list
Re: csv iterator question
Thanks, Ethan. that was a great solution. i just tested it. On Fri, May 23, 2008 at 7:08 PM, Ethan Furman <[EMAIL PROTECTED]> wrote: > davidj411 wrote: > > When you save an open file to a variable, you can re-use that variable >> for membership checking. >> it does not seem to be that way with the csv.reader function, even >> when set to a variable name. >> >> what is the best way to store the open CSV file in memory or do i need >> to open the file each time? >> >> example of open method on file object: >> fhandle=open(filename).readelines() >> >> > >>> fhandle = open('c:/temp/08-02024.csv').readlines() > >>> type(fhandle) > > >>> len(fhandle) > 381 > > fhandle is a list containing the contents of the file, not a file handle -- > that's why you can easily re-use it. > > example of csv.reader method: >> reader = csv.reader(open(csvfilename)) >> >> > Try this instead: > >>>reader = csv.reader(open('c:/temp/08-02024.csv')) > >>> contents = [line for line in reader] > >>> type(contents) > > >>> len(contents) > 381 > > You still get a list that you can easily use, that has gone through the csv > routines. > > Hope this helps. > -- > Ethan > > -- http://mail.python.org/mailman/listinfo/python-list
Re: WMI remote call in python script to create process on remote windows computer
ok, cut and pasted, but changed the username/password to protect the innocent. this is from interactive prompt. let me know if i am still not doing the slashes correctly please. i doubt authentication is the issue.; i can get pid information using WQL queries. objCreateProc.Create expects 4 strings (not objects?), right? version info: >>> sys.version '2.6 (r26:66721, Oct 2 2008, 11:35:03) [MSC v.1500 32 bit (Intel)]' >>> import win32com.client >>> computer = "servername" >>> strUser = "servername\\my_account" >>> strPassword ="shh_secret" >>> objSWbemLocator = win32com.client.Dispatch("WbemScripting.SWbemLocator") >>> objSWbemServices = objSWbemLocator.ConnectServer(computer, >>> r"root\cimv2",strUser,strPassword) >>> objCreateProc = objSWbemServices.Get("Win32_Process") >>> ProcessID = u"200" >>> objCreateProc.Create(u"cmd /c ping 127.0.0.1 >>> >>c:\\temp\\finall.log",u"c:\\temp",u' ',ProcessID ) Traceback (most recent call last): File "", line 1, in TypeError: 'int' object is not callable how can i see the method available? >>> help(objCreateProc) just gives me "Help on instance of CDispatch in module >>> win32com.client:" Thanks David -- http://mail.python.org/mailman/listinfo/python-list