ModuleNotFoundError: No module named 'tornado' on ubuntu - python

When I am trying to run my application I got the following error
Traceback (most recent call last):
File "./app.py", line 32, in <module>
from pushservices.bootstrap import init_messaging_agents
File "/home/airnotifier/airnotifier/pushservices/bootstrap.py", line 2, in <module>
from .apns import *
File "/home/airnotifier/airnotifier/pushservices/apns.py", line 5, in <module>
from util import json_encode
File "/home/airnotifier/airnotifier/util.py", line 37, in <module>
import tornado
ModuleNotFoundError: No module named 'tornado'
I tried to run this command to install tornado
python3 -m pip install tornado
then I got the following message
Requirement already satisfied: tornado in /usr/local/lib/python3.8/dist-packages (6.0.3)
followed by the following error log
--- Logging error ---
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/pip/_internal/utils/logging.py", line 177, in emit
self.console.print(renderable, overflow="ignore", crop=False, style=style)
File "/usr/local/lib/python3.8/dist-packages/pip/_vendor/rich/console.py", line 1752, in print
extend(render(renderable, render_options))
File "/usr/local/lib/python3.8/dist-packages/pip/_vendor/rich/console.py", line 1390, in render
for render_output in iter_render:
File "/usr/local/lib/python3.8/dist-packages/pip/_internal/utils/logging.py", line 134, in __rich_console__
for line in lines:
File "/usr/local/lib/python3.8/dist-packages/pip/_vendor/rich/segment.py", line 245, in split_lines
for segment in segments:
File "/usr/local/lib/python3.8/dist-packages/pip/_vendor/rich/console.py", line 1368, in render
renderable = rich_cast(renderable)
File "/usr/local/lib/python3.8/dist-packages/pip/_vendor/rich/protocol.py", line 36, in rich_cast
renderable = cast_method()
File "/usr/local/lib/python3.8/dist-packages/pip/_internal/self_outdated_check.py", line 130, in __rich__
pip_cmd = get_best_invocation_for_this_pip()
File "/usr/local/lib/python3.8/dist-packages/pip/_internal/utils/entrypoints.py", line 58, in get_best_invocation_for_this_pip
if found_executable and os.path.samefile(
File "/usr/lib/python3.8/genericpath.py", line 101, in samefile
s2 = os.stat(f2)
FileNotFoundError: [Errno 2] No such file or directory: '/usr/bin/pip3.8'
Call stack:
File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/usr/local/lib/python3.8/dist-packages/pip/__main__.py", line 31, in <module>
sys.exit(_main())
File "/usr/local/lib/python3.8/dist-packages/pip/_internal/cli/main.py", line 70, in main
return command.main(cmd_args)
File "/usr/local/lib/python3.8/dist-packages/pip/_internal/cli/base_command.py", line 101, in main
return self._main(args)
File "/usr/local/lib/python3.8/dist-packages/pip/_internal/cli/base_command.py", line 223, in _main
self.handle_pip_version_check(options)
File "/usr/local/lib/python3.8/dist-packages/pip/_internal/cli/req_command.py", line 148, in handle_pip_version_check
pip_self_version_check(session, options)
File "/usr/local/lib/python3.8/dist-packages/pip/_internal/self_outdated_check.py", line 237, in pip_self_version_check
logger.info("[present-rich] %s", upgrade_prompt)
File "/usr/lib/python3.8/logging/__init__.py", line 1446, in info
self._log(INFO, msg, args, **kwargs)
File "/usr/lib/python3.8/logging/__init__.py", line 1589, in _log
self.handle(record)
File "/usr/lib/python3.8/logging/__init__.py", line 1599, in handle
self.callHandlers(record)
File "/usr/lib/python3.8/logging/__init__.py", line 1661, in callHandlers
hdlr.handle(record)
File "/usr/lib/python3.8/logging/__init__.py", line 954, in handle
self.emit(record)
File "/usr/local/lib/python3.8/dist-packages/pip/_internal/utils/logging.py", line 179, in emit
self.handleError(record)
Message: '[present-rich] %s'
Arguments: (UpgradePrompt(old='22.1.2', new='22.2.2'),)
can anyone please tell me what should I do and what is the problem ?

Here's a possible scenario that could cause this:
you execute pip install tornado as a user but you run the tornado project as another user.
Sorry for my terrible english, hope you can understand

Related

Module 'cryptography.utils' has no attribute 'bit_length'

I am currently trying to figure out how to use netmiko to automate some of my routine work.Such as getting configuration backup, creating vlans etc.I've managed to use it on Aruba and Huawei Switches without problem.But on alcatel switch I'm facing this issue:
Unknown exception: module 'cryptography.utils' has no attribute 'bit_length'
Traceback (most recent call last):
File "C:\Users\melih.celik\AppData\Local\Programs\Python\Python39\lib\site-packages\paramiko\transport.py", line 2075, in run
self.kex_engine.parse_next(ptype, m)
File "C:\Users\melih.celik\AppData\Local\Programs\Python\Python39\lib\site-packages\paramiko\kex_gex.py", line 101, in parse_next
return self._parse_kexdh_gex_reply(m)
File "C:\Users\melih.celik\AppData\Local\Programs\Python\Python39\lib\site-packages\paramiko\kex_gex.py", line 281, in _parse_kexdh_gex_reply
self.transport._verify_key(host_key, sig)
File "C:\Users\melih.celik\AppData\Local\Programs\Python\Python39\lib\site-packages\paramiko\transport.py", line 1886, in _verify_key
if not key.verify_ssh_sig(self.H, Message(sig)):
File "C:\Users\melih.celik\AppData\Local\Programs\Python\Python39\lib\site-packages\paramiko\dsskey.py", line 148, in verify_ssh_sig
key = dsa.DSAPublicNumbers(
File "C:\Users\melih.celik\AppData\Local\Programs\Python\Python39\lib\site-packages\cryptography\hazmat\primitives\asymmetric\dsa.py", line 212, in public_key
return backend.load_dsa_public_numbers(self)
File "C:\Users\melih.celik\AppData\Local\Programs\Python\Python39\lib\site-packages\cryptography\hazmat\backends\openssl\backend.py", line 871, in load_dsa_public_numbers
dsa._check_dsa_parameters(numbers.parameter_numbers)
File "C:\Users\melih.celik\AppData\Local\Programs\Python\Python39\lib\site-packages\netmiko\tplink\tplink_jetstream.py", line 145, in _override_check_dsa_parameters
if crypto_utils.bit_length(parameters.q) not in [160, 256]:
AttributeError: module 'cryptography.utils' has no attribute 'bit_length'
Traceback (most recent call last):
File "C:\Users\melih.celik\Desktop\New_Backup\Yedek\Coding\Rand stuff\ssh_deneme(toplu).py", line 75, in
config_backup(cihaz_secim,ip_address,username,password)
File "C:\Users\melih.celik\Desktop\New_Backup\Yedek\Coding\Rand stuff\ssh_deneme(toplu).py", line 12, in config_backup
net_connect=ConnectHandler(**switch) #Baglanti kuruldu.
File "C:\Users\melih.celik\AppData\Local\Programs\Python\Python39\lib\site-packages\netmiko\ssh_dispatcher.py", line 312, in ConnectHandler
return ConnectionClass(*args, **kwargs)
File "C:\Users\melih.celik\AppData\Local\Programs\Python\Python39\lib\site-packages\netmiko\base_connection.py", line 346, in init
self._open()
File "C:\Users\melih.celik\AppData\Local\Programs\Python\Python39\lib\site-packages\netmiko\base_connection.py", line 351, in _open
self.establish_connection()
File "C:\Users\melih.celik\AppData\Local\Programs\Python\Python39\lib\site-packages\netmiko\base_connection.py", line 920, in establish_connection
self.remote_conn_pre.connect(**ssh_connect_params)
File "C:\Users\melih.celik\AppData\Local\Programs\Python\Python39\lib\site-packages\paramiko\client.py", line 406, in connect
t.start_client(timeout=timeout)
File "C:\Users\melih.celik\AppData\Local\Programs\Python\Python39\lib\site-packages\paramiko\transport.py", line 660, in start_client
raise e
File "C:\Users\melih.celik\AppData\Local\Programs\Python\Python39\lib\site-packages\paramiko\transport.py", line 2075, in run
self.kex_engine.parse_next(ptype, m)
File "C:\Users\melih.celik\AppData\Local\Programs\Python\Python39\lib\site-packages\paramiko\kex_gex.py", line 101, in parse_next
return self._parse_kexdh_gex_reply(m)
File "C:\Users\melih.celik\AppData\Local\Programs\Python\Python39\lib\site-packages\paramiko\kex_gex.py", line 281, in _parse_kexdh_gex_reply
self.transport._verify_key(host_key, sig)
File "C:\Users\melih.celik\AppData\Local\Programs\Python\Python39\lib\site-packages\paramiko\transport.py", line 1886, in _verify_key
if not key.verify_ssh_sig(self.H, Message(sig)):
File "C:\Users\melih.celik\AppData\Local\Programs\Python\Python39\lib\site-packages\paramiko\dsskey.py", line 148, in verify_ssh_sig
key = dsa.DSAPublicNumbers(
File "C:\Users\melih.celik\AppData\Local\Programs\Python\Python39\lib\site-packages\cryptography\hazmat\primitives\asymmetric\dsa.py", line 212, in public_key
return backend.load_dsa_public_numbers(self)
File "C:\Users\melih.celik\AppData\Local\Programs\Python\Python39\lib\site-packages\cryptography\hazmat\backends\openssl\backend.py", line 871, in load_dsa_public_numbers
dsa._check_dsa_parameters(numbers.parameter_numbers)
File "C:\Users\melih.celik\AppData\Local\Programs\Python\Python39\lib\site-packages\netmiko\tplink\tplink_jetstream.py", line 145, in _override_check_dsa_parameters
if crypto_utils.bit_length(parameters.q) not in [160, 256]:
AttributeError: module 'cryptography.utils' has no attribute 'bit_length'
Thanks for your help in advance.
It looks like tplink_jetstream.py assumes that a (now removed) helper function is available to it. The simplest fix here would be to go into that file and modify the line containing crypto_utils.bit_length(parameters.q) to read parameters.q.bit_length() instead.

upgrade to django 1.11.12 error in models/manager.py contribute_to_class

I haven't touched a project in a long time and realized I upgraded my django to version 1.11.12. Trying to re-run project (runserver) and found several out of date packages (easy-thumbnails and psycopg2). Ran pip install upgrade on those. Now when I run, I get the following error and it seems like it is coming form my models? Not sure what it is telling me though or the proper course of action. Maybe there was another upgrade step I missed when I upgraded to django 1.11? (sorry been ages since I touched this code)
Unhandled exception in thread started by <function wrapper at 0x104ab2500>
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 228, in wrapper
fn(*args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 116, in inner_run
autoreload.raise_last_exception()
File "/usr/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 251, in raise_last_exception
six.reraise(*_exception)
File "/usr/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 228, in wrapper
fn(*args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/django/__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/local/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models()
File "/usr/local/lib/python2.7/site-packages/django/apps/config.py", line 202, in import_models
self.models_module = import_module(models_module_name)
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/Users/shane.thomas/programming/sw_nga_site/swsite/models.py", line 12, in <module>
from filer.fields.image import FilerImageField
File "/usr/local/lib/python2.7/site-packages/filer/fields/image.py", line 4, in <module>
from ..models import Image
File "/usr/local/lib/python2.7/site-packages/filer/models/__init__.py", line 3, in <module>
from .clipboardmodels import * # flake8: noqa
File "/usr/local/lib/python2.7/site-packages/filer/models/clipboardmodels.py", line 9, in <module>
from . import filemodels
File "/usr/local/lib/python2.7/site-packages/filer/models/filemodels.py", line 18, in <module>
from .foldermodels import Folder
File "/usr/local/lib/python2.7/site-packages/filer/models/foldermodels.py", line 240, in <module>
mptt.register(Folder)
File "/usr/local/lib/python2.7/site-packages/mptt/__init__.py", line 12, in register
from mptt.models import MPTTModelBase
File "/usr/local/lib/python2.7/site-packages/mptt/models.py", line 379, in <module>
class MPTTModel(six.with_metaclass(MPTTModelBase, models.Model)):
File "/usr/local/lib/python2.7/site-packages/django/utils/six.py", line 808, in __new__
return meta(name, bases, d)
File "/usr/local/lib/python2.7/site-packages/mptt/models.py", line 262, in __new__
cls = super_new(meta, class_name, bases, class_dict)
File "/usr/local/lib/python2.7/site-packages/django/db/models/base.py", line 162, in __new__
new_class.add_to_class(obj_name, obj)
File "/usr/local/lib/python2.7/site-packages/django/db/models/base.py", line 325, in add_to_class
value.contribute_to_class(cls, name)
File "/usr/local/lib/python2.7/site-packages/mptt/managers.py", line 81, in contribute_to_class
super(TreeManager, self).contribute_to_class(model, name)
File "/usr/local/lib/python2.7/site-packages/django/db/models/manager.py", line 120, in contribute_to_class
setattr(model, name, ManagerDescriptor(self))
AttributeError: can't set attribute

Jupyter Notebook won't run python 3 - import pygments error

New to Anaconda and Jupyter Notebooks but for some reason I can't run Jupyter Notebook in my environments running python 3. Every time my terminal displays this:
Traceback (most recent call last):
File "/anaconda3/bin/jupyter-notebook", line 11, in
sys.exit(main())
File "/anaconda3/lib/python3.6/site-packages/jupyter_core/application.py", line 267, in launch_instance
return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
File "/anaconda3/lib/python3.6/site-packages/traitlets/config/application.py", line 657, in launch_instance
app.initialize(argv)
File "", line 2, in initialize
File "/anaconda3/lib/python3.6/site-packages/traitlets/config/application.py", line 87, in catch_config_error
return method(app, *args, **kwargs)
File "/anaconda3/lib/python3.6/site-packages/notebook/notebookapp.py", line 1296, in initialize
self.init_webapp()
File "/anaconda3/lib/python3.6/site-packages/notebook/notebookapp.py", line 1093, in init_webapp
self.jinja_environment_options
File "/anaconda3/lib/python3.6/site-packages/notebook/notebookapp.py", line 167, in init
default_url, settings_overrides, jinja_env_options)
File "/anaconda3/lib/python3.6/site-packages/notebook/notebookapp.py", line 259, in init_settings
nbextensions_path=jupyter_app.nbextensions_path,
File "/anaconda3/lib/python3.6/site-packages/notebook/notebookapp.py", line 807, in nbextensions_path
from IPython.paths import get_ipython_dir
File "/anaconda3/lib/python3.6/site-packages/IPython/init.py", line 54, in
from .core.application import Application
File "/anaconda3/lib/python3.6/site-packages/IPython/core/application.py", line 25, in
from IPython.core import release, crashhandler
File "/anaconda3/lib/python3.6/site-packages/IPython/core/crashhandler.py", line 27, in
from IPython.core import ultratb
File "/anaconda3/lib/python3.6/site-packages/IPython/core/ultratb.py", line 115, in
from IPython.core import debugger
File "/anaconda3/lib/python3.6/site-packages/IPython/core/debugger.py", line 37, in
from IPython.utils import PyColorize
File "/anaconda3/lib/python3.6/site-packages/IPython/utils/PyColorize.py", line 47, in
from .colorable import Colorable
File "/anaconda3/lib/python3.6/site-packages/IPython/utils/colorable.py", line 12, in
import pygments
File "/Library/Python/2.7/site-packages/pygments/init.py", line 46
except TypeError, err:
^
SyntaxError: invalid syntax
Any recommendations on how to correct?

pyglet errors for python3

The pyglet module on my computer isn't working. I've tried a lot of suggestions from others and none of them have worked.
First I tried pip3 install pyglet. But when I tried to run code I got this error:
Traceback (most recent call last):
File "/Users/chervjay/Downloads/gameloop.py", line 5, in <module>
from pyglet.gl import *
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pyglet/gl/__init__.py", line 236, in <module>
import pyglet.window
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pyglet/window/__init__.py", line 1816, in <module>
gl._create_shadow_window()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pyglet/gl/__init__.py", line 205, in _create_shadow_window
_shadow_window = Window(width=1, height=1, visible=False)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pyglet/window/__init__.py", line 493, in __init__
display = get_platform().get_default_display()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pyglet/window/__init__.py", line 1765, in get_default_display
return pyglet.canvas.get_display()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pyglet/canvas/__init__.py", line 82, in get_display
return Display()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pyglet/canvas/carbon.py", line 22, in __init__
import MacOS
ImportError: No module named 'MacOS'
Then I commented out the lines that use MacOS in carbon.py, which are only 2, and ran it again, and this time it said
Traceback (most recent call last):
File "/Users/chervjay/Downloads/gameloop.py", line 132, in <module>
app = App()
File "/Users/chervjay/Downloads/gameloop.py", line 114, in __init__
self.hud = Hud(self.win)
File "/Users/chervjay/Downloads/gameloop.py", line 97, in __init__
color=(1, 1, 1, 0.5),
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pyglet/font/__init__.py", line 348, in __init__
group=self._group)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pyglet/text/layout.py", line 791, in __init__
self.document = document
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pyglet/text/layout.py", line 874, in _set_document
self._init_document()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pyglet/text/layout.py", line 977, in _init_document
self._update()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pyglet/text/layout.py", line 911, in _update
lines = self._get_lines()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pyglet/text/layout.py", line 887, in _get_lines
glyphs = self._get_glyphs()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pyglet/text/layout.py", line 1016, in _get_glyphs
glyphs.extend(font.get_glyphs(text[start:end]))
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pyglet/font/base.py", line 378, in get_glyphs
self.glyphs[c] = glyph_renderer.render(c)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pyglet/font/carbon.py", line 240, in render
text_ucs2 = str_ucs2(text)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pyglet/font/carbon.py", line 194, in str_ucs2
return create_string_buffer(text + '\0')
TypeError: can't concat bytes to str
I have tried
pip3.5 install --upgrade http://pyglet.googlecode.com/archive/tip.zip and got the same errors. I cannot find any other answers.
Please help if you know how to. Thank you.
I got the code I'm trying to run from http://tartley.com/?p=250.

GAE can't generate discovery file

I upgraded my GAE SDK to Version 1.8.5 and cannot generate a discovery file anymore with endpointscfg.py gen_discovery_doc -o.-f rpc .../main.FlyFlap.APi
I get the errors below.
I tried to delete the file google_appengine/lib/cacerts/urlfetch_cacerts.txt and certs.txt like it is suggested here, but it didn't help. Does someone got same problems?
Traceback (most recent call last):
File "/usr/local/bin/endpointscfg.py", line 196, in <module>
run_file(__file__, globals())
File "/usr/local/bin/endpointscfg.py", line 192, in run_file
execfile(script_path, globals_)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/endpointscfg.py", line 472, in <module>
sys.exit(main(sys.argv))
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/endpointscfg.py", line 467, in main
args.callback(args)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/endpointscfg.py", line 348, in _GenDiscoveryDocCallback
output_path, hostname=hostname)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/endpointscfg.py", line 188, in GenDiscoveryDoc
service_configs = GenApiConfig(service_class_names, hostname=hostname)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/endpointscfg.py", line 144, in GenApiConfig
module_name, base_service_class_name = service_class_name.rsplit('.', 1)
ValueError: need more than 1 value to unpack
updated osx and it works again.

Categories

Resources