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

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

Related

How to solve AttributeError: 'module' object has no attribute 'ABC'

I am a bit new to Linux but I am having an issue with my recently installed package Frida. It worked fine until yesterday when I installed fridump as well.
When I try to use Frida I am getting this:
Traceback (most recent call last):
File "/usr/local/bin/frida", line 8, in <module>
sys.exit(main())
File "/usr/local/lib/python2.7/dist-packages/frida_tools/repl.py", line 34, in main
from frida_tools import _repl_magic
File "/usr/local/lib/python2.7/dist-packages/frida_tools/_repl_magic.py", line 7, in <module>
class Magic(abc.ABC):
AttributeError: 'module' object has no attribute 'ABC'
I have Python 3.9.10 installed but I guess it has to do with Python 2.7 and Frida using new version but I don't know how to fix it. Any suggestions?
I got no experience for both tools but after a bit search ,
My suggestion is to uninstall (remove) fridump and Farida,
pip uninstall <packagename>
in your case frida is the package name
And use different virtual environment for each tool :
virtualenv -p /usr/bin/python3 py3env
virtualenv -p /usr/bin/python py2env
to know more about virtual environments here
So each environment can work fine separately without version conflicts and later on will help install any additional needed tools for each package.

ModuleNotFoundError in tracebacks with Python3.6 on linux

I installed Python 3.6 on Ubuntu 16.04 by using Jonathon Fernyhough's PPA:
sudo add-apt-repository ppa:jonathonf/python-3.6
sudo apt-get update
sudo apt-get install python3.6
I made a string, using the new literal string interpolation, but I supplied an invalid format specifier. I not only got the expected ValueError: Invalid format specifier, but also the unexpected ModuleNotFoundError: No module named 'apt_pkg'.
$ python3.6
Python 3.6.0 (default, Dec 29 2016, 21:40:36)
[GCC 5.4.1 20161202] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> value = 4 * 20
>>> f'the value is {value:%A}'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: Invalid format specifier
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
from apport.fileutils import likely_packaged, get_recent_crashes
File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
from apport.report import Report
File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>
import apport.fileutils
File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>
from apport.packaging_impl import impl as packaging
File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 23, in <module>
import apt
File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'
Original exception was:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: Invalid format specifier
I reported this to the Python bug tracker. There it was noted that:
It seems to be vendor's issue not CPython itself. This same issue also happens in Ubuntu 16.10's Python 3.6. Raise any exception can cause this:
Python 3.6.0b2 (default, Oct 11 2016, 05:27:10)
[GCC 6.2.0 20161005] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> raise Exception
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
Exception
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
from apport.fileutils import likely_packaged, get_recent_crashes
File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
from apport.report import Report
File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>
import apport.fileutils
File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>
from apport.packaging_impl import impl as packaging
File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 23, in <module>
import apt
File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'
Original exception was:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
Exception
>>>
Also see https://bugs.launchpad.net/ubuntu/+source/python3.6/+bug/1631367.
Finally, the issue was closed with the comment
Yes, this appears to be the vendor's failure reporting infrastructure
that is failing. Why they'd want a report for every traceback at the
interactive prompt is beyond me, but that appears to be what they are
trying to do.
My questions now are:
How do I interpret this comment? Is the vendor in this case Jonathon Fernyhough's PPA? And did he change something to to the Python code he distributes so that it tries to file a report for every Exception that produces a traceback?
Who do I need to notify or where do I need to file a bug to get this resolved?
I solved this issue for Python 3.6 by first installing the python-apt package for Python 3:
sudo apt install python3-apt
After that, I changed to the dist-packages directory and copied the apt_pkg[...].so file to the new default file name apt_pkg.so, to be also recognized by Python 3.6:
cd /usr/lib/python3/dist-packages
sudo cp apt_pkg.cpython-34m-i386-linux-gnu.so apt_pkg.so
Now all ModuleNotFoundError: No module named 'apt_pkg' exceptions disappeared on expectedly thrown error messages.
After I posted this question to Stackoverflow, Barry A. Warsaw made the following comment to the issue tracker
Please understand that installing Python 3.6 from a random PPA does
not provide full support for this version of the interpreter. Python 3.6 is not yet a supported version in any version of Ubuntu
(which I'm assuming your using), although we are working on it for
17.04.
Very often, you can install a new Python 3 interpreter package and
many things will work because the Ubuntu infrastructure shares
pure-Python modules across all installed Python 3's. Technically
speaking, they will all have /usr/lib/python3/dist-packages on their
sys.path so any third party pure-Python module built for a support
version of Python 3 will be importable by any (package-built)
installed version of Python 3.
But that 1) is a long way from saying that those third-party modules
will work; 2) does not include any packages containing C extension
modules, which must be rebuilt for the specific interpreter version.
Supporting a new version of Python is a long process, for which we are
just starting. Please engage with ubuntu-devel#ubuntu.com for
details.
Ubuntu does install a standard exception handler so that when Python
applications and such crash, we can gather crash statistics, so that
we can devote resources to fixing common problems and regressions.
apport (which you see in the traceback) is that crash reporting
infrastructure. apport calls apt_pkg, which is an (C++) extension
module and thus won't have been built for the version of Python 3.6
you installed from that PPA, unless of course the PPA owner (who I
don't know) has also done an archive-wide Python 3 rebuild. Since I'm
in the process of setting that up, and I know it's quite a bit of
work, I doubt that's been done for this rather random PPA.
The ubuntu-devel mailing list is a better place to discuss the ongoing
work to bring Python 3.6 as a supported version on Ubuntu.
If most voted answer does not work for you please try below steps (Keep in mind you must change [version]):
run this command sudo apt install python3-apt
go to directory cd /usr/lib/python3/dist-packages
run ls to find correct version of apt_pkg.cpython-[version]-i386-linux-gnu.so in my case it was 35m
create a symlink sudo cp apt_pkg.cpython-[version]-i386-linux-gnu.so apt_pkg.so DON'T FORGET: type your [version]
Troubleshouting
If you get error cp: cannot stat 'apt_pkg.cpython-[your-version]-i386-linux-gnu.so': No such file or directory try commands below:
rm -rf apt_pkg.so
create a symlink sudo cp apt_pkg.cpython-[version]-i386-linux-gnu.so apt_pkg.so DON'T FORGET: type your [version]
I removed python3-apt and that seems to have solved it for Python 3.8
sudo apt-get remove --purge python3-apt
sudo apt-get install python3-apt

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.

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

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

Error while starting new IPython console in Spyder

While I was training a neural network with Pybrain, my computer crashed and I had to reboot it. Now Spyder, Python, IPython seem to work fine, however, when trying to open a new IPython console in Spyder, I get the following error:
Error in sitecustomize; set PYTHONVERBOSE for traceback:
TypeError: 'NoneType' object is not callable
Traceback (most recent call last):
File "C:\Users\Mi\Anaconda3\lib\site‑packages\spyderlib\widgets\externalshell\start_ipython_kernel.py", line 167, in
from IPython.kernel.zmq.kernelapp import IPKernelApp
File "C:\Users\Mi\Anaconda3\lib\site‑packages\IPython\__init__.py", line 48, in
from .core.application import Application
File "C:\Users\Mi\Anaconda3\lib\site‑packages\IPython\core\application.py", line 22, in
from IPython.config.application import Application, catch_config_error
File "C:\Users\Mi\Anaconda3\lib\site‑packages\IPython\config\__init__.py", line 6, in
from .application import *
File "C:\Users\Mi\Anaconda3\lib\site‑packages\IPython\config\application.py", line 19, in
from IPython.config.configurable import SingletonConfigurable
File "C:\Users\Mi\Anaconda3\lib\site‑packages\IPython\config\configurable.py", line 14, in
from IPython.utils.text import indent, wrap_paragraphs
File "C:\Users\Mi\Anaconda3\lib\site‑packages\IPython\utils\text.py", line 28, in
from IPython.external.path import path
File "C:\Users\Mi\Anaconda3\lib\site‑packages\IPython\external\path\__init__.py", line 2, in
from path import *
File "C:\Users\Mi\Anaconda3\lib\site‑packages\path.py", line 122, in
__version__ = pkg_resources.require('path.py')[0].version
TypeError: 'NoneType' object is not callable
The error does not seem to interfere with the execution of Python scripts however I am wondering if I accidentally messed something up. I searched the internet but found nothing that could explain this error.
I am using Python 3.4.3 64 bit with the Anaconda 2.3.0 distribution.
Either upgrade setuptools or try
pip install --upgrade --force setuptools fixed it. Either one or the other should fix the problem.
The accepted answer is correct in that it is a setup tools problem, but I couldn't use pip install --upgrade --force setuptools, that complained about not being able to find easy-install.pth
Instead I was able to upgrade setuptools using easy-install itself with:
easy_install --upgrade setuptools, hope that helps someone who was stuck like me.
I have the same problem. and setuptools did not fix my error.
finally, run
conda update path.py
fix my error. You could check this link: https://github.com/spyder-ide/spyder/issues/2679
conda update qt pyqt
conda update spyder
pip install -U spyder
This worked for me

Resources