Re: [Tutor] Tables in Tkinter

2017-03-02 Thread Pooja Bhalode
Hi Alan,

Sorry for being ambiguous earlier. I can make it more clear in this email.
I am planning on creating a scrollable table (grid of values) with title
labels for each column and rows present in it and a title for the overall
table.

I saw it online that to create a table in tkinter, I can use a built in
module tkintertable but would have to download it.
when I tried to install tkintertable using pip: i got the following errors:

Poojas-MacBook-Pro:~ poojabhalode$ pip install tkintertable

Collecting tkintertable

Collecting Pmw (from tkintertable)

Installing collected packages: Pmw, tkintertable

Exception:

Traceback (most recent call last):

  File
"/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py",
line 215, in main

status = self.run(options, args)

  File
"/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/commands/install.py",
line 342, in run

prefix=options.prefix_path,

  File
"/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py",
line 784, in install

**kwargs

  File
"/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py",
line 851, in install

self.move_wheel_files(self.source_dir, root=root, prefix=prefix)

  File
"/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py",
line 1064, in move_wheel_files

isolated=self.isolated,

  File
"/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/wheel.py", line
345, in move_wheel_files

clobber(source, lib_dir, True)

  File
"/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/wheel.py", line
316, in clobber

ensure_dir(destdir)

  File
"/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/utils/__init__.py",
line 83, in ensure_dir

os.makedirs(path)

  File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py",
line 157, in makedirs

mkdir(name, mode)

OSError: [Errno 13] Permission denied:
'/Library/Python/2.7/site-packages/Pmw'


After this, if I tried to import

>From tkintertable import TableCanvas

It gave me an error saying no module tkintertable found.

Can you please suggest me as to what I can do and how I can create the
table required? I also want to create another table wherein there would be
scrollable rows and columns. There would be one main column, which would be
subdivided into three and then the three columns subdivided into more
columns.


Please let me know.

Thank you


Pooja

On Wed, Mar 1, 2017 at 8:27 PM, Alan Gauld via Tutor 
wrote:

> On 01/03/17 23:40, Pooja Bhalode wrote:
>
> > I am trying to create normal tables in Tkinter.
>
> First you need to define what a "normal table" is.
> There is no such thing in standard Tkinter, so any
> kind of table is not normal.
>
> Do you want a simple grid of values?
> Do you want a spreadsheet type grid with editable cells?
> Do you want a live link to an underlying data store?
> Do you want it scrollable? Or re-sizeable? within the form?
>
> All of these features are "normal" for tables in
> different GUI toolkits, but none of them are normal
> in Tkinter.
>
> > as to what functions I can use, I looked into tkintertable, but that does
> > not seem to work for me.
>
> What does "not work" mean?
>
> Did it display on screen?
> Did it have empty values?
> Were the values not editable (assuming you wanted them to be?
>
> You need to be much more specific when describing problems.
>
> > I tried installing it but it gave me a bunch of
> > errors while installation and does not work.
>
> How did you install it?
> What were the errors?
> What does "not work" mean? (How could it work if the
> installation gave "a bunch of errors"?)
>
> > Is there any other simpler way for creating table and configuring them as
> > per needed?
>
> It depends what you want. Tell us what you are trying
> to achieve and we may be able to suggest something.
>
>
> --
> 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
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] looping - beginner question

2017-03-02 Thread Rafael Knuth
I wrote a program that is supposed to take orders from customers in a bar.
If the desired drink is available, the customer will be served. If
not, he will be informed that the drink is not available. This is what
I wrote:

bar = ["beer", "coke", "wine"]

customer_order = input("What would you like to drink, dear guest? ")

for drink in bar:
if customer_order != drink:
print ("Sorry, we don't serve %s." % customer_order)
else:
print ("Sure, your %s will be served in a minute!" % customer_order)

What I want the program to do is to "silently" loop through the list
of drinks and to print the correct answer. Instead, it loops through
each item on the list like this:

>>>
== RESTART: C:/Users/Rafael/Documents/01 - BIZ/Python/Python Code/PPC_4.py ==
What would you like to drink, dear guest? coke
Sorry, we don't serve coke.
Sure, your coke will be served in a minute!
Sorry, we don't serve coke.
>>>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Tables in Tkinter

2017-03-02 Thread Pooja Bhalode
I am currently using python 2.7 in mac system.
I think tkinter would be a problem since I use Tkinter for Python 2.7. But
I do not know the corresponding part of tkintertable for python 2.7

Thank you

Pooja

On Thu, Mar 2, 2017 at 9:25 AM, Pooja Bhalode 
wrote:

> Hi Alan,
>
> Sorry for being ambiguous earlier. I can make it more clear in this email.
> I am planning on creating a scrollable table (grid of values) with title
> labels for each column and rows present in it and a title for the overall
> table.
>
> I saw it online that to create a table in tkinter, I can use a built in
> module tkintertable but would have to download it.
> when I tried to install tkintertable using pip: i got the following errors:
>
> Poojas-MacBook-Pro:~ poojabhalode$ pip install tkintertable
>
> Collecting tkintertable
>
> Collecting Pmw (from tkintertable)
>
> Installing collected packages: Pmw, tkintertable
>
> Exception:
>
> Traceback (most recent call last):
>
>   File 
> "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py",
> line 215, in main
>
> status = self.run(options, args)
>
>   File 
> "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/commands/install.py",
> line 342, in run
>
> prefix=options.prefix_path,
>
>   File 
> "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py",
> line 784, in install
>
> **kwargs
>
>   File 
> "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py",
> line 851, in install
>
> self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
>
>   File 
> "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py",
> line 1064, in move_wheel_files
>
> isolated=self.isolated,
>
>   File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/wheel.py",
> line 345, in move_wheel_files
>
> clobber(source, lib_dir, True)
>
>   File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/wheel.py",
> line 316, in clobber
>
> ensure_dir(destdir)
>
>   File 
> "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/utils/__init__.py",
> line 83, in ensure_dir
>
> os.makedirs(path)
>
>   File 
> "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py",
> line 157, in makedirs
>
> mkdir(name, mode)
>
> OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-
> packages/Pmw'
>
>
> After this, if I tried to import
>
> From tkintertable import TableCanvas
>
> It gave me an error saying no module tkintertable found.
>
> Can you please suggest me as to what I can do and how I can create the
> table required? I also want to create another table wherein there would be
> scrollable rows and columns. There would be one main column, which would be
> subdivided into three and then the three columns subdivided into more
> columns.
>
>
> Please let me know.
>
> Thank you
>
>
> Pooja
>
> On Wed, Mar 1, 2017 at 8:27 PM, Alan Gauld via Tutor 
> wrote:
>
>> On 01/03/17 23:40, Pooja Bhalode wrote:
>>
>> > I am trying to create normal tables in Tkinter.
>>
>> First you need to define what a "normal table" is.
>> There is no such thing in standard Tkinter, so any
>> kind of table is not normal.
>>
>> Do you want a simple grid of values?
>> Do you want a spreadsheet type grid with editable cells?
>> Do you want a live link to an underlying data store?
>> Do you want it scrollable? Or re-sizeable? within the form?
>>
>> All of these features are "normal" for tables in
>> different GUI toolkits, but none of them are normal
>> in Tkinter.
>>
>> > as to what functions I can use, I looked into tkintertable, but that
>> does
>> > not seem to work for me.
>>
>> What does "not work" mean?
>>
>> Did it display on screen?
>> Did it have empty values?
>> Were the values not editable (assuming you wanted them to be?
>>
>> You need to be much more specific when describing problems.
>>
>> > I tried installing it but it gave me a bunch of
>> > errors while installation and does not work.
>>
>> How did you install it?
>> What were the errors?
>> What does "not work" mean? (How could it work if the
>> installation gave "a bunch of errors"?)
>>
>> > Is there any other simpler way for creating table and configuring them
>> as
>> > per needed?
>>
>> It depends what you want. Tell us what you are trying
>> to achieve and we may be able to suggest something.
>>
>>
>> --
>> 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
>>
>
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] feedback on simple python code

2017-03-02 Thread Ryan Smith
On 2/28/17, 3:32 AM, "Tutor on behalf of Peter Otten"

wrote:

>Ryan Smith wrote:
>
>> Hi all,
>> 
>> New python student here. I have been using O¹reilly¹s "Python Beyond the
>> Basics: Object Oriented Programming video series". In one of the
>> assignments we are to write a simple inheritance hierarchy of three
>> classes that write to text files. I have actually written the code for
>>the
>> assignment and it runs as well as meets the requirements of the
>> assignment. I am posting to get feedback on how I can improve this and
>> making it more pythonic and concise.
>> 
>> Please keep in mind that I am simply ³simulating" writing to a log file
>> and a tabbed delimited file, so I¹m not necessarily looking for which
>> modules I could have to create actual log files or writing to actual csv
>> files. The output of the code should be two text files with text written
>> to them that have been passed to the instance of each respective object.
>> 
>> #!/usr/bin/env python
>> 
>> import abc
>> import datetime
>> 
>> class WriteFile(object):
>> __metaclass__ = abc.ABCMeta
>> 
>> 
>> @abc.abstractmethod
>> def write(self,text):
>
>You might run a tool like https://pypi.python.org/pypi/pycodestyle over
>your 
>code to ensure it follows common standards.
>
>> """Write to file"""
>> return
>> 
>> 
>> class LogFile(WriteFile):
>> def __init__(self,fh):
>> self.fh = fh
>> 
>> 
>> def write(self, text):
>> date = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
>> entry = "{0} {1}{2}".format(date, text, '\n')
>> with open(self.fh, 'a') as f:
>> f.write(entry)
>> 
>> class DelimWrite(WriteFile):
>> def __init__(self, fh, delim):
>> self.fh = fh
>> self.delim = delim
>> 
>> 
>> def write(self, text):
>> with open(self.fh, 'a') as f:
>> entry = ""
>> for item in text:
>> if self.delim in item:
>> entry += ' "{0}"{1} '.format(item,self.delim)
>
>What will happen if text contains double quotes?
>
>> else:
>> entry += item+self.delim
>
>Have a look at the str.join() method. Example:
>
 ",".join(["foo", "bar", "baz"])
>'foo,bar,baz'
>
>> f.write(entry.strip(self.delim) + '\n')
>
>I will mention another "principle", DRY (don't repeat yourself), i. e. do
>not write the same code twice.
>
>When I look at your code I see that both DelimWrite and LogFile open a
>file. 
>If you want modify your code to accept file objects like sys.stdout you
>have 
>to make changes in both subclasses. To avoid that you might put the file-
>writing part into a separate method:
>
>class WriteFile(object):
>def __init__(self, file):
>self.file = file
>
>def write_record(self, record):
>with open(self.file, "a") as f:
>f.write(self.format_record(record))
>
>def format_record(self, record):
>return record
>
>
>class LogFile(WriteFile):
>def format_record(self, record):
>date = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
>return "{0} {1}\n".format(date, record)
>
>
>class DelimWrite(WriteFile):
>quote = '"'
>def __init__(self, file, delimiter):
>super(DelimWrite, self).__init__(file)
>self.delimiter = delimiter
>
>def escaped(self, value):
>value = str(value)
>if self.delimiter in value:
>quote = self.quote
>value = '"{}"'.format(value.replace(quote, quote + quote))
>return value
>
>def format_record(self, record):
>escaped_rows = (self.escaped(value) for value in record)
>return self.delimiter.join(escaped_rows) + "\n"
>
>
>___
>Tutor maillist  -  Tutor@python.org
>To unsubscribe or change subscription options:
>https://mail.python.org/mailman/listinfo/tutor
>

Danny/Peter,

Thank you to both of you for your feedback.

Peter,

I will definitely be adding pycodestyle to my toolkit. You made a good
point about creating a separate method for file writing so that both the
DelimWrite and the LogFile classes can use them. Also looking at my code I
see where my code does repeat with the write() method. I guess I’m still
trying to understand polymorphism because that’s what I was aiming for
when I wrote the code.

Danny,

Thank you for the link you provided on Liskov’s principals. To be honest I
started reading what you shared and realize it’s gonna take a little time
to digest it so that I can apply the principals in future code. I’m sure I
will have more questions, but I will just start a separate thread.

Again thank you both,

Ryan

 


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


Re: [Tutor] Spyder IDE Anaconda3: Problem with Plt.savefig

2017-03-02 Thread Stephen P. Molnar

On 03/01/2017 08:32 PM, Alan Gauld via Tutor wrote:

On 01/03/17 20:20, Stephen P. Molnar wrote:

I have written a Python3 program to plot and save UV/VIS spectra from
the results of an Orca quantum mechanical calculation.


Caveat: This forum is for help on the core Python language
and its standard library. Asking about anything beyond that
may require a lot more information about the context - for
example few of us will know anything about UV/VIS spectra
(even what that means!)

However, I'll hazard a guess...


figure = name+'.png'
print(figure)
plt.savefig('figure', bbox_inches='tight')


Shouldn't the last line use the variable figure
rather than a literal string 'figure' :

plt.savefig(figure, bbox_inches='tight')


where the print statement verifies the nae of the saved figure. The
problem is that the saved file is figure.png.


I'm guessing that's because you are passing the string 'figure'
instead of the variable.

But I don;t know anything about your plt object
or its savefig() method, not even which library
you are using. Is it matplotlib? Or something else?

HTH



That was the problem.

Many thanks.

--
Stephen P. Molnar, Ph.D.Life is a fuzzy set
www.molecular-modeling.net  Stochastic and multivariate
(614)312-7528 (c)
Skype: smolnar1
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] looping - beginner question

2017-03-02 Thread Alan Gauld via Tutor
On 02/03/17 13:42, Rafael Knuth wrote:

> bar = ["beer", "coke", "wine"]
> 
> customer_order = input("What would you like to drink, dear guest? ")
> 
> for drink in bar:
> if customer_order != drink:
> print ("Sorry, we don't serve %s." % customer_order)
> else:
> print ("Sure, your %s will be served in a minute!" % customer_order)
> 
> What I want the program to do is to "silently" loop through the list

So you only want the sorry... message if the loop completes without
finding a drink. That means you need to put that print statement after
the loop. Python includes a feature for that - a for/else construct.

for drink in bar:
if drink == customer_order:
   print(Sure...)
   break  #exit loop and avoid else
else:
# only if the loop completes normally

However, there is another way to do this that doesn't
use an explicit loop: the 'in' operator

if customer_order in bar:
print("sure)
else:
print ("Sorry)

hth
-- 
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] Tables in Tkinter

2017-03-02 Thread Alan Gauld via Tutor
On 02/03/17 14:25, Pooja Bhalode wrote:

> when I tried to install tkintertable using pip: i got the following errors:
> 
> OSError: [Errno 13] Permission denied:
> '/Library/Python/2.7/site-packages/Pmw'


Based on this I'm guessing you need to run pip with sudo?

-- 
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] looping - beginner question

2017-03-02 Thread Mats Wichmann
On 03/02/2017 08:06 AM, Alan Gauld via Tutor wrote:
> On 02/03/17 13:42, Rafael Knuth wrote:
> 
>> bar = ["beer", "coke", "wine"]
>>
>> customer_order = input("What would you like to drink, dear guest? ")
>>
>> for drink in bar:
>> if customer_order != drink:
>> print ("Sorry, we don't serve %s." % customer_order)
>> else:
>> print ("Sure, your %s will be served in a minute!" % customer_order)
>>
>> What I want the program to do is to "silently" loop through the list
> 
> So you only want the sorry... message if the loop completes without
> finding a drink. That means you need to put that print statement after
> the loop. Python includes a feature for that - a for/else construct.
> 
> for drink in bar:
> if drink == customer_order:
>print(Sure...)
>break  #exit loop and avoid else
> else:
> # only if the loop completes normally
> 
> However, there is another way to do this that doesn't
> use an explicit loop: the 'in' operator
> 
> if customer_order in bar:
> print("sure)
> else:
> print ("Sorry)

To follow on to what Alan said, you don't need to loop over a list (or
tuple, or dictionary, or other "iterable") to find out if it contains an
item. You can just test membership directly.




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


Re: [Tutor] looping - beginner question

2017-03-02 Thread leam hall
On Thu, Mar 2, 2017 at 8:42 AM, Rafael Knuth  wrote:

> I wrote a program that is supposed to take orders from customers in a bar.
> If the desired drink is available, the customer will be served. If
> not, he will be informed that the drink is not available. This is what
> I wrote:
>
> bar = ["beer", "coke", "wine"]
>
> customer_order = input("What would you like to drink, dear guest? ")
>
> for drink in bar:
> if customer_order != drink:
> print ("Sorry, we don't serve %s." % customer_order)
> else:
> print ("Sure, your %s will be served in a minute!" %
> customer_order)
>
> What I want the program to do is to "silently" loop through the list
> of drinks and to print the correct answer. Instead, it loops through
> each item on the list like this:
>
> >>>
> == RESTART: C:/Users/Rafael/Documents/01 - BIZ/Python/Python Code/PPC_4.py
> ==
> What would you like to drink, dear guest? coke
> Sorry, we don't serve coke.
> Sure, your coke will be served in a minute!
> Sorry, we don't serve coke.
> >>>
>
> Rafael, don't forget that your input string might have a newline character
that needs to be cleaned off. I think, can't test at the moment. The
simplest test might be:

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


Re: [Tutor] Tables in Tkinter

2017-03-02 Thread Pooja Bhalode
Hi Alan,

Thank you for that advice. Sorry, I should have caught that.
Also, i can look into the documentation of tkintertable for creating the
table.

Thank you

Pooja
On Thu, Mar 2, 2017 at 10:12 AM Alan Gauld via Tutor 
wrote:

> On 02/03/17 14:25, Pooja Bhalode wrote:
>
> > when I tried to install tkintertable using pip: i got the following
> errors:
> >
> > OSError: [Errno 13] Permission denied:
> > '/Library/Python/2.7/site-packages/Pmw'
>
>
> Based on this I'm guessing you need to run pip with sudo?
>
> --
> 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
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Asking about pi_switch

2017-03-02 Thread Quang nguyen
Hi,

Right now, I need to use pi_switch in order to send data through RF system
by Pi2. Until now, I installed everything it need from an article on the
internet. Those things are python-dev, libboost-python-dev, python-pip, and
I used pip to install pi_switch.

I think it just compatible with python2, and I cannot import it to python3.

Are there any ways I can import it to python3 or execute python2 script
which has pi_switch by python3 script?.

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


Re: [Tutor] Asking about pi_switch

2017-03-02 Thread Alan Gauld via Tutor
On 02/03/17 22:20, Quang nguyen wrote:

> Right now, I need to use pi_switch in order to send data through RF system
> by Pi2. Until now, I installed everything it need from an article on the
> internet. Those things are python-dev, libboost-python-dev, python-pip, and
> I used pip to install pi_switch.
> 
> I think it just compatible with python2, and I cannot import it to python3.
> 
> Are there any ways I can import it to python3 or execute python2 script
> which has pi_switch by python3 script?.

There are a few compatibility libraries around but your
simplest solution is probably to install python2 on your Pi.

BTW You might find a Pi forum gets you more answers than this list which
is aimed for Python language queries and the standard library. Not too
many of us use a Pi (although I confess that I do occasionally)


-- 
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] Asking about pi_switch

2017-03-02 Thread Alex Kleider

On 2017-03-02 14:20, Quang nguyen wrote:

Hi,

Right now, I need to use pi_switch in order to send data through RF 
system
by Pi2. Until now, I installed everything it need from an article on 
the
internet. Those things are python-dev, libboost-python-dev, python-pip, 
and

I used pip to install pi_switch.

I think it just compatible with python2, and I cannot import it to 
python3.


Are there any ways I can import it to python3 or execute python2 script
which has pi_switch by python3 script?.

Thanks


I'll assume you are using Raspbian as the OS on a Raspberry Pi.
Raspbian is a Debian based version of Linux.
python2.7 is the default but python3 is also there.
I suggest you use virtualenv as follows:

sudo apt-get install python-virtualenv
cd 
virtualenv -p python3 venv
source venv/bin/activate  # This will leave you in a Python 3 
environment.

pip install py_switch  # I assume this is a RPi specific package

You can exit the environment with the following command:
deactivate

You can get back into it by sourcing activate again as shown above.

Hope this is helpful.

I've been doing a lot of this sort of stuff with the Raspberry Pi and 
would be happy to keep the conversation going off line for the non 
Python bits.


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


Re: [Tutor] Asking about pi_switch

2017-03-02 Thread Alex Kleider



On 02/03/17 22:20, Quang nguyen wrote:

Right now, I need to use pi_switch in order to send data through RF 
system
by Pi2. Until now, I installed everything it need from an article on 
the
internet. Those things are python-dev, libboost-python-dev, 
python-pip, and

I used pip to install pi_switch.

I think it just compatible with python2, and I cannot import it to 
python3.


Are there any ways I can import it to python3 or execute python2 
script

which has pi_switch by python3 script?.


Sorry, Quang, I got your problem backwards- Raspbian comes with 
python2.7.
Are you sure you are using Python 3?  You would have had to take special 
measures to do so.


check here: https://github.com/lexruee/pi-switch-python
and note that rpi-rf is recommended instead.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor