[Tutor] pip upgrade issue with virtual env

2017-07-10 Thread Feifan Liu
Hello
I used anaconda to create a virtual envs.
Anaconda location: /usr/local/anaconda
My envs location: ~/.conda/envs/py2713

Then I activated my environment, did pip upgrade using: sudo pip install
--upgrade pip
***
Collecting pip
  Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB)
100%
Installing collected packages: pip
  Found existing installation: pip 9.0.0
Uninstalling pip-9.0.0:
  Successfully uninstalled pip-9.0.0
Successfully installed pip-9.0.1


But when I do "pip -V", it still using 8.1.1 as follows:
pip 8.1.1 from /usr/local/anaconda/lib/python2.7/site-packages (python 2.7)

when I do "which -a pip", it shows:
~/.conda/envs/py2713/bin/pip
/usr/local/anaconda/bin/pip
/usr/local/anaconda/bin/pip
/usr/bin/pip

But whichever I use, it all triggered the 8.8.1 version from
/usr/local/anaconda/lib/python2.7/site-packages

Just started anaconda, and any help is appreciated.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] help with macOS version 10.12.5

2017-07-10 Thread Carlton Banks
Have you tried brew install python3
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 3 taps (caskroom/cask, homebrew/core, homebrew/science).
==> Updated Formulae
berkeley-dbhomebrew/science/nco   percona-server
bitrisehugo   percona-server-mongodb
carthage   jhipster   percona-toolkit
clang-format   ldcpercona-xtrabackup
dbxml  mongodbstrongswan
exploitdb  paket  varnish@4
folly  pcre ✔ yadm

Error: python3 3.5.1 is already installed
To install 3.6.1, first run `brew unlink python3`
Error occurs on mine as i’ve already installed it..
> Den 10. jul. 2017 kl. 14.44 skrev maia fornaro via Tutor :
> 
> Hello, My name is maia and I'm train to install python 3 in my macOS  sierra 
> version 10.12.5 and I receive this error went i open python:
> 
> Python 3.6.1 (v3.6.1:69c0db5050, Mar 21 2017, 01:21:04) 
> [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
> Type "copyright", "credits" or "license()" for more information.
 WARNING: The version of Tcl/Tk (8.5.9) in use may be unstable.
> Visit http://www.python.org/download/mac/tcltk/ for current information.
> 
> I try to install another tcltk version but still have the same error, so I 
> will like for your help.
> Thanks !
> Maia 
> ___
> 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] help with macOS version 10.12.5

2017-07-10 Thread maia fornaro via Tutor
Hello, My name is maia and I'm train to install python 3 in my macOS  sierra 
version 10.12.5 and I receive this error went i open python:

Python 3.6.1 (v3.6.1:69c0db5050, Mar 21 2017, 01:21:04) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "copyright", "credits" or "license()" for more information.
>>> WARNING: The version of Tcl/Tk (8.5.9) in use may be unstable.
Visit http://www.python.org/download/mac/tcltk/ for current information.

I try to install another tcltk version but still have the same error, so I will 
like for your help.
Thanks !
Maia 
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] call key on_press event multiple times when key is held down

2017-07-10 Thread Carlton Banks
Thanks for the response :)
> Den 10. jul. 2017 kl. 10.54 skrev Peter Otten <__pete...@web.de>:
> 
> Carlton Banks wrote:
> 
>> So i tried a different solution, introducing two threads one handling the
>> keyboard, and the other one is a while true, that keeps running.
>> 
>> https://pastebin.com/U0WVQMYP 
>> 
>> but for some reason, am I constantly running into IOerror, hence
>> no frames is being recorded.  Any suggestion on why?
> 
> Please remember to always provide the traceback.
> 
There is no traceback, no error message besides the IOerror caught by the 
try/execpt. 

>> while True:
>>time.sleep(0.1)
>>if listener.key_pressed == True and started == False:
>>started = True
>>listener.stream.start_stream()
>>print "start Stream"
>> 
>>elif listener.key_pressed == False and started == True:
>>print "Something coocked"
>>listener.stream.stop_stream()
> 
> Did you get a non-empty output.wav?

The output.wav is empty

>>listener.stream.close()
> 
> you see the IOError on the second attempt to record something.

I see the IOerror while i have the key down,  not only on the first or second 
attempt..

>>p.terminate()

> As you are only prepared to record once and another record would overwrite 
> the file anyway (at least that's what I suppose
> 

currently I am trying to make one recording work like this,
but would like to have the functionality of keep generating different audio 
files,
with different utterances..
>>wf = wave.open(WAVE_OUTPUT_FILENAME, 'wb')
> 
> to do) perhaps you can omit the while-True loop altogether. Or you omit the 
> stream.close() call until after that loop (though there seems to be no way 
> to exit it cleanly at the moment).
> 
Not sure if that is the problem here… 
> Note that these are just ideas, I'm not familiar with pyaudio, or pynput, or 
> wave.
> 
And thanks for suggestioning them :)
>>wf.setnchannels(CHANNELS)
>>wf.setsampwidth(p.get_sample_size(FORMAT))
>>wf.setframerate(RATE)
>>wf.writeframes(b''.join(frames))
>>wf.close()
>> 
>>started = False
>> 
> 
> 
> ___
> 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] Fwd: Re: call key on_press event multiple times when key is held down

2017-07-10 Thread Alan Gauld via Tutor
On 04/07/17 13:45, Carlton Banks wrote:

> Any suggestion on any GUI solutions?

Here is a Tkinter solution that increments a counter
while the mouse button is pressed. It should give you the idea...
Obviously you need to replace the counter increment
with your desired processing. And the print statements
are just to show the events being processed.

##
import tkinter as tk

display = "count: "
flag = False
counter = 0

def do_down(e):
global flag
print('Key down')
flag = True
after_loop()

def do_up(e):
global flag
print('key up')
flag = False

def after_loop():
print('looping')
global counter
counter += 1
l['text'] = display +str(counter)
if flag:
   top.after(10,after_loop)


top = tk.Tk()
l = tk.Label(top,text=display+'0')
l.pack()
l.bind("",do_down)
l.bind("",do_up)
top.mainloop()

###

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] call key on_press event multiple times when key is held down

2017-07-10 Thread Peter Otten
Carlton Banks wrote:

> So i tried a different solution, introducing two threads one handling the
> keyboard, and the other one is a while true, that keeps running.
> 
> https://pastebin.com/U0WVQMYP 
> 
> but for some reason, am I constantly running into IOerror, hence
> no frames is being recorded.  Any suggestion on why?

Please remember to always provide the traceback.

> while True:
> time.sleep(0.1)
> if listener.key_pressed == True and started == False:
> started = True
> listener.stream.start_stream()
> print "start Stream"
> 
> elif listener.key_pressed == False and started == True:
> print "Something coocked"
> listener.stream.stop_stream()

Did you get a non-empty output.wav?

If yes, my guess is that you can record something the first time you press 
the key, and when you release it and close the audio input with

> listener.stream.close()

you see the IOError on the second attempt to record something.

> p.terminate()


As you are only prepared to record once and another record would overwrite 
the file anyway (at least that's what I suppose
 
> wf = wave.open(WAVE_OUTPUT_FILENAME, 'wb')

to do) perhaps you can omit the while-True loop altogether. Or you omit the 
stream.close() call until after that loop (though there seems to be no way 
to exit it cleanly at the moment).

Note that these are just ideas, I'm not familiar with pyaudio, or pynput, or 
wave.

> wf.setnchannels(CHANNELS)
> wf.setsampwidth(p.get_sample_size(FORMAT))
> wf.setframerate(RATE)
> wf.writeframes(b''.join(frames))
> wf.close()
> 
> started = False
> 




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


Re: [Tutor] call key on_press event multiple times when key is held down

2017-07-10 Thread Carlton Banks
So i tried a different solution, introducing two threads one handling the 
keyboard, 
and the other one is a while true, that keeps running. 

https://pastebin.com/U0WVQMYP 

but for some reason, am I constantly running into IOerror, hence 
no frames is being recorded.  Any suggestion on why?
> Den 4. jul. 2017 kl. 14.45 skrev Carlton Banks :
> 
>> 
>>> Interesting solution, but still find a bit "dirty hackish”
>>> to involve a timer in this..  I guess it just would be neat if 
>>> it just worked as i thought it to be.  But i guess i have to look into 
>>> curses.
>> 
>> A timer based loop is actually the standard pattern for
>> implementing a loop in an event driven environment (the
>> main alternative is to launch a background thread).
>> It's how most GUIs handle such scenarios.
>> 
>> The problem in a CLI solution is that you have to build your
>> own timer event system (usually based on time.sleep() or
>> similar). Hence the suggestion to use a GUI.
>> 
> 
> Any suggestion on any GUI solutions?
> 
> 
> Regards 
> Carl
> 

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