python module install manully
I have a module insteon.py what I need to install manually because it is not in the python index packages. I copied the module in /usr/lib/python2.7/dist-packages and /usr/local/lib/python2.7/dist-packages. When I try to import the module insteon.py I get this error: Does someone knows what the problem can be. Traceback (most recent call last): File "main.py", line 15, in from insteon import Insteon File "/usr/lib/python2.7/dist-packages/insteon.py", line 25, in config = configuration.loadConfig() AttributeError: Configuration instance has no attribute 'loadConfig' -- https://mail.python.org/mailman/listinfo/python-list
newsreader pan could not find my post
Hello, I post a message in comp.lang python, but with caching new articles in the newsreader pan I don't see my article. How can I contact the administrater or this group. Thanks -- https://mail.python.org/mailman/listinfo/python-list
online python courses
I am follows on this moment two online pythoncourses from code.tutsplus.com But I am interested in following more online pythoncourses. Maby someone have some links to websites for me what handles python online courses. thanks -- https://mail.python.org/mailman/listinfo/python-list
GoPiGo distence sensor
I have a small robot on wheels named the GoPiGo. What I want is if the distence sensor read the same distence for let say 5 seconds then the GoPiGo go's backward. But I don't now how to program this in python. The Api functions for the GoPiGo are here: http://www.dexterindustries.com/GoPiGo/programming/python-programming-for-the-raspberry-pi-gopigo/ Can someone help me with this. -- https://mail.python.org/mailman/listinfo/python-list
pocketsphinx no module named pocketsphinx found
I try to run an example python file for pocketsphinx but I get this error: File "continuous_test.py", line 5, in from pocketsphinx.pocketsphinx import * ImportError: No module named pocketsphinx Does somebody knows how to repair this. -- https://mail.python.org/mailman/listinfo/python-list
Re: pocketsphinx no module named pocketsphinx found
Op dinsdag 12 juli 2016 10:00:51 UTC+2 schreef ldomp...@casema.nl: > I try to run an example python file for pocketsphinx but I get this error: > > File "continuous_test.py", line 5, in > from pocketsphinx.pocketsphinx import * > ImportError: No module named pocketsphinx > > Does somebody knows how to repair this. I think that pocketsphinx installed successfully because I install it on my raspberry pi with sudo-apt-get How can I create a module named pocketsphinx.py to try out the library. Thanks -- https://mail.python.org/mailman/listinfo/python-list
Re: pocketsphinx no module named pocketsphinx found
Op dinsdag 12 juli 2016 10:00:51 UTC+2 schreef ldomp...@casema.nl: > I try to run an example python file for pocketsphinx but I get this error: > > File "continuous_test.py", line 5, in > from pocketsphinx.pocketsphinx import * > ImportError: No module named pocketsphinx > > Does somebody knows how to repair this. I had python version 2.6 3.0 3.4 installed and removed. I reinstall pocketsphinx python and now I don't get any errors while import from pocketsphinx. So I tried to run some python examples and now I get this error. I don't have a clue whats coing on. INFO: feat.c(715): Initializing feature stream to type: '1s_c_d_dd', ceplen=13, CMN='live', VARNORM='no', AGC='none' INFO: cmn.c(97): mean[0]= 12.00, mean[1..12]= 0.0 ERROR: "acmod.c", line 83: Folder 'pocketsphinx/model/en-us/en-us' does not contain acoustic model definition 'mdef' Traceback (most recent call last): File "example.py", line 15, in decoder = Decoder(config) File "/usr/local/lib/python2.7/dist-packages/pocketsphinx/pocketsphinx.py", line 271, in __init__ this = _pocketsphinx.new_Decoder(*args) RuntimeError: new_Decoder returned -1 -- https://mail.python.org/mailman/listinfo/python-list
Re: pocketsphinx no module named pocketsphinx found
Op dinsdag 12 juli 2016 10:00:51 UTC+2 schreef ldomp...@casema.nl: > I try to run an example python file for pocketsphinx but I get this error: > > File "continuous_test.py", line 5, in > from pocketsphinx.pocketsphinx import * > ImportError: No module named pocketsphinx > > Does somebody knows how to repair this. I work it out with importing pocketsphinx and sphinxbase but I have an other error: Traceback (most recent call last): File "", line 1, in ImportError: No module named Decoder Is there a way to download the module Decoder somewhere? -- https://mail.python.org/mailman/listinfo/python-list
SyntaxError: Non-ASCII character
I copy this script from the magpi but when I run this script I get this error: SyntaxError: Non-ASCII character '\xe2' in file sound.py on line 32, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details Below is the eamplescript. What is wrong with this script. # You need to import the pyaudio module import pyaudio # First, we will listen # We need to set some parameters # Buffer chunk size in bytes CHUNK = 1024 # The audio format FORMAT = pyaudio.paInt16 # The number of channels to record on CHANNELS = 2 # The sample rate, 44.1KHz RATE = 44100 # The number of seconds to record for RECORD_SECS = 5 # Next, we create a PyAudio object p = pyaudio.PyAudio() # We need a stream to record from stream = p.open(format=FORMAT, channels=CHANNELS, rate=RATE, input=TRUE, frames_per_buffer=CHUNK) # We can now record into a temporary buffer frames = [] for i in range(0, int(RATE / CHUNK * RECORD_SECS)): data = stream.read(CHUNK) frames.append(data) # We can now shut everything down stream.stop_stream() stream.close() p.terminate() # If we want to play a wave file, we will need the wave module import wave # We can open it, give a filename wf = wave.open(“test.wav”, “rb”) # We need a new PyAudio object p = pyaudio.PyAudio() # We will open a stream, using the settings from the wave file stream = p.open(format=p.get_format_from_width(wf.getsampwidth()), channels=wf.getnchannels(), rate=wf.getframerate(), output=True) # We can now read from the file and play it out data = wf.readframes(CHUNK) while data != ‘’: stream.write(data) data = wf.readframes(CHUNK) # Don’t forget to shut everything down again stream.stop_stream() stream.close() p.terminate() -- https://mail.python.org/mailman/listinfo/python-list
Re: SyntaxError: Non-ASCII character
Op zondag 17 juli 2016 11:19:32 UTC+2 schreef ldomp...@casema.nl: > I copy this script from the magpi but when I run this script I get this > error: > SyntaxError: Non-ASCII character '\xe2' in file sound.py on line 32, but no > encoding declared; see http://python.org/dev/peps/pep-0263/ for details > > Below is the eamplescript. What is wrong with this script. > > > # You need to import the pyaudio module > import pyaudio > # First, we will listen > # We need to set some parameters > # Buffer chunk size in bytes > CHUNK = 1024 > # The audio format > FORMAT = pyaudio.paInt16 > # The number of channels to record on > CHANNELS = 2 > # The sample rate, 44.1KHz > RATE = 44100 > # The number of seconds to record for > RECORD_SECS = 5 > # Next, we create a PyAudio object > p = pyaudio.PyAudio() > # We need a stream to record from > stream = p.open(format=FORMAT, channels=CHANNELS, > rate=RATE, input=TRUE, frames_per_buffer=CHUNK) > # We can now record into a temporary buffer > frames = [] > for i in range(0, int(RATE / CHUNK * RECORD_SECS)): > data = stream.read(CHUNK) > frames.append(data) > # We can now shut everything down > stream.stop_stream() > stream.close() > p.terminate() > # If we want to play a wave file, we will need the wave module > import wave > # We can open it, give a filename > wf = wave.open(“test.wav”, “rb”) > # We need a new PyAudio object > p = pyaudio.PyAudio() > # We will open a stream, using the settings from the wave file > stream = p.open(format=p.get_format_from_width(wf.getsampwidth()), > channels=wf.getnchannels(), rate=wf.getframerate(), > output=True) > # We can now read from the file and play it out > data = wf.readframes(CHUNK) > while data != ‘’: > stream.write(data) > data = wf.readframes(CHUNK) > # Don’t forget to shut everything down again > stream.stop_stream() > stream.close() > p.terminate() I installed python 3.4 and set my python path to PYTONPATH:/usr/bin/python3.4 When I try to import pyaudio then I get this error: Python 3.4.2 (default, Oct 19 2014, 13:31:11) [GCC 4.9.1] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import pyaudio Traceback (most recent call last): File "", line 1, in ImportError: No module named 'pyaudio' Do I have to set a path also for to find the modules -- https://mail.python.org/mailman/listinfo/python-list
Re: SyntaxError: Non-ASCII character
Op zondag 17 juli 2016 11:19:32 UTC+2 schreef ldomp...@casema.nl: > I copy this script from the magpi but when I run this script I get this > error: > SyntaxError: Non-ASCII character '\xe2' in file sound.py on line 32, but no > encoding declared; see http://python.org/dev/peps/pep-0263/ for details > > Below is the eamplescript. What is wrong with this script. > > > # You need to import the pyaudio module > import pyaudio > # First, we will listen > # We need to set some parameters > # Buffer chunk size in bytes > CHUNK = 1024 > # The audio format > FORMAT = pyaudio.paInt16 > # The number of channels to record on > CHANNELS = 2 > # The sample rate, 44.1KHz > RATE = 44100 > # The number of seconds to record for > RECORD_SECS = 5 > # Next, we create a PyAudio object > p = pyaudio.PyAudio() > # We need a stream to record from > stream = p.open(format=FORMAT, channels=CHANNELS, > rate=RATE, input=TRUE, frames_per_buffer=CHUNK) > # We can now record into a temporary buffer > frames = [] > for i in range(0, int(RATE / CHUNK * RECORD_SECS)): > data = stream.read(CHUNK) > frames.append(data) > # We can now shut everything down > stream.stop_stream() > stream.close() > p.terminate() > # If we want to play a wave file, we will need the wave module > import wave > # We can open it, give a filename > wf = wave.open(“test.wav”, “rb”) > # We need a new PyAudio object > p = pyaudio.PyAudio() > # We will open a stream, using the settings from the wave file > stream = p.open(format=p.get_format_from_width(wf.getsampwidth()), > channels=wf.getnchannels(), rate=wf.getframerate(), > output=True) > # We can now read from the file and play it out > data = wf.readframes(CHUNK) > while data != ‘’: > stream.write(data) > data = wf.readframes(CHUNK) > # Don’t forget to shut everything down again > stream.stop_stream() > stream.close() > p.terminate() I hate it to ask you again but I really want that this script going to work. And I use the raspberry pi for it. I also get a lot off alsa errors on my screen so I don't no if that result in this error: Traceback (most recent call last): File "sound.py", line 19, in rate=RATE, input=TRUE, frames_per_buffer=CHUNK) NameError: name 'TRUE' is not defined -- https://mail.python.org/mailman/listinfo/python-list
Re: SyntaxError: Non-ASCII character
Op zondag 17 juli 2016 11:19:32 UTC+2 schreef ldomp...@casema.nl: > I copy this script from the magpi but when I run this script I get this > error: > SyntaxError: Non-ASCII character '\xe2' in file sound.py on line 32, but no > encoding declared; see http://python.org/dev/peps/pep-0263/ for details > > Below is the eamplescript. What is wrong with this script. > > > # You need to import the pyaudio module > import pyaudio > # First, we will listen > # We need to set some parameters > # Buffer chunk size in bytes > CHUNK = 1024 > # The audio format > FORMAT = pyaudio.paInt16 > # The number of channels to record on > CHANNELS = 2 > # The sample rate, 44.1KHz > RATE = 44100 > # The number of seconds to record for > RECORD_SECS = 5 > # Next, we create a PyAudio object > p = pyaudio.PyAudio() > # We need a stream to record from > stream = p.open(format=FORMAT, channels=CHANNELS, > rate=RATE, input=TRUE, frames_per_buffer=CHUNK) > # We can now record into a temporary buffer > frames = [] > for i in range(0, int(RATE / CHUNK * RECORD_SECS)): > data = stream.read(CHUNK) > frames.append(data) > # We can now shut everything down > stream.stop_stream() > stream.close() > p.terminate() > # If we want to play a wave file, we will need the wave module > import wave > # We can open it, give a filename > wf = wave.open(“test.wav”, “rb”) > # We need a new PyAudio object > p = pyaudio.PyAudio() > # We will open a stream, using the settings from the wave file > stream = p.open(format=p.get_format_from_width(wf.getsampwidth()), > channels=wf.getnchannels(), rate=wf.getframerate(), > output=True) > # We can now read from the file and play it out > data = wf.readframes(CHUNK) > while data != ‘’: > stream.write(data) > data = wf.readframes(CHUNK) > # Don’t forget to shut everything down again > stream.stop_stream() > stream.close() > p.terminate() When I change input=True instead than I get a lot of errors: Traceback (most recent call last): File "sound.py", line 19, in rate=RATE, input=True, frames_per_buffer=CHUNK) File "/usr/lib/python3/dist-packages/pyaudio.py", line 747, in open stream = Stream(self, *args, **kwargs) File "/usr/lib/python3/dist-packages/pyaudio.py", line 442, in __init__ self._stream = pa.open(**arguments) OSError: [Errno Invalid number of channels] -9998 I don't think we can solve those errors Anyway thanks for helping me out so far. -- https://mail.python.org/mailman/listinfo/python-list
my first script for the GoPiGo
I want that this script runs to times from the upper line to the buttom line. I tried with for x in range(2): but that didn't work The GoPiGo is a small robot on wheels. The API codes are here: http://www.dexterindustries.com/GoPiGo/programming/python-programming-for-the- raspberry-pi-gopigo/ from gopigo import * import time for x in range (2): mindist = 70 servo(120) time.sleep(2) fwd() stop() time.sleep(2) bwd() stop() if mindist > us_dist(15): bwd() stop print x -- - --- -- - Posted with NewsLeecher v7.0 Beta 2 Web @ http://www.newsleecher.com/?usenet --- - -- - -- https://mail.python.org/mailman/listinfo/python-list
Re: my first script for the GoPiGo
In reply to "MRAB" who wrote the following: > On 2015-10-22 16:07, input/ldompel...@casema.nl wrote: > > I want that this script runs to times from the upper line to the buttom > > line. > > I tried with for x in range(2): but that didn't work > > You say "didn't work", but in what way didn't it work? > > > The GoPiGo is a small robot on wheels. > > > > The API codes are here: > > http://www.dexterindustries.com/GoPiGo/programming/ > > python-programming-for-the- > > raspberry-pi-gopigo/ > > > > > > from gopigo import * > > import time > > Thanks or the reply. I mean that i want this script running two times. So the first line is mindist = 70 And the last line is print x And that two times So that the robut continues moving two times in this script, from the upperline to the bottum line two times. > > for x in range (2): > > The lines to be repeated should be indented more than the 'for' line. > > > mindist = 70 > > servo(120) > > time.sleep(2) > > fwd() > > stop() > > time.sleep(2) > > bwd() > > stop() > > if mindist > us_dist(15): > > bwd() > > stop > > print x > > -- - --- -- - Posted with NewsLeecher v7.0 Beta 2 Web @ http://www.newsleecher.com/?usenet --- - -- - -- https://mail.python.org/mailman/listinfo/python-list
Re: GoPiGo script
I intended the rules under while True: The script is working now only the wheels go's only forward "(fwd)",so the sensor not detect any obstacles.(sensor=us_dist(15). --- from gopigo import * import time set_right_speed(150) set_left_speed(105) while True: #def test(): enable_servo() mindist = 80 servo(90) fwd() print ("forward1x") #time.sleep(5) #stop() if mindist > us_dist(15): #enc_tgt(1,1,72) bwd() print ("backward1x",us_dist(15)) time.sleep(2) left_rot() print("left rot",us_dist(15)) time.sleep(3) stop() if mindist < us_dist(15): #enc_tgt(1,1,72) fwd() print("forward2x",us_dist(15)) time.sleep(2) stop() for x in range(3): if mindist > us_dist(15): bwd() print("backward2x",us_dist(15)) In reply to "hakugin@gmail.com" who wrote the following: > On Friday, October 30, 2015 at 2:19:21 PM UTC-4, input/ld...@casema.nl wrot= > e: > > Thank you or the reply. > > This is the errorwith while True: > > =20 > > File "test03.py", line 10 > > enable_servo() > > =20 > > =20 > > In reply to "haku...@gmail.com" who wrote the following: > > =20 > > > On Friday, October 30, 2015 at 12:58:43 PM UTC-4, input/ld...@casema.nl= > =20 > > wrote: > > > > The GoPiGo is a little robot on wheels. > > > > =20 > > > > > > enable_servo() > > > If it is returning an error with "enable_servo()" then there are a few poss= > ible causes. I would make sure everything is indented correctly, as well as= > check and ensure the function is in the gopigo library. Those would be the= > 2 most likely causes. As for the issue with the while loop, I would defini= > tely follow Peter's advice. I started to create a small example script but = > found that what I classify as simple may not be as simple for others, but I= > will do my best to get something done over the weekend if you haven't foun= > d a solution by Monday. -- - --- -- - Posted with NewsLeecher v7.0 Beta 2 Web @ http://www.newsleecher.com/?usenet --- - -- - -- https://mail.python.org/mailman/listinfo/python-list
Re: GoPiGo script
> The body of the 'while' loop extends from the line: > > enable_servo() > > to the line: > > print ("forward1x") > > Would that explain it? When i run this scipt its only print a lot off print1x. Do you mean that ? Thanks In reply to "MRAB" who wrote the following: > On 2015-10-31 10:28, input/ldompel...@casema.nl wrote: > > I intended the rules under while True: > > The script is working now only the wheels go's only forward "(fwd)",so the > > sensor not detect any obstacles.(sensor=us_dist(15). > > > > > > --- > > > > from gopigo import * > > import time > > > > > > set_right_speed(150) > > set_left_speed(105) > > > The body of the 'while' loop extends from the line: > > enable_servo() > > to the line: > > print ("forward1x") > > Would that explain it? > > > while True: > > #def test(): > > enable_servo() > > mindist = 80 > > servo(90) > > fwd() > > print ("forward1x") > > #time.sleep(5) > > #stop() > > > > if mindist > us_dist(15): > > #enc_tgt(1,1,72) > > bwd() > > print ("backward1x",us_dist(15)) > > time.sleep(2) > > left_rot() > > print("left rot",us_dist(15)) > > time.sleep(3) > > stop() > > > > if mindist < us_dist(15): > > #enc_tgt(1,1,72) > > fwd() > > print("forward2x",us_dist(15)) > > time.sleep(2) > > stop() > > > > for x in range(3): > > > > if mindist > us_dist(15): > > bwd() > > print("backward2x",us_dist(15)) > > -- - --- -- - Posted with NewsLeecher v7.0 Beta 2 Web @ http://www.newsleecher.com/?usenet --- - -- - -- https://mail.python.org/mailman/listinfo/python-list
Re: GoPiGo script
> It does not only print; it also calls enable_servo, servo and fwd > repeatedly. > Then I am misinformed, because someone told me in this group to use while True: Is there another function that I can use for to restart this script? Thanks In reply to "MRAB" who wrote the following: > On 2015-10-31 18:59, input/ldompel...@casema.nl wrote: > > > The body of the 'while' loop extends from the line: > > > > > > enable_servo() > > > > > > to the line: > > > > > > print ("forward1x") > > > > > > Would that explain it? > > > > When i run this scipt its only print a lot off print1x. > > Do you mean that ? > > > It does not only print; it also calls enable_servo, servo and fwd > repeatedly. > > > > > In reply to "MRAB" who wrote the following: > > > > > On 2015-10-31 10:28, input/ldompel...@casema.nl wrote: > > > > I intended the rules under while True: > > > > The script is working now only the wheels go's only forward "(fwd)",so > > > > the > > > > sensor not detect any obstacles.(sensor=us_dist(15). > > > > > > > > > > > > > > --- > > > > > > > > from gopigo import * > > > > import time > > > > > > > > > > > > set_right_speed(150) > > > > set_left_speed(105) > > > > > > > The body of the 'while' loop extends from the line: > > > > > > enable_servo() > > > > > > to the line: > > > > > > print ("forward1x") > > > > > > Would that explain it? > > > > > > > while True: > > > > #def test(): > > > > enable_servo() > > > > mindist = 80 > > > > servo(90) > > > > fwd() > > > > print ("forward1x") > > > > #time.sleep(5) > > > > #stop() > > > > > > > > if mindist > us_dist(15): > > > > #enc_tgt(1,1,72) > > > > bwd() > > > > print ("backward1x",us_dist(15)) > > > > time.sleep(2) > > > > left_rot() > > > > print("left rot",us_dist(15)) > > > > time.sleep(3) > > > > stop() > > > > > > > > if mindist < us_dist(15): > > > > #enc_tgt(1,1,72) > > > > fwd() > > > > print("forward2x",us_dist(15)) > > > > time.sleep(2) > > > > stop() > > > > > > > > for x in range(3): > > > > > > > > if mindist > us_dist(15): > > > > bwd() > > > > print("backward2x",us_dist(15)) > > > > -- - --- -- - Posted with NewsLeecher v7.0 Beta 2 Web @ http://www.newsleecher.com/?usenet --- - -- - -- https://mail.python.org/mailman/listinfo/python-list
Re: GoPiGo script
I tried to use def loop(): now for to restart the script. but its only restart "fwd()" print ("forward 1x") and then stop. It does not look further for the if function. Is there another way to restart this script ? I also tried with (while True:) but that does nothing. Thanks --- from gopigo import * import time set_right_speed(150) set_left_speed(105) enable_servo mindist = 80 servo(90) def loop(): fwd() print ("forward 1x") time.sleep(2) stop() if mindist > us_dist(15): bwd() print ("backward 1x",us_dist(15)) time.sleep(2) left_rot() print("left rot",us_dist(15)) time.sleep(3) stop() if mindist < us_dist(15): fwd() print("forward 2x",us_dist(15)) time.sleep(2) stop() #for x in range(3): if mindist > us_dist(15): bwd() print("backward 2x",us_dist(15)) time.sleep(2) stop() right() else: fwd() print("forward else",us_dist(15)) time.sleep(4) stop() if mindist > us_dist(15): bwd() print("backward 3x") time.sleep(2) stop() left_rot() print("left rot") time.sleep(1) stop() mindist = 80 loop() In reply to "Peter Pearson" who wrote the following: > On Fri, 30 Oct 2015 16:58:16 GMT, input/ldompel...@casema.nl wrote: > > The GoPiGo is a little robot on wheels. > > > > I want that this script restart when its ends. > > I tried with "while True"and"return"and also "continue" > > But those functions gives me errors. > > What for function else can I use to restart this script. > > > [snip] > > > > from gopigo import * > > import time > > > > > > set_right_speed(150) > > set_left_speed(105) > > > > while True: > > Is this the "while True" that gave you errors? I think it > should, since a "while" should be followed by an indented block > of code. Perhaps you should use this "while True" to replace > the "for x in range(3)" near the bottom. > > > #def test(): > > enable_servo() > > mindist = 80 > > servo(90) > > fwd()#wheels go forward > > print ("forward1x") > > #time.sleep(5) > > #stop() > > > > if mindist > us_dist(15): > > #enc_tgt(1,1,72) > > bwd()#wheels go backward > > print ("backward1x",us_dist(15)) > > time.sleep(2) > > left_rot()#wheels rotate left > > print("left rot",us_dist(15)) > > time.sleep(3) > > stop() > > > > if mindist < us_dist(15): > >#enc_tgt(1,1,72) > > fwd()#wheels go forward > > print("forward2x",us_dist(15)) > > time.sleep(2) > > stop() > > > > for x in range(3): > > > > if mindist > us_dist(15): > > bwd()#wheels go backward > > print("backward2x",us_dist(15)) > > In future questions, it might help if you explained which of these > print statements you would like to see executed how many times. > > -- > To email me, substitute nowhere->runbox, invalid->com. -- - --- -- - Posted with NewsLeecher v7.0 Beta 2 Web @ http://www.newsleecher.com/?usenet --- - -- - -- https://mail.python.org/mailman/listinfo/python-list
Re: GoPiGo script
He mike, Thank you or making this script. Only I get errors for sleep. I also tried to change it to time.sleep() but that also gives errors. File "test05.py", line 23 sleep(2) ^ SyntaxError: invalid syntax --- In reply to "hakugin@gmail.com" who wrote the following: > On Monday, November 2, 2015 at 8:45:35 AM UTC-5, hakug...@gmail.com wrote: > > On Monday, November 2, 2015 at 8:29:26 AM UTC-5, input/ld...@casema.nl > > wrote: > > > I tried to use def loop(): now for to restart the script. > > > but its only restart "fwd()" print ("forward 1x") and then stop. > > > It does not look further for the if function. > > > Is there another way to restart this script ? > > > I also tried with (while True:) but that does nothing. > > > > > > Thanks > > > > > > > > Ignore that last suggestion... between auto correct and other things there are > some issues with it. > > Try this instead: > > from gopigo import * > from time import sleep > > # Boolean variable for the "while" loop > KEEP_GOING = True > > enable_servo() > mindist = 80 > servo(90) > > set_right_speed(150) > set_left_speed(105) > > def MainLoop(): > # A check statement can be added to set KEEP_GOING to False > # and allow the function to end > while KEEP_GOING: > fwd() > print("forward1x") > if mindist > us_dist(15): > bwd() > print("backward1x",us_dist(15) > sleep(2) > left_rot() > print("left rot",us_dist(15)) > sleep(3) > stop() > if mindist < us_dist(15): > fwd() > print("forward2x",us_dist(15)) > time.sleep(2) > stop() > > # This is a simple check to determine if the script was run by itself > # or if it was imported by another script. If it was imported it will > # fail this check and not run the code but will allow access to the > # function defined above. > if __name__ == '__main__': > MainLoop() > > - Mike -- - --- -- - Posted with NewsLeecher v7.0 Beta 2 Web @ http://www.newsleecher.com/?usenet --- - -- - -- https://mail.python.org/mailman/listinfo/python-list
Re: GoPiGo script
Thank you for the explanation for it. I must tell you that i yust beginning with python. I bought the book beginning programming with python. In reply to "Dennis Lee Bieber" who wrote the following: > On Mon, 02 Nov 2015 13:29:04 GMT, input/ldompel...@casema.nl declaimed the > following: > > > I tried to use def loop(): now for to restart the script. > > but its only restart "fwd()" print ("forward 1x") and then stop. > > > def loop(): > >fwd() > >print ("forward 1x") > >time.sleep(2) > >stop() > > > > if mindist > us_dist(15): > > Which is exactly what you told it to do. You have defined a function > containing four statements: fwd(), print(), sleep(), and stop(); after > executing the stop the function will return to where it was called -- the > end of your program. > > All of your"if" statements will be executed after "loop" is defined > (but not executed) and before the call to "loop" at the bottom. They are > NOT part of "loop". Please reread the Python language reference manual, > focusing on the part that describes indentation and block structuring. > > > > loop() > > > > Also, just calling something "loop" does not make it a loop. This > function will be called just one time and then the program will exit. > -- > Wulfraed Dennis Lee Bieber AF6VN > wlfr...@ix.netcom.comHTTP://wlfraed.home.netcom.com/ -- - --- -- - Posted with NewsLeecher v7.0 Beta 2 Web @ http://www.newsleecher.com/?usenet --- - -- - -- https://mail.python.org/mailman/listinfo/python-list
raw_input and break
I have an continues loop with "while True:" Now I want to use "raw_input" and when I press "s" on the keybord that it will "break" the continues loop. I tried: choices = raw_input if choises == s: break But even when I not press "s" it "break" I want that I not press "s" the script continues. Any ideas ? Thanks -- - --- -- - Posted with NewsLeecher v7.0 Beta 2 Web @ http://www.newsleecher.com/?usenet --- - -- - -- https://mail.python.org/mailman/listinfo/python-list
Re: raw_input and break
In reply to "Joel Goldstick" who wrote the following: > On Wed, Nov 4, 2015 at 4:44 PM, wrote: > > > I have an continues loop with "while True:" > > Now I want to use "raw_input" and when I press "s" on the keybord that it > > will > > "break" the continues loop. > > > > I tried: > > choices = raw_input > > if choises == s: > > break > > You need to quote the s: > if choices == 's' I quote the s, but its still break even when I not press the s. -- >But even when I not press "s" it "break" > > I want that I not press "s" the script continues. > > > > Any ideas ? > > > > You need to quote the s: > if choices == 's' > > you need to check your spelling -- you have choices and choises > > You need to indent break 4 spaces > > > > > Thanks > > > > > > > > -- > > - --- -- - > > Posted with NewsLeecher v7.0 Beta 2 > > Web @ http://www.newsleecher.com/?usenet > > --- - -- - > > > > -- > > https://mail.python.org/mailman/listinfo/python-list > > > > > > -- > Joel Goldstick > http://joelgoldstick.com/stats/birthdays -- - --- -- - Posted with NewsLeecher v7.0 Beta 2 Web @ http://www.newsleecher.com/?usenet --- - -- - -- https://mail.python.org/mailman/listinfo/python-list
Re: raw_input and break
In reply to "tian.su.y...@gmail.com" who wrote the following: > =E5=9C=A8 2015=E5=B9=B411=E6=9C=884=E6=97=A5=E6=98=9F=E6=9C=9F=E4=B8=89 UTC= > -6=E4=B8=8B=E5=8D=883:45:09=EF=BC=8Cinput/ld...@casema.nl=E5=86=99=E9=81=93= > =EF=BC=9A > > I have an continues loop with "while True:" > > Now I want to use "raw_input" and when I press "s" on the keybord that it= > will=20 > > "break" the continues loop. In this script it always break even when I not press 's' I want that this script go's to if mindist > us_dist(15): And when I press 's' its stop. Any ideas ? while True: enable_servo() servo(90) mindist = 80 choices = input("letter s to stop:") if choices == 's': print ("stop") break if mindist > us_dist(15): bwd() print ("backward 1x") > > =20 > > I tried: > > choices =3D raw_input > > if choises =3D=3D s: > > break > > =20 > > But even when I not press "s" it "break" > > I want that I not press "s" the script continues. > > =20 > > Any ideas ? > > =20 > > Thanks > > =20 > > =20 > > =20 > > --=20 > > - --- -- - > > Posted with NewsLeecher v7.0 Beta 2 > > Web @ http://www.newsleecher.com/?usenet > > --- - -- - > > while True: > inp =3D input("Enter whatever you want, letter 's' to stop: ") > if inp =3D=3D 's': > print("Program stopped.") > break > print("You just entered:", inp) > > Is this along the line that you are thinking? As pointed out earlier, it wi= > ll be much easier for people to help if you can share the exact code you pu= > t into and the error messages as well. Thanks and good luck! > All the best, > Tian -- - --- -- - Posted with NewsLeecher v7.0 Beta 2 Web @ http://www.newsleecher.com/?usenet --- - -- - -- https://mail.python.org/mailman/listinfo/python-list
Re: raw_input and break
In reply to "Peter Otten" who wrote the following: > input/ldompel...@casema.nl wrote: > > > while True: > > enable_servo() > > servo(90) > > mindist = 80 > > choices = input("letter s to stop:") > > if choices == 's': > > print ("stop") > > break > > if mindist > us_dist(15): >In this particular case the problem is that you are using Python 2 where >input() tries to execute the text the user enters as Python code. >Tian's example code assumes Python 3. >To fix your problem replace the line > choices = input("letter s to stop:") >in your script with > choices = raw_input("letter s to stop:") Oh no, this is not what I want. Now it is waiting for input when its go further with the script. Because I have an while True: so I want that the script go's continue only when I press a key then it must stop the script. Thanks -- > > bwd() > > print ("backward 1x") > > > In this script it always break even when I not press 's' > > I want that this script go's to if mindist > us_dist(15): > > And when I press 's' its stop. > > > > Any ideas ? > > Does it print something like > > Traceback (most recent call last): > File "", line 1, in > File "", line 0 > > ^ > SyntaxError: unexpected EOF while parsing > > when it stops? This is called a "traceback" and you should always include it > in your post when you need help with an error in your script. > > In this particular case the problem is that you are using Python 2 where > input() tries to execute the text the user enters as Python code. > > Tian's example code assumes Python 3. > > To fix your problem replace the line > > choices = input("letter s to stop:") > > in your script with > > choices = raw_input("letter s to stop:") -- - --- -- - Posted with NewsLeecher v7.0 Beta 2 Web @ http://www.newsleecher.com/?usenet --- - -- - -- https://mail.python.org/mailman/listinfo/python-list
Re: raw_input and break
In reply to "Peter Otten" who wrote the following: > input/ldompel...@casema.nl wrote: > > > > choices = raw_input("letter s to stop:") > > > > Oh no, this is not what I want. Now it is waiting for input when its go > > further with the script. Because I have an while True: so I want that the > > script go's continue only when I press a key then it must stop the script. > > Solutions to that problem are OS-dependent. For Unix terminals > > https://docs.python.org/2/faq/ > library.html#how-do-i-get-a-single-keypress-at-a-time > > shows one way which I used to write the contextmanager below: > > $ cat capture_key.py > import termios, fcntl, sys, os > > from contextlib import contextmanager > > > @contextmanager > def nonblocking(stdin=None): > if stdin is None: > stdin = sys.stdin > > fd = sys.stdin.fileno() > > oldterm = termios.tcgetattr(fd) > newattr = termios.tcgetattr(fd) > newattr[3] = newattr[3] & ~termios.ICANON & ~termios.ECHO > termios.tcsetattr(fd, termios.TCSANOW, newattr) > > oldflags = fcntl.fcntl(fd, fcntl.F_GETFL) Thanks for the reply. Is there no easy way to do so in python ? I am using the raspberry pi with Wheezy and for the robot the GoPiGo which is connected on the raspberry pi. The GoPiGo board has his own code like: fwd()="forward" bwd()="backward" right()="right" left="left" and so on. I am just a dummie with python. Thanks -- > fcntl.fcntl(fd, fcntl.F_SETFL, oldflags | os.O_NONBLOCK) > def read(n): > try: > return stdin.read(n) > except IOError: > return "" > try: > yield read > finally: > termios.tcsetattr(fd, termios.TCSAFLUSH, oldterm) > fcntl.fcntl(fd, fcntl.F_SETFL, oldflags) > > > Put the capture_key.py module into the same folder as your script and use it > like in the demo below: > > from capture_key import nonblocking > > # put your code here > > with nonblocking() as read: > print("letter s to stop:") > while True: > enable_servo() > servo(90) > mindist = 80 > choices = read(1) > if choices == 's': > print("stop") > break > if mindist > us_dist(15): > bwd() > print("backward 1x") -- - --- -- - Posted with NewsLeecher v7.0 Beta 2 Web @ http://www.newsleecher.com/?usenet --- - -- - -- https://mail.python.org/mailman/listinfo/python-list
Re: raw_input and break
>The code in capture_key.py may look a bit scary, but just as I took it >without bothering the details you can take the resulting module without >caring about the code in it. Alternatively you can search >https://pypi.python.org Thanks for the link. I realy appreciate it. Can you also tell me what I am looking for in https://pypi.python.org for a result. Thanks In reply to "Peter Otten" who wrote the following: > input/ldompel...@casema.nl wrote: > > > In reply to "Peter Otten" who wrote the following: > > > > > input/ldompel...@casema.nl wrote: > > > > > > > > choices = raw_input("letter s to stop:") > > > > > > > > Oh no, this is not what I want. Now it is waiting for input when its go > > > > further with the script. Because I have an while True: so I want that > > > > the script go's continue only when I press a key then it must stop the > > > > script. > > > > > > Solutions to that problem are OS-dependent. For Unix terminals > > > > > > https://docs.python.org/2/faq/ > > > library.html#how-do-i-get-a-single-keypress-at-a-time > > > > > > shows one way which I used to write the contextmanager below: > > > > > > $ cat capture_key.py > > > import termios, fcntl, sys, os > > > > > > from contextlib import contextmanager > > > > > > @contextmanager > > > def nonblocking(stdin=None): > > > if stdin is None: > > > stdin = sys.stdin > > > > > > fd = sys.stdin.fileno() > > > > > > oldterm = termios.tcgetattr(fd) > > > newattr = termios.tcgetattr(fd) > > > newattr[3] = newattr[3] & ~termios.ICANON & ~termios.ECHO > > > termios.tcsetattr(fd, termios.TCSANOW, newattr) > > > > > > oldflags = fcntl.fcntl(fd, fcntl.F_GETFL) > > Thanks for the reply. Is there no easy way to do so in python ? > > If you are asking for a ready-made function in the standard library, I don't > know one and I don't think there is one (there are recipes that work on top > of curses though). > > > I am using the raspberry pi with Wheezy and for the robot the GoPiGo which > > is connected on the raspberry pi. The GoPiGo board has his own code like: > > fwd()="forward" bwd()="backward" right()="right" left="left" and so on. I > > am just a dummie with python. > > The code in capture_key.py may look a bit scary, but just as I took it > without bothering the details you can take the resulting module without > caring about the code in it. Alternatively you can search > > https://pypi.python.org > > for a solution that you prefer. -- - --- -- - Posted with NewsLeecher v7.0 Beta 2 Web @ http://www.newsleecher.com/?usenet --- - -- - -- https://mail.python.org/mailman/listinfo/python-list
Re: raw_input and break
Oke, lets try your code.Can you help me with that. This is my code: - from gopigo import * import time set_right_speed(150) set_left_speed(105) enable_servo() fwd() print("forward 1x") time.sleep(4) stop() while True: servo(90) mindist = 80 if mindist > us_dist(15): bwd() print ("backward 1x") time.sleep(2) stop() right() time.sleep(1) stop() print("right 1x") time.sleep(2) stop() fwd() print("forward 2x") time.sleep(3) stop() left() time.sleep(1) print("left 1x") stop() fwd() print("forward 3x") time.sleep(2) stop() -- In reply to "Peter Otten" who wrote the following: > input/ldompel...@casema.nl wrote: > > > > The code in capture_key.py may look a bit scary, but just as I took it > > > without bothering the details you can take the resulting module without > > > caring about the code in it. Alternatively you can search > > > > > https://pypi.python.org > > > > Thanks for the link. I realy appreciate it. > > Can you also tell me what I am looking for in https://pypi.python.org for > > a result. > > I didn't have a particular module in mind. Pypy, or the "Python Package > Index", is a repository for all kinds of modules and libraries. If you don't > yet feel comfortable looking around (peferrably using the search engine of > your choice) and experimenting a bit I recommend that you try the piece of > code I posted (or wait for someone else to chime in with a better > suggestion). -- - --- -- - Posted with NewsLeecher v7.0 Beta 2 Web @ http://www.newsleecher.com/?usenet --- - -- - -- https://mail.python.org/mailman/listinfo/python-list
Re: raw_input and break
He, Thank you for making some time for it. Is this your code ? I am also using python 3 I got an error with execute the scipt: --- Enter command> Traceback (most recent call last): File "test06.py", line 44, in for (dir, tm) in SEQUENCE: NameError: name 'SEQUENCE' is not defined --- import time import threading set_right_speed(150) set_left_speed(105) def cmdHandler(): global notDone while True: cmd = raw_input("Enter command> ").lower() if cmd.startswith("s"): notDone = False break else: print ("Unimplemented command: %s") % cmd cmdThread = threading.Thread(target=cmdHandler) cmdThread.start() def move(drct, dly): if drct == FORWARD: fwd() print ("Forward") elif drct == BACKWARD: bwd() print ("Backward") elif drct == LEFT: left() print ("Left") elif drct == RIGHT: right() print ("Right") else: print ("Invalid command: %s") % drct time.sleep(dly) stop() notDone = True servo(90) mindist = 80 while notDone: if mindist > us_dist(15): for (dir, tm) in SEQUENCE: move(dir, tm) - In reply to "Dennis Lee Bieber" who wrote the following: > On Thu, 05 Nov 2015 17:28:36 GMT, input/ldompel...@casema.nl declaimed the > following: > > > Oke, lets try your code.Can you help me with that. > > This is my code: > > - > > from gopigo import * > > import time > > > > set_right_speed(150) > > set_left_speed(105) > > Is there a typo there? If those are setting rotation speeds for > independent drive wheels, you will have a slow left turn enabled. > > > enable_servo() > > fwd() > > print("forward 1x") > > time.sleep(4) > > stop() > > > > while True: > >servo(90) > >mindist = 80 > > > >if mindist > us_dist(15): > > "mindist" will always be 80 -- there is no code shown below that ever > changes it (so the above assignment can be put before the "while" > statement). That means your us_dist() function must somewhere return a > value greater than 80. > > >bwd() > >print ("backward 1x") > >time.sleep(2) > >stop() > >right() > >time.sleep(1) > >stop() > >print("right 1x") > >time.sleep(2) > > You stopped the right() call before ever doing any output > > >stop() > >fwd() > >print("forward 2x") > >time.sleep(3) > >stop() > >left() > >time.sleep(1) > >print("left 1x") > >stop() > >fwd() > >print("forward 3x") > >time.sleep(2) > >stop() > > -- > > Off-hand, I'd try to get rid of a lot of that redundancy by defining > functions to encapsulate your sequence... (Python 2.x syntax -- not tested) > > > (FORWARD, BACKWARD, LEFT, RIGHT) = (1, 2, 3, 4) > SEQUENCE = [ (BACKWARD, 2), > (RIGHT, 1), > (FORWARD, 3), > (LEFT, 1), > (FORWARD, 2) ] > > def move(drct, dly): > if drct == FORWARD: > fwd() > print "Forward" > elif drct == BACKWARD: > bwd() > print "Backward" > elif drct == LEFT: > left() > print "Left" > elif drct == RIGHT: > right() > print "Right" > else: > print "Invalid command: %s" % drct > time.sleep(dly) > stop() > > notDone = True > servo(90) > mindist = 80 > > while notDone: > if mindist > us_dist(15): > for (dir, tm) in SEQUENCE: >move(dir, tm) > > -=-=-=-=- > > Now, if you don't mind having to also press the key, you could > use the threading module to handle the keyboard shutdown command instead of > using system specific modules to do raw keystroke input. You'd add > something before the while loop (and this is really pseudo-code, barely any > attempt at Python): > > import threading > > def cmdHandler(): > global notDone > while True: > cmd = raw_input("Enter command> ").lower() > if cmd.startswith("s"): >notDone = False >break > else: >print "Unimplemented command: %s" % cmd > > cmdThread = threading.Thread(target=cmdHandler) > cmdThread.start() > > This concept doesn't require changes if the underlying OS changes, and > does open things up to having more complex commands (one could have > commands with arguments since the input is line oriented). > > -- > Wulfraed Dennis Lee Bieber AF6VN > wlfr...@ix.netcom.comHTTP://wlfraed.home.netcom.com/ -- - --- -- - Poste
Re: raw_input and break
Hi, I tried to define SEQUENCE with: The script is working now, exept that I do'nt get a menu in terminal for "s" to stop. - def SEQUENCE(): while notDone: if mindist > us_dist(15): for (dir, tm) in SEQUENCE: move(dir, tm) - In reply to "input/ldompel...@casema.nl" who wrote the following: > He, > Thank you for making some time for it. > Is this your code ? > I am also using python 3 > > I got an error with execute the scipt: > --- > > Enter command> Traceback (most recent call last): > File "test06.py", line 44, in > for (dir, tm) in SEQUENCE: > NameError: name 'SEQUENCE' is not defined > --- > > import time > import threading > > set_right_speed(150) > set_left_speed(105) > > def cmdHandler(): > global notDone > while True: > cmd = raw_input("Enter command> ").lower() > if cmd.startswith("s"): > notDone = False > break > else: > print ("Unimplemented command: %s") % cmd > > cmdThread = threading.Thread(target=cmdHandler) > cmdThread.start() > def move(drct, dly): > if drct == FORWARD: > fwd() > print ("Forward") > elif drct == BACKWARD: > bwd() > print ("Backward") > elif drct == LEFT: > left() > print ("Left") > elif drct == RIGHT: > right() > print ("Right") > else: > print ("Invalid command: %s") % drct > time.sleep(dly) > stop() > > notDone = True > > servo(90) > mindist = 80 > > while notDone: > if mindist > us_dist(15): > for (dir, tm) in SEQUENCE: > move(dir, tm) > > -- > --- > In reply to "Dennis Lee Bieber" who wrote the following: > > > On Thu, 05 Nov 2015 17:28:36 GMT, input/ldompel...@casema.nl declaimed the > > following: > > > > > Oke, lets try your code.Can you help me with that. > > > This is my code: > > > - > > > from gopigo import * > > > import time > > > > > > set_right_speed(150) > > > set_left_speed(105) > > > > Is there a typo there? If those are setting rotation speeds for > > independent drive wheels, you will have a slow left turn enabled. > > > > > enable_servo() > > > fwd() > > > print("forward 1x") > > > time.sleep(4) > > > stop() > > > > > > while True: > > >servo(90) > > >mindist = 80 > > > > > >if mindist > us_dist(15): > > > > "mindist" will always be 80 -- there is no code shown below that ever > > changes it (so the above assignment can be put before the "while" > > statement). That means your us_dist() function must somewhere return a > > value greater than 80. > > > > >bwd() > > >print ("backward 1x") > > >time.sleep(2) > > >stop() > > >right() > > >time.sleep(1) > > >stop() > > >print("right 1x") > > >time.sleep(2) > > > > You stopped the right() call before ever doing any output > > > > >stop() > > >fwd() > > >print("forward 2x") > > >time.sleep(3) > > >stop() > > >left() > > >time.sleep(1) > > >print("left 1x") > > >stop() > > >fwd() > > >print("forward 3x") > > >time.sleep(2) > > >stop() > > > -- > > > > Off-hand, I'd try to get rid of a lot of that redundancy by defining > > functions to encapsulate your sequence... (Python 2.x syntax -- not tested) > > > > > > (FORWARD, BACKWARD, LEFT, RIGHT) = (1, 2, 3, 4) > > SEQUENCE = [ (BACKWARD, 2), > > (RIGHT, 1), > > (FORWARD, 3), > > (LEFT, 1), > > (FORWARD, 2) ] > > > > def move(drct, dly): > > if drct == FORWARD: > > fwd() > > print "Forward" > > elif drct == BACKWARD: > > bwd() > > print "Backward" > > elif drct == LEFT: > > left() > > print "Left" > > elif drct == RIGHT: > > right() > > print "Right" > > else: > > print "Invalid command: %s" % drct > > time.sleep(dly) > > stop() > > > > notDone = True > > servo(90) > > mindist = 80 > > > > while notDone: > > if mindist > us_dist(15): > > for (dir, tm) in SEQUENCE: > >move(dir, tm) > > > > -=-=-=-=- > > > > Now, if you don't mind having to also press the key, you could > > use the threading module to handle the keyboard shutdown command instead of > > using system specific modules to do raw k
time module
hi, I like to have a function that prints time in seconds. I am looking for something for example that seconds count from zero. I search the internet for time module in python but could not found anathing usefull. Has someone an example for it. Thanks -- - --- -- - Posted with NewsLeecher v7.0 Beta 2 Web @ http://www.newsleecher.com/?usenet --- - -- - -- https://mail.python.org/mailman/listinfo/python-list
Re: time module
> Ambiguous requirement: any normal counter starts from zero... But what > "zero" represents may differ... Seconds since Jan 1 1970? Seconds since > midnight? Seconds since start of program? Thanks for the reply Yes, I would like seconds since start of program. Can I not doing something like time()=0 only this gives an error. Thanks In reply to "Dennis Lee Bieber" who wrote the following: > On Sat, 07 Nov 2015 21:27:06 GMT, input/ldompel...@casema.nl declaimed the > following: > > > hi, > > > > I like to have a function that prints time in seconds. > > I am looking for something for example that seconds count from zero. > > I search the internet for time module in python but could not found anathing > > usefull. > > > > Ambiguous requirement: any normal counter starts from zero... But what > "zero" represents may differ... Seconds since Jan 1 1970? Seconds since > midnight? Seconds since start of program? > > > > > import time > > > > t0 = time.time() > > > > t0 > 1446941608.052 > > > > t0 / 60.0 > 24115693.46755 > > > > t0 / 60.0 / 60.0 > 401928.2244593 > > > > t0 / 60.0 / 60.0 / 24.0 > 16747.009352453704 > > > > t0 / 60.0 / 60.0 / 24.0 / 365.25 > 45.850812737724034 > > > > > > Almost 46 years worth of seconds. > > > > > tStart = time.time() > > > > for x in range(10): > ... time.sleep(x) > ... print time.time() - tStart > ... > 36.502935 > 37.5040001869 > 39.509629 > 42.509905 > 46.5170001984 > 51.519534 > 57.522193 > 64.5210001469 > 72.523019 > 81.523019 > > > > > > Okay, I'm not the fastest typist (35 seconds from tStart to finishing the > loop code) > -- > Wulfraed Dennis Lee Bieber AF6VN > wlfr...@ix.netcom.comHTTP://wlfraed.home.netcom.com/ -- - --- -- - Posted with NewsLeecher v7.0 Beta 2 Web @ http://www.newsleecher.com/?usenet --- - -- - -- https://mail.python.org/mailman/listinfo/python-list
import module pyttsx in windows IDLE failed
When I try to run this module in Windows IDLE I get this message: How can I solve this problem. Thanks Traceback (most recent call last): File "C:\raspberrypi\recipe-578839-1.py", line 1, in import pyttsx ImportError: No module named 'pyttsx' This is what I found on the internet: --- import pyttsx engine = pyttsx.init() engine.setProperty('rate', 70) voices = engine.getProperty('voices') for voice in voices: print ("Using voice:"), repr(voice) engine.setProperty('voice', voice.id) engine.say("Hi there, how's you ?") engine.say("A B C D E F G H I J K L M") engine.say("N O P Q R S T U V W X Y Z") engine.say("0 1 2 3 4 5 6 7 8 9") engine.say("Sunday Monday Tuesday Wednesday Thursday Friday Saturday") engine.say("Violet Indigo Blue Green Yellow Orange Red") engine.say("Apple Banana Cherry Date Guava") engine.runAndWait() -- - --- -- - Posted with NewsLeecher v7.0 Beta 2 Web @ http://www.newsleecher.com/?usenet --- - -- - -- https://mail.python.org/mailman/listinfo/python-list
Re: import module pyttsx in windows IDLE failed
In reply to "MRAB" who wrote the following: Have you installed pyttsx? No, I did not. Where can I find pyttsx to install ? Thanks - > On 2015-11-16 17:12, input/ldompel...@casema.nl wrote: > > When I try to run this module in Windows IDLE I get this message: > > How can I solve this problem. > > > > Thanks > > > > Traceback (most recent call last): > >File "C:\raspberrypi\recipe-578839-1.py", line 1, in > > import pyttsx > > ImportError: No module named 'pyttsx' > > > > This is what I found on the internet: > > --- > > import pyttsx > > engine = pyttsx.init() > > engine.setProperty('rate', 70) > > > > voices = engine.getProperty('voices') > > for voice in voices: > > print ("Using voice:"), repr(voice) > > engine.setProperty('voice', voice.id) > > engine.say("Hi there, how's you ?") > > engine.say("A B C D E F G H I J K L M") > > engine.say("N O P Q R S T U V W X Y Z") > > engine.say("0 1 2 3 4 5 6 7 8 9") > > engine.say("Sunday Monday Tuesday Wednesday Thursday Friday Saturday") > > engine.say("Violet Indigo Blue Green Yellow Orange Red") > > engine.say("Apple Banana Cherry Date Guava") > > engine.runAndWait() > > > > > Have you installed pyttsx? -- - --- -- - Posted with NewsLeecher v7.0 Beta 2 Web @ http://www.newsleecher.com/?usenet --- - -- - -- https://mail.python.org/mailman/listinfo/python-list
Re: import module pyttsx in windows IDLE failed
Now I get this error: Traceback (most recent call last): File "C:\raspberrypi\recipe-578839-1.py", line 1, in import pyttsx File "C:\Users\loek\AppData\Local\Programs\Python\Python35\lib\site-packages\pyttsx\__init__.py", line 18, in from engine import Engine ImportError: No module named 'engine' === In reply to "Terry Reedy" who wrote the following: > On 11/16/2015 12:45 PM, input/ldompel...@casema.nl wrote: > > In reply to "MRAB" who wrote the following: > > Have you installed pyttsx? > > > > No, I did not. > > Where can I find pyttsx to install ? > > Let pip find it (its on pypi). > On a command line, enter 'pip install pyttsx' > > -- > Terry Jan Reedy -- - --- -- - Posted with NewsLeecher v7.0 Beta 2 Web @ http://www.newsleecher.com/?usenet --- - -- - -- https://mail.python.org/mailman/listinfo/python-list