Ubuntu 16.04 python3.5: PyAudio 0.2.9 or later is required (found version 0.2.8) - python-3.5

that's my first question here.
I have a problem with python3.5 and PyAudio on my Ubuntu 16.04:
What type of problem I have
Currently I'm writing on a program that uses the speech_recognition library in python.
And if I call my script (python3 processor.py), it says the following:
Traceback (most recent call last):
File "processor.py", line 143, in <module>
main()
File "processor.py", line 132, in main
with sp_reco.Microphone() as source:
File "/usr/local/lib/python3.5/dist-packages/speech_recognition/__init__.py", line 55, in __init__
self.pyaudio_module = self.get_pyaudio()
File "/usr/local/lib/python3.5/dist-packages/speech_recognition/__init__.py", line 88, in get_pyaudio
raise AttributeError("PyAudio 0.2.9 or later is required (found version {0})".format(pyaudio.__version__))
AttributeError: PyAudio 0.2.9 or later is required (found version 0.2.8)
Checking existing pip3 modules with pip3 list gave me the following:
PyAudio (0.2.9)
And I don't know why speech_recognition says the found version is 0.2.8
And it works if I type python3 in the console and type in the shown python console import pyaudio
My script works fully, if I use the python command
Screenshot pip3 list

Related

PyCharm and turtle

I have a problem with PyCharm. I start learning python with PyCharm and I want write some with turtle package. When i try execute this code
import turtle
bob = turtle.Turtle()
I have that message:
"C:\Program Files\Python36\python.exe" C:/Users/Ptr/Desktop/python/Proj_1/Gui.py
Traceback (most recent call last):
File "C:/Users/Ptr/Desktop/python/Proj_1/Gui.py", line 1, in <module>
import turtle
File "C:\Program Files\Python36\lib\turtle.py", line 107, in <module>
import tkinter as TK
File "C:\Users\Ptr\Desktop\python\tkinter.py", line 3, in <module>
okno = tkinter.Tk()
AttributeError: module 'tkinter' has no attribute 'Tk'
Process finished with exit code 1
When I try execute that code using IDLE all works.
In PyCharm I try install turtle in project:
Python>Project Interpreter
but all time I have same error:
Collecting turtle
Using cached turtle-0.0.2.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\Ptr\AppData\Local\Temp\pycharm-packaging\turtle\setup.py", line 40
except ValueError, ve:
except ValueError, ve:
^
SyntaxError: invalid syntax
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\Ptr\AppData\Local\Temp\pycharm-packaging\turtle\
enter code here
A couple of things to note for those running into this at a later time:
tkinter must be installed on your machine. There is a python2.x and
python3.x version. It must match your version of python. For example,
In Ubuntu, I am running python3.6, and had to run apt-get install
python3.6-tk
Pycharm allows you to pick interpreters. It is possible to be running
a different interpreter in IDLE than in PyCharm, making the mismatch
of python and tkinter versions potentially confusing. This is further
complicated potentially by virtual environments. Be certain your
python version and you tkinter versions match.
You can not have modules in your import path of the name tkinter.py or turtle.py
As mentioned by ds_secret, turtle comes with python, no need to
install it separately.
You don't pip turtle. Turtle is a built-in python package.
You just say import turtle.

Python3.4 - Install pyautogui - Raspberry Pi 3

I've been trying to install pyautogui for Python 3.4 on my Raspberry Pi 3 for the last 2 hours... I need it because I wrote a touch keyboard application that needs to run on it. On my main machine (elementary OS 0.4 with Python 3.5) I was able to install it without any problems. First I tried sudo pip install pyautogui but that only installed the Python 2.7 version of pyautogui. Of course next I tried sudo pip3 install pyautogui but that gave me this error:
Running setup.py (path:/tmp/pip-build-hf289jja/pyautogui/setup.py) egg_info for package pyautogui
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "/tmp/pip-build-hf289jja/pyautogui/setup.py", line 6, in <module>
version=__import__('pyautogui').__version__,
File "/tmp/pip-build-hf289jja/pyautogui/pyautogui/__init__.py", line 114, in <module>
from . import _pyautogui_x11 as platformModule
File "/tmp/pip-build-hf289jja/pyautogui/pyautogui/_pyautogui_x11.py", line 6, in <module>
from Xlib.display import Display
File "/usr/local/lib/python3.4/dist-packages/Xlib/display.py", line 20, in <module>
import new
ImportError: No module named 'new'
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 17, in
File "/tmp/pip-build-hf289jja/pyautogui/setup.py", line 6, in
version=__import__('pyautogui').__version__,
File "/tmp/pip-build-hf289jja/pyautogui/pyautogui/init.py", line 114, in
from . import _pyautogui_x11 as platformModule
File "/tmp/pip-build-hf289jja/pyautogui/pyautogui/_pyautogui_x11.py", line 6, in
from Xlib.display import Display
File "/usr/local/lib/python3.4/dist-packages/Xlib/display.py", line 20, in
import new
ImportError: No module named 'new'
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip-build-hf289jja/pyautogui
Storing debug log for failure in /root/.pip/pip.log
... sorry for the formatting of the above, I couldn't get it to stay inside one code box.
I have no idea what module "new" is. I tried everything else under the sun, such as installing from the official resources: https://pypi.python.org/pypi/PyAutoGUI and various other guides, with NO results.. I'm kinda loosing my mind right now.
ANY Help is grately appreciated :)
Try the following:
sudo pip3 install python3-xlib
sudo pip3 install pyautogui
This assumes you have some other python3 libraries already installed, but you will see missing installs in the above if not.

Does unirest support python3?

Does unirest support python3? I have googled and zero information comes up. Even in the unirest documentation it does not say it is 2.x only which leads me to believe it supports both 3.x and 2.x. However the install fails with 3.4 and succeeds with 2.7. See below.
nkltss:~/dev$ mkvirtualenv mashape -p /usr/bin/python3
Running virtualenv with interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in mashape/bin/python3
Also creating executable in mashape/bin/python
Installing setuptools, pip...done.
(mashape)nkltss:~/dev$ pip install unirest
Downloading/unpacking unirest
Downloading Unirest-1.1.6.tar.gz
Running setup.py (path:/home/nick/.virtualenvs/mashape/build/unirest/setup.py) egg_info for package unirest
warning: no files found matching '*.txt' under directory 'docs'
Downloading/unpacking poster>=0.8.1 (from unirest)
Downloading poster-0.8.1.tar.gz
Running setup.py (path:/home/nick/.virtualenvs/mashape/build/poster/setup.py) egg_info for package poster
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "/home/nick/.virtualenvs/mashape/build/poster/setup.py", line 2, in <module>
import poster
File "/home/nick/.virtualenvs/mashape/build/poster/poster/__init__.py", line 29, in <module>
import poster.streaminghttp
File "/home/nick/.virtualenvs/mashape/build/poster/poster/streaminghttp.py", line 61
print "send:", repr(value)
^
SyntaxError: invalid syntax
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "/home/nick/.virtualenvs/mashape/build/poster/setup.py", line 2, in <module>
import poster
File "/home/nick/.virtualenvs/mashape/build/poster/poster/__init__.py", line 29, in <module>
import poster.streaminghttp
File "/home/nick/.virtualenvs/mashape/build/poster/poster/streaminghttp.py", line 61
print "send:", repr(value)
^
SyntaxError: invalid syntax
----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /home/nick/.virtualenvs/mashape/build/poster
Storing debug log for failure in /home/nick/.pip/pip.log
For now I am using 2.7 but I prefer to use 3.x for new projects.
The project is not Python 3 compatible. When the project doesn't explicitly state this (not in the setup.py trove classifiers nor in documentation), you'll have to look at the source code.
There I find:
no use_2to3 use in setup to automatically rewrite code on install
imports for urllib2, a Python 2 only library.
The project depends on the poster library, which is also urllib2 specific.
I'd use the requests library instead. It supports Python 3 out of the box, and apart from asynchronous requests it supports the same feature set (but better as it doesn't have the shortcomings urllib2 brings along). For asynchronous requests, you can add on requests-futures.

can't install CherryPy with python3.3 under ubuntu12.04

I tried to install CherryPy under Ubuntu 12.04.3 server with command:
sudo python3.3 setup.py install
It seems that everything was fine.
But when running test:
python3.3 -c "import cherrypy"
it gives an error:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/lib/python3.3/dist-packages/cherrypy/__init__.py", line 82, in <module>
from cherrypy import process
File "/usr/local/lib/python3.3/dist-packages/cherrypy/process/__init__.py", line 14, in <module>
from cherrypy.process import plugins, servers
File "/usr/local/lib/python3.3/dist-packages/cherrypy/process/plugins.py", line 424, in <module>
class PerpetualTimer(threading._Timer):
AttributeError: 'module' object has no attribute '_Timer'
When doing the same with
python2.7 -c "import cherrypy"
it gives no output.
What could it be?
Best regards,
Leonid
"Timer class was renamed from _Timer to Timer in Python 3.3"
https://bitbucket.org/cherrypy/cherrypy/issue/1163/attributeerror-in-cherrypyprocessplugins
Hope this helps!
I have downloaded CherryPy 3.2.3 from python.org (https://pypi.python.org/pypi/CherryPy/3.2.3) instead of 3.2.2 taken from cherrypy.org (http://download.cherrypy.org/cherrypy/3.2.2/) used before and run installation process once more.
Now it works for some reason...
I work with Cherrypy and I install this with Mako always with Terminal writing:
sudo apt-get install subversion python-mako python-simplejson python-cherrypy3 graphviz
This I find inside the site, you can save this in bookmarks' s browser.
Installation simpler and faster

Spyder IDE fails to start on Windows 10 with Python 3.8 [duplicate]

This question already has answers here:
Jupyter Notebook with Python 3.8 - NotImplementedError
(4 answers)
Closed 3 years ago.
Note: this issue is fixed in Spyder 4.1.3!
(original question) checking out Python 3.8 (x64) on Windows 10, I got into trouble when trying to setup Spyder. Note: the issue was reproducible with a fresh Python installation on a clean Windows-10 system. However, no such issues on Linux (tested on debian / Mint19.x).
At first, everything went smooth during installation via pip install spyder.
error #1: pywin32
After starting Spyder, it said in the IPython console window:
Traceback (most recent call last):
File "c:\users\USERNAME\appdata\local\programs\python\python38\lib\site‑packages\spyder\plugins\ipythonconsole.py", line 1572, in create_kernel_manager_and_kernel_client
kernel_manager.start_kernel(stderr=stderr_handle)
File "c:\users\USERNAME\appdata\local\programs\python\python38\lib\site‑packages\jupyter_client\manager.py", line 240, in start_kernel
self.write_connection_file()
File "c:\users\USERNAME\appdata\local\programs\python\python38\lib\site‑packages\jupyter_client\connect.py", line 470, in write_connection_file
self.connection_file, cfg = write_connection_file(self.connection_file,
File "c:\users\USERNAME\appdata\local\programs\python\python38\lib\site‑packages\jupyter_client\connect.py", line 141, in write_connection_file
with secure_write(fname) as f:
File "c:\users\USERNAME\appdata\local\programs\python\python38\lib\contextlib.py", line 113, in __enter__
return next(self.gen)
File "c:\users\USERNAME\appdata\local\programs\python\python38\lib\site‑packages\jupyter_core\paths.py", line 424, in secure_write
win32_restrict_file_to_user(fname)
File "c:\users\USERNAME\appdata\local\programs\python\python38\lib\site‑packages\jupyter_core\paths.py", line 359, in win32_restrict_file_to_user
import win32api
ImportError: DLL load failed while importing win32api: Das angegebene Modul wurde nicht gefunden.
I was able to fix the import error by running pywin32_postinstall.py -install from the scripts folder (from a cmd prompt with elevated rights). That copies pythoncom38.dll and pywintypes38.dll from \Lib\site-packages\pywin32_system32 to \windows\system32, see also here - however, I'd suggest to not modify system folders and use the option I put in my answer below.
error #2: tornado
However, now Spyder just freezes at the loading screen (logo displayed, saying something like "initializing main window")!
cloning the dev version of Spyder from https://github.com/spyder-ide/spyder.git and running it via python bootstrap.py --debug reveals the cause of the freeze:
2019-11-03 17:39:53,261 [ERROR] [tornado.application] -> Exception in callback functools.partial(<function ThreadedZMQSocketChannel.__init__.<locals>.setup_stream at 0x0000015E00B758B0>)
Traceback (most recent call last):
File "C:\Users\USERNAME\AppData\Local\Programs\Python\Python38\lib\site-packages\tornado\ioloop.py", line 743, in _run_callback
ret = callback()
File "C:\Users\USERNAME\AppData\Local\Programs\Python\Python38\lib\site-packages\jupyter_client\threaded.py", line 48, in setup_stream
self.stream = zmqstream.ZMQStream(self.socket, self.ioloop)
File "C:\Users\USERNAME\AppData\Local\Programs\Python\Python38\lib\site-packages\zmq\eventloop\zmqstream.py", line 127, in __init__
self._init_io_state()
File "C:\Users\USERNAME\AppData\Local\Programs\Python\Python38\lib\site-packages\zmq\eventloop\zmqstream.py", line 546, in _init_io_state
self.io_loop.add_handler(self.socket, self._handle_events, self.io_loop.READ)
File "C:\Users\USERNAME\AppData\Local\Programs\Python\Python38\lib\site-packages\tornado\platform\asyncio.py", line 99, in add_handler
self.asyncio_loop.add_reader(fd, self._handle_events, fd, IOLoop.READ)
File "C:\Users\USERNAME\AppData\Local\Programs\Python\Python38\lib\asyncio\events.py", line 501, in add_reader
raise NotImplementedError
NotImplementedError
...so it seems the import error caused by the Python 3.8 version of pywin32 is only one issue. There's also a problem related to tornado IO (web server), see here / here.
last checked with Python 3.8.2 (AMD64), Spyder 4.1.1. Please note that I am not using Anaconda. Use either conda or pip, not both.
Spyder 4.1.3 Update: The issue is fixed!
(Tested on Python 3.8.3rc1, tornado 6.0.4)
If you come here still experiencing similar startup issues with Spyder: the first thing to try I'd suggest upgrade to Spyder version >= 4.1.3.
older version of this answer
workaround, tornado issue:
Modify the file ...\Python38...\Lib\site-packages\tornado\platform\asyncio.py;
add
import sys
if sys.platform == 'win32':
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
after the other import statements. Source: here on SO and also linked here. If I get this post on the tornado repo right, this is likely to be a pretty permanent workaround.
if also needed - workaround, pywin32 issue:
Modify the file ...\Python38\Lib\site-packages\jupyter_core\path.py;
add a line
import pywintypes
before import win32api in line 359. This modification is based on this post.

Resources