How to downgrade an Raspberry Pi Zero W from Python 3.7 to 3.6 without breaking the environment (eg, pip), to use pyaudio

孤街浪徒 提交于 2021-01-28 17:09:08

问题


I'm trying to run an FFT on a few high frequency bins of a continuous audio stream from a USB microphone input using a Raspberry Pi Zero W. The Windows PC prototype runs but when deploying to the Pi there are issues with "pyaudio" which does not have a Python3.7 wheel(?) for ARM, only Python3.6. The RPi OS install includes 3.7 and I think all I want to do is downgrade to 3.6. This is a fixed purpose device so virtualenv is not needed (and I had issues trying it) and can't burden the Pi Zero with Anaconda. I haven't ever built on *nix.

I installed Python3.6 and changed the python3 symlink to point to it. Running "pip3 install pyaudio" yields:

...
File "/usr/lib/python3/dist-packages/pip/_internal/locations.py", line 10, in from distutils import sysconfig as distutils_sysconfig ImportError: cannot import name 'sysconfig'

Multiple angles of attack seem to run into distutils sysconfig (like when I tried virtualenv). I've tried so many things (like update-alternatives) I'm probably a bit confused as to current state.

I think my question is "how to downgrade an RPi Zero W from Python 3.7 to 3.6 without breaking the environment (eg, pip)", but perhaps it's really "how do I get pyaudio in 3.7", or "is there an alternative to pyaudio".

Additional info:

  • python3 --version --> "Python 3.6.8"
  • python3 -c "import sysconfig" --> runs without complaint
  • sudo apt install python3-distutils --> "python3-distutils is already the newest version (3.7.3-1)" Can I get 3.6?
  • pip3 install setuptools --> "ImportError: cannot import name 'sysconfig'"

This is my first stackoverflow post, apologies for breaches of etiquette.


回答1:


Python 3.7 that is installed is system-wide. Is there any reason that you couldn't install Python as a unique version and run that specific installation? Typically when people want a different version they are doing an upgrade so you could search for persons who have documented that process.

Generally, you would download the project and compile it on your machine. Make a folder in your home folder, switch into it and then.

$ wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tar.xz
$ tar xf Python-3.6.5.tar.xz
$ cd Python-3.6.5
$ ./configure
$ make
$ sudo make altinstall

$ which python3.6 returns /usr/local/bin/python3.6

$ which python3 returns /usr/bin/python3

as usual



来源:https://stackoverflow.com/questions/65066866/how-to-downgrade-an-raspberry-pi-zero-w-from-python-3-7-to-3-6-without-breaking

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!