954,549 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Python 2.4: AttributeError: 'module' object has no attribute 'argv'

Hi, I tried to run following script of drawing a sin/cos curve using python 2.4 , there is error:

Traceback (most recent call last):
File "", line 6, in ?
File "C:\Python24\Lib\lib-tk\Tkinter.py", line 1564, in __init__
baseName = os.path.basename(sys.argv[0])
AttributeError: 'module' object has no attribute 'argv'


Can anybody tell me what should I do for this error?
Thanks!

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

from Tkinter import *
import math
import sys
sys.frozen = 1
 
root = Tk()
root.title("Simple plot using canvas and line")
 
width = 400
height = 300
center = height//2
x_increment = 1
# width stretch
x_factor = 0.04
# height stretch
y_amplitude = 80
 
c = Canvas(width=width, height=height, bg='white')
c.pack()
 
str1 = "sin(x)=blue  cos(x)=red"
c.create_text(10, 20, anchor=SW, text=str1)
 
center_line = c.create_line(0, center, width, center, fill='green')
 
# create the coordinate list for the sin() curve, have to be integers
xy1 = []
for x in range(400):
    # x coordinates
    xy1.append(x * x_increment)
    # y coordinates
    xy1.append(int(math.sin(x * x_factor) * y_amplitude) + center)
 
sin_line = c.create_line(xy1, fill='blue')
 
# create the coordinate list for the cos() curve
xy2 = []
for x in range(400):
    # x coordinates
    xy2.append(x * x_increment)
    # y coordinates
    xy2.append(int(math.cos(x * x_factor) * y_amplitude) + center)
 
cos_line = c.create_line(xy2, fill='red')
 
root.mainloop()

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

cambrian
Newbie Poster
1 post since Dec 2006
Reputation Points: 10
Solved Threads: 0
 
from Tkinter import * import math ##import sys sys.frozen = 1 .....

do you want to comment out "import sys" and try again?

ghostdog74
Junior Poster
156 posts since Apr 2006
Reputation Points: 75
Solved Threads: 44
 

I know this code all too well!
http://www.daniweb.com/code/snippet578.html
Why did you add these two lines?

import sys
sys.frozen = 1
vegaseat
DaniWeb's Hypocrite
Moderator
5,989 posts since Oct 2004
Reputation Points: 1,345
Solved Threads: 1,417
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You