Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

syntax error and module error #8

Open
SamMuel112 opened this issue Dec 30, 2018 · 7 comments
Open

syntax error and module error #8

SamMuel112 opened this issue Dec 30, 2018 · 7 comments

Comments

@SamMuel112
Copy link

Hello,

I am trying to use this code on a raspberry pito make a live oscilloscope (as a prototype) for my modular synthesizer. I have 2 main errors.

one says:
File "/home/pi/Desktop/Waveformviewer1.py", line 13
%matplotlib tk
^
SyntaxError: invalid syntax

I tried bypassing it by commenting it with a #. but it brought up:

                        File "/home/pi/Desktop/Waveformviewer1.py", line 5, in <module>
                           import pyaduio
                        ImportError: No module named 'pyaudio'

To resolve this I have tried running install commands in the terminal updates upgrades all that sort of back-end stuff but it's still not working.

please help

@rudrathegreat
Copy link

rudrathegreat commented Jan 2, 2019

One thing is that instead of using %matplotlib tk use -

import matplotlib

matplotlib.use('TkAgg')

But remember that in order to have the TkAgg backend, you must have python tk.

Secondly, pyaudio must be installed. In order to check if that has been installed, try importing it in the Python Shell. If the module has not been found, then that means that it has not been properly installed.

import pyaudio

In order to install pyaudio, you need to install portaudio. After that, you can safely install pyaudio with no errors

sudo pip install PyAudio

Another thing to notify here is that portaudio is programmed in C, so you need to build it using something like Microsoft Visual Studio.

I hope I helped you with your issue!

P.S - I am not an artificial intelligent program or robot!

@SamMuel112
Copy link
Author

SamMuel112 commented Jan 2, 2019

Thank you so much for your reply!!!!.

Ill try that tomorrow afternoon as its almost midnight here now.

One question.

Will port audio (as you mention it being programmed in c) actually work on rasberry pi? As i wont be able to run MVS on the Pi?

Will it be a problem? If so is there an alternative??

Sam

@rudrathegreat
Copy link

rudrathegreat commented Jan 2, 2019

Yes it should, I have done this process on a Linux laptop. All you need to do is configure and build portaudio before installing pyaudio.

./configure && make

Just remember that PyAudio is sort of like an interface between PortAudio and Python!

Another thing is that if you are having doubts that you do not have python tk, you can check by importing tkinter -

import tkinter as tk

If it gives an error, then you have to install it -

sudo apt-get install python-tk
sudio apt-get install python3-tk

Then try importing it again!

😄

@rudrathegreat
Copy link

Another thing to note is that when you have python tk and you have the TkAgg backend, then you don't exactly have to do this -

matplotlib.use('TkAgg')

Because when you have the TkAgg backend, that is your default backend.

@SamMuel112
Copy link
Author

okay,

so I did everything you said. I think we got rid of the matplotlib problems but we still have issues with the pyaudio modules not found.

the only thing you said to do that I 'couldn't' do was the

./confige && make

where was that suppose to go??

also could not specifically install portaudio. not sure if I was supposed to be able to but yeah
ive got photos of my responses if it helps.

@rudrathegreat
Copy link

The part where you have to build portaudio is actually from the documentation - http://www.portaudio.com

Again, the reason why pyaudio was not installed was because it couldn't technically find PortAudio. See, in order for PortAudio to be recognised, it needs to be built.

Installation for PyAudio is also mentioned here, however it doesn't mention how to install PortAudio, make it recognisable for PyAudio, which is why you need to go to the PortAudio documentation -

https://people.csail.mit.edu/hubert/pyaudio/

I hope that helped with the PyAudio problem!

@rudrathegreat
Copy link

This is what the PyAudio documentation mentions -

To build PyAudio from source, you will also need to build PortAudio v19.

I have also found a reference to this issue -

https://stackoverflow.com/questions/33513522/when-installing-pyaudio-pip-cannot-find-portaudio-h-in-usr-local-include

I hope that helped with the issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants