Re: [Tutor] SSL Error

2018-08-01 Thread Saket Mehrotra
Hi

I am also not using any Open SSL package.
I have just added  " import requests" in py file. And when I run the module
I   get the SSL package error ,not sure why.

Thanks
Saket

On Tue, Jul 31, 2018 at 10:28 PM, Marc Tompkins 
wrote:

> This is a general Python tutor group; I'm not sure anybody here can help
> you with the OpenSSL package (I've definitely never used it myself.)  We're
> all willing to help, but this might not be the right place to ask this
> question.
>
> More to the point, though, when you ask questions on this list it's best
> to just cut and paste BOTH your code and the actual error
> message/traceback; from the bit that you've posted, it sounds like it might
> be as simple as a typo, but we can't really tell without seeing your code.
>
> On Mon, Jul 30, 2018 at 7:52 PM, Saket Mehrotra 
> wrote:
>
>> Hi
>>
>> I am trying to run import requests in a py file but I am getting below
>> error  ssl.PROTOCOL_SSLv23: OpenSSL.SSL.SSLv23_METHOD,
>> AttributeError: module 'ssl' has no attribute 'PROTOCOL_SSLv23'
>> >>>
>>
>> I tried to execute below from the terminal but it still remains
>> unresolved.
>>
>> sudo easy_install --upgrade pip
>>
>> I've also had to run:
>>
>> sudo pip uninstall pyopenssl
>>
>> sudo pip install mozdownload
>>
>>
>> Can you please help me .
>>
>> Thanks & Regards
>> Saket Mehrotra
>> ___
>> Tutor maillist  -  Tutor@python.org
>> To unsubscribe or change subscription options:
>> https://mail.python.org/mailman/listinfo/tutor
>>
>
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] SSL Error

2018-08-01 Thread Alan Gauld via Tutor
On 01/08/18 05:07, Saket Mehrotra wrote:
> Hi
> 
> I am also not using any Open SSL package.
> I have just added  " import requests" in py file. And when I run the module
> I   get the SSL package error ,not sure why.

Then you really need to send the complete error message
and the code that generates it - the full function
definition at least.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any ideas why this woudn't work?

2018-08-01 Thread Alan Gauld via Tutor
On 01/08/18 14:17, Matthew Polack wrote:
>
> c:\Python>python crops3.py
> Traceback (most recent call last):
>   File "crops3.py", line 30, in 
>     filemenu.add_command(label="Show", command=self.showImg)
> NameError: name 'self' is not defined

The problem with cutting and pasting/copying code...

self is the name used for the first parameter in a
class method definition.  But you have not defined
any classes so self does not make sense.

In fact once you get past this error you will likely run into others
since self will have very strange values compared to the original
author's intent.

I suspect you might also run into other problems since you use
from tkinter import *

and

from PIL import Image...

But tkinter also has an Image class which your PIL one will
hide. If you intend to use the tkinter Image rather than the
PIL one you will be stuck.

If you use the

import tkinter as tk

approach you will avoid the ambiguity.



>
>
> I can't figure out why his works and mine doesn't
>
> Here is all my code so far...can either of you spot anything wrong?
>
> Thanks so much if you have a chance to look.

OK, But I've also CC'd it to the list since its good to keep the
discussion public so other people can benefit (and contribute)
too.

>
> Matt
>
>
>
> fromtkinter import*
> root =Tk("Crop Calculator")
> root.title("Crop Calculator")
> root.geometry("640x640+0+0")
> fromPIL importImage, ImageTk
> defdonothing():
> filewin =Toplevel(root)
> button =Button(filewin, text="Do nothing button")
> button.pack()
> defshowImg(self):
> load =Image.open('wheat.jpg')
> render =ImageTk.PhotoImage(load)
> img =Label(self, image=render)
> img.image =render
> img.place(x=0, y=0)
> defShowTxt(self):
> text =Label (self, text='Hey there')
> text.pack()
> menubar =Menu(root)
> filemenu =Menu(menubar, tearoff=0)
> filemenu.add_command(label="New", command=donothing)
> filemenu.add_command(label="Show", command=self.showImg)
> filemenu.add_command(label="Show Text", command=self.showTxt)
> filemenu.add_command(label="Save", command=donothing)
> filemenu.add_command(label="Save as...", command=donothing)
> filemenu.add_command(label="Close", command=donothing)
> filemenu.add_separator()
> filemenu.add_command(label="Exit", command=root.quit)
> menubar.add_cascade(label="File", menu=filemenu)
> editmenu =Menu(menubar, tearoff=0)
> editmenu.add_command(label="Undo", command=donothing)
> editmenu.add_separator()
> editmenu.add_command(label="Cut", command=donothing)
> editmenu.add_command(label="Copy", command=donothing)
> editmenu.add_command(label="Paste", command=donothing)
> editmenu.add_command(label="Delete", command=donothing)
> editmenu.add_command(label="Select All", command=donothing)
> menubar.add_cascade(label="Edit", menu=editmenu)
> helpmenu =Menu(menubar, tearoff=0)
> helpmenu.add_command(label="Help Index", command=donothing)
> helpmenu.add_command(label="About...", command=donothing)
> menubar.add_cascade(label="Help", menu=helpmenu)
> root.config(menu=menubar)
> # abutton = Button(root, text="Crop Prices in Australia")
> #Main Heading Labels
> #Answerlabel
> answerlabel=Label(root, text="wheatwords")
> # abutton.pack(side='left', fill='both', expand=True)
> '''
> instruction.grid(row=1, columnspan=12, sticky='ew')
> blanklabel.grid(row=2, columnspan=12, sticky='ew')
> blanklabel2.grid(row=11, columnspan=12, sticky='ew')
> '''
> wheatcost =("$5.23")
> peascost =("$3.23")
> lupenscost =("$8.23")
> barleycost =("$2.53")
> canolacost =("$9.72")
> sorghumcost =("$22.23")
> #List of Crops
> croplabel =Label(root, text="Crop Prices in Australia", fg="white",
> bg="green", font=("arial", 36, "bold"))
> instruction =Label(root, text="Please select from the following
> crops", fg="green", bg="white", font=("arial", 18, "bold"))
> wheatbutton =Button(root, text="Wheat", fg="black", bg="yellow")
> wheatprice =Label(root, text=wheatcost, fg="white", bg="black")
> peasbutton =Button(root, text="Peas", fg="white", bg="green")
> peasprice =Label(root, text=peascost, fg="white", bg="black")
> lupensbutton =Button(root, text="Lupens", fg="white", bg="brown")
> lupensprice =Label(root, text=lupenscost, fg="white", bg="black")
> barleybutton =Button(root, text="Barley", fg="white", bg="brown")
> barleyprice =Label(root, text=barleycost, fg="white", bg="black")
> canolabutton =Button(root, text="Canola", fg="white", bg="red")
> canolaprice =Label(root, text=canolacost, fg="white", bg="black")
> sorghumbutton =Button(root, text="Sorghum", fg="black", bg="ivory3")
> sorghumprice =Label(root, text=sorghumcost, fg="white", bg="black")
> blankline =Label(root, text="", bg="white")
> label_1 =Label(root, text="Type of Crop", fg="white", bg="black")
> label_2 =Label(root, text="Number of Metric Tonnes", fg="white",
> bg="black")
> entry1 =Entry(root)
> entry2 =Entry(root)
> blankline2 =Label(root, text="", bg="white")
> statusbar =Label(root, text="Copyright 2018", fg="white", bg="black",
> relief='sunken')
> wheat_image =Image.open("wh

Re: [Tutor] SSL Error

2018-08-01 Thread Marc Tompkins
On Wed, Aug 1, 2018 at 1:13 AM, Alan Gauld via Tutor 
wrote:

> On 01/08/18 05:07, Saket Mehrotra wrote:
> > Hi
> >
> > I am also not using any Open SSL package.
> > I have just added  " import requests" in py file. And when I run the
> module
> > I   get the SSL package error ,not sure why.
>
> Then you really need to send the complete error message
> and the code that generates it - the full function
> definition at least.
>

THIS.
Give us the _whole_ error message, even the parts that look like they don't
make any sense.  For one thing, the traceback tells us exactly which line
of code triggered the exception - and which file that line of code came
from.  From your description, it sounds like the error is being thrown by
the requests module, but we can't tell.

I've just taken a look at the source for "requests"; it never asks for
 PROTOCOL_SSLv23
specifically, so I don't know where that's coming from.  PROTOCOL_SSLv23 is
a constant in the standard-library ssl module, but not in pyopenssl.  (You
mentioned that you uninstalled pyopenssl, but requests imports it - so
there must be another copy of it on your machine somewhere?)

I can't emphasize this enough: the right way to ask questions is also the
easiest way - cut and paste.  Don't paraphrase, don't edit, don't try to be
creative or descriptive.  Just give us the entire error message and
traceback, and we can go from there.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor