Why XP can not run Python after being setting the PATH?
Hello all: I have set the PATH for Python as follows: My Computer->Properties->Advanced->Environment Variables->System Variables->Path ...; C:\Program Files\Python24; Then I try to run python under command line C:\>python C:\>python.exe I got nothing:) It works iff I run as follows: C:\>"Program Files\Python24\python.exe" Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> My question is how I can set the path so that the XP can run python without the full path? Thank you very much -Daniel -- http://mail.python.org/mailman/listinfo/python-list
Re: Why XP can not run Python after being setting the PATH?
Hello Dennis: > A second suggestion would be: don't install Python in "Program > Files", but put it at the top level of the partition (ie; C:\Python24\) > I guess your comment is right. However, I would like to install Python under directory "C:\Program Files\Python24" Also, I list some screen shot from my machine as follows: C:\Program Files\Python24>cd \ C:\>python C:\>"Program Files\Python24\python.exe" Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> ^Z C:\>Program\ Files\Python24\python.exe 'Program\' is not recognized as an internal or external command, operable program or batch file. C:\>python111 'python111' is not recognized as an internal or external command, operable program or batch file. It seems that XP know there is python.exe there, but cannot run it correctly if i use c:\python The only way works on my machine is to run with full path. Maybe there is not solution to this problem:)? Thank you all:) -- http://mail.python.org/mailman/listinfo/python-list
Re: Why XP can not run Python after being setting the PATH?
Hello Ray: Python is on my Path list as follows: C:\Program Files\Python24>echo %path% C:\Program Files\texmf\miktex\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\cygwin\usr\local\bin;c:\cygwin\bin;C:\P rogram Files\Java\jdk1.5.0_06\bin;C:\Program Files\gp400win32\gnuplot\bi n;C:\Program Files\Python24;C:\Program Files\j2sdk1.4.2_09\bin; So I don't think that is the real problem:) thank you Ray wrote: > By any chance the command window hasn't been restarted after you've > changed the PATH? Strange that looks OK. > > If you do echo %PATH% what does it tell you, is Python there? > > Cheers > Ray > > Daniel Mark wrote: > > Hello all: > > > > I have set the PATH for Python as follows: > > > > My Computer->Properties->Advanced->Environment Variables->System > > Variables->Path > > > > ...; C:\Program Files\Python24; > > > > Then I try to run python under command line > > > > C:\>python > > > > C:\>python.exe > > > > I got nothing:) > > > > It works iff I run as follows: > > > > C:\>"Program Files\Python24\python.exe" > > Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)] > > on win32 > > Type "help", "copyright", "credits" or "license" for more information. > > >>> > > > > My question is how I can set the path so that the XP can run python > > without the full path? > > > > > > Thank you very much > > -Daniel -- http://mail.python.org/mailman/listinfo/python-list
Re: Why XP can not run Python after being setting the PATH?
Hello John: I did try, however, it doesn't work on my machine. Thank you -Daniel John Salerno wrote: > Daniel Mark wrote: > > > Maybe there is not solution to this problem:)? > > Did you not try Sybren's suggestion? Remove the space between the > semicolon and the path and it should work. It worked (and didn't work) > for me when I tested it. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why XP can not run Python after being setting the PATH?
Dear John: > Have a look in each of those folders (including the root!!) and see > what you find there. [If I were forced to bet, I'd put my money on > cygwin]. You are a genius!!! My machine was intalled python in cygwin:) I didn't expect that I could get so much helps from this forum. My heartfelt thanks go out to John and all friends here:) -Daniel -- http://mail.python.org/mailman/listinfo/python-list
How to draw line on Image?
Hello all: I want to draw some shapes, such as lines, circles on an image. The input to the program is an image and the output from the program is a superimposed image. what kind of document or functions I should take a look for searching this question? The program doesn't show the image, but draws some shapes on the input image. Thank you -daniel -- http://mail.python.org/mailman/listinfo/python-list
py2exe: cannot identify image file
Hello all:
I have following code that works well under command line, but it
doesn't work after I convert it
as exe application.
### file: testPath.py
import getopt, math, sys, os, Image, ImageDraw, aggdraw
def processline():
try:
imgDir = 'c:/'
lumenImageName = '00299.jpg'
im = Image.open(os.path.join(imgDir, lumenImageName))
arrowImageName = '00299.png'
im.save(os.path.join(imgDir, arrowImageName), "PNG")
print lumenImageName
except IOError, e:
print e
def main():
processline()
if __name__ == '__main__':
main()
print 'Done'
else:
print 'non main'
### setup.py
from distutils.core import setup
import py2exe
options = {
"bundle_files": 1,
# "ascii": 1, # to make a smaller executable, don't include the
encodings
"compressed": 1, # compress the library archive
}
setup(
# The first three parameters are not required, if at least a
# 'version' is given, then a versioninfo resource is built from
# them and added to the executables.
version = "1.0",
description = "testPath",
name = "testPath",
options = {"py2exe": options},
zipfile = None, # append zip-archive to the executable.
# targets to build
console=['testPath.py'],
)
###
It works under command line
C:\>python testPath.py
00299.jpg
Done
But it doesn't work after I convert it as EXE application
The error message I got from screen is as follows:
C:\dist>testPath.exe
cannot identify image file
Done
It seems that function 'Image.open' cannot read image file under EXE
application.
What should I do for this problem?
Thank you
-Daniel
--
http://mail.python.org/mailman/listinfo/python-list
How to handle wrong input in getopt package in Python?
Hello all:
I am using getopt package in Python and found a problem that I can not
figure out an easy to do .
// Correct input
D:\>python AddArrowOnImage.py --imageDir=c:/
// Incorrect input
D:\>python AddArrowOnImage.py --imageDi
Traceback (most recent call last):
File "AddArrowOnImage.py", line 113, in ?
File "AddArrowOnImage.py", line 88, in main
File "getopt.pyc", line 89, in getopt
File "getopt.pyc", line 157, in do_longs
getopt.GetoptError: option --imageDir requires argument
Is there any method in getopt or Python that I could easily check the
validity of each
command line input parameter?
Thank you
-Daniel
FYI: My code that deals with getopt is as follows:
o, a = getopt.getopt(sys.argv[1:], 'h', ['imageDir='])
opts = {}
for k,v in o:
if k in ['--imageDir'] and len(v) == 0:
usage(); sys.exit("Insufficient input parameters!")
opts[k] = v
if opts.has_key('-h'):
usage(); sys.exit(0)
if not len(opts['--imageDir']):
usage(); sys.exit("Insufficient input parameters!")
--
http://mail.python.org/mailman/listinfo/python-list
How to change font direction?
Hello all: I am using PIL to draw some graphics and I need to draw some texts in vertical direction rather than the default left-to-right horizontal direction. Is there anyway I could do that? Thank you -Daniel -- http://mail.python.org/mailman/listinfo/python-list
How to draw a rectangle with gradient?
Hello all: I am using PIL to draw a rectangle filled with color blue. Is there anyway I could set the fill pattern so that the drawn rectangle could be filled with gradient blue? Thank you -Daniel -- http://mail.python.org/mailman/listinfo/python-list
How to efficiently proceed addition and subtraction in python list?
Hello all: I have a list AAA = [1, 2, 3] and would like to subtract one from list AAA so AAA' = [0, 1, 2] What should I do? Thank you -Daniel -- http://mail.python.org/mailman/listinfo/python-list
Do we need to delete "ImageDraw.Draw" after using it?
Hello all:
I am looking the sample code posted on PIL website
http://www.pythonware.com/library/pil/handbook/imagedraw.htm
<>
import Image, ImageDraw
im = Image.open("lena.pgm")
draw = ImageDraw.Draw(im)
draw.line((0, 0) + im.size, fill=128)
draw.line((0, im.size[1], im.size[0], 0), fill=128)
del draw # === Why we should delete this object draw?
# write to stdout
im.save(sys.stdout, "PNG")
#
Is there any general rule that we must delete the object after using
it?
Thank you
-Daniel
--
http://mail.python.org/mailman/listinfo/python-list
How to evaluate the memory usage of a python program?
Hello all: I have a python program and would like to find out the maximum memory used by this program. Does Python provide such module so I could check it easily? Thank you -Daniel -- http://mail.python.org/mailman/listinfo/python-list
How does IPython modify the sys.path?
Hello all: I installed IPython on my XP machine today and find that my sys.path has been changed as follows: >> import sys >> print sys.path ['', 'C:\\Program Files\\Python24\\scripts', 'C:\\WINDOWS\\system32\\python24.zip', 'C:\\Documents and Settings\\Daniel\\Desktop', 'C:\\Program Files\\Python24\\DLLs', 'C:\\Program Files\\Python24\\lib', 'C:\\Program Files\\Python24\\lib\\plat-win', 'C:\\Program Files\\Python24\\lib\\lib-tk', 'C:\\Program Files\\Python24', 'C:\\Program Files\\Python24\\lib\\site-packages', 'C:\\Program Files\\Python24\\lib\\site-packages\\PIL', 'C:\\Program Files\\Python24\\lib\\site-packages\\win32', 'C:\\Program Files\\Python24\\lib\\site-packages\\win32\\lib', 'C:\\Program Files\\Python24\\lib\\site-packages\\Pythonwin', 'C:\\Program Files\\Python24\\lib\\site-packages\\wx-2.6-msw-ansi', 'C:\\Program Files\\Python24\\lib\\site-packages\\reportlab_2_0', 'C:\\Program Files\\Python24\\lib\\site-packages\\IPython/Extensions', 'C:\\Documents and Settings\\Daniel\\_ipython'] Obviously, IPython changed my sys.path and added an entry in the end as "C:\\Documents and Settings\\Daniel\\_ipython'" However, I cannot figure out how IPython can change my sys.path. I refer to all the following sources 1> http://www.python.org/doc/current/inst/search-path.html Installing Python Modules 2> KEY_LOCAL_MACHINE\Software\Python\PythonCore\2.4\PythonPath 3> My machine has no environment variable "PYTHONPATH" 4> There is no *.pth file under C:\Program Files\Python24\Lib\site-packages that contains that information (i.e. C:\\Documents and Settings\\Daniel\\_ipython) So how dos IPython modify my sys.path without trace??? Thank you very much! -Daniel -- http://mail.python.org/mailman/listinfo/python-list
Does Python provide "Struct" data structure?
Hello all:
I have found a useful module in IPython, named 'from IPython.ipstruct
import Struct".
So I can use it as follows:
from IPython.ipstruct import Struct
mystruct = Struct(echo = 1,
verb = 'Verbose',
filedir = 'C:/temp',
)
print mystruct.filedir
#
I have two following questions:
1> Does Python provide such Struct in this standard libary.
Python has "4.3 struct -- Interpret strings as packed binary data", but
it looks like different
from what I really want to get.
2> Is it safe to use IPython's modules in my python program?
I will pack all my code into an executable application by using py2exe.
The clients would like to use this application without any python
intallation.
What should I pay attention if I include the IPython modules into my
python code and
convert it into executable application by using py2exe?
The setup.py for my application is as follows:
###
from distutils.core import setup
import py2exe
options = {
"bundle_files": 1,
# "ascii": 1, # to make a smaller executable, don't include the
encodings
"compressed": 1, # compress the library archive
}
setup(
# The first three parameters are not required, if at least a
# 'version' is given, then a versioninfo resource is built from
# them and added to the executables.
version = "1.0",
description = "mycode",
name = "mycode",
options = {"py2exe": options},
zipfile = None, # append zip-archive to the executable.
# targets to build
console=['mycode.py'],
)
###
Does I need to make any modification if I include IPython module in my
code?
Thank you for your helps
-Daniel
--
http://mail.python.org/mailman/listinfo/python-list
Question about the article "py2exe compiler" in Python Cookbook by Alexander Semenov
Hello all: I follow the following tutorial http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/108598 Description: script for making executables with py2exe ## from distutils.core import setup import sys, os, py2exe name = sys.argv[1] sys.argv[1] = 'py2exe' sys.path.append(os.path.dirname(os.path.abspath(name))) setup(name=name[:-3], scripts=[name]) ## However, I can not get the expected results. 1> save the above script as file makexe.py under the folder C:\Program Files\Python24\Tools\Scripts 2> add this path to system path 3> C:\> makexe.py myscript.py What I got from the "dist" folder are as follows: C:\dist\unicodedata.pyd C:\dist\w9xpopen.exe C:\dist\zlib.pyd C:\dist\bz2.pyd C:\dist\library.zip C:\dist\MSVCR71.dll C:\dist\python24.dll Suppose I should get an executable file under this folder. What should I do to solve this problem? Thank you -Daniel -- http://mail.python.org/mailman/listinfo/python-list
How to save High Quality JPG image by setting Image module from PIL
hello all: I am using Image module from PIL to save created image as JPG format. Is there any option I could set for function Image.save so that the stored image will have the highest quality. Thank you -Daniel -- http://mail.python.org/mailman/listinfo/python-list
remove the last character or the newline character?
Hello all: I have the following snippet: In [1]: fileName = 'Perfect Setup.txt\n' In [2]: fileName = fileName[0:len(fileName)-1)] # remove the '\n' character In [3]: fileName Out[3]: 'Perfect Setup.txt' Question one: Does python provide any function that can remove the last character of a string? I don't know whether or not the method I used is efficient Question two: Does python provide any function that can remove the newline character from a string if it exists? Thank very much! -Daniel -- http://mail.python.org/mailman/listinfo/python-list
