Getting "NotImplementedError" from Mkdocs serve command [duplicate] - mkdocs

This question already has answers here:
Jupyter Notebook with Python 3.8 - NotImplementedError
(4 answers)
Closed 3 years ago.
I am setting up a documentation using mkdocs but I am getting "NotImplementedError" when runing the "mkdocs serve" command
Note that I am working on windows 10 and installed the Python 3.8.0a3 version
INFO - Building documentation...
INFO - Cleaning site directory
[I 190419 16:50:46 server:298] Serving on http://127.0.0.1:8000
Traceback (most recent call last):
File "c:\python38\lib\runpy.py", line 192, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\python38\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Python38\Scripts\mkdocs.exe\__main__.py", line 9, in <module>
File "c:\python38\lib\site-packages\click\core.py", line 764, in __call__
return self.main(*args, **kwargs)
File "c:\python38\lib\site-packages\click\core.py", line 717, in main
rv = self.invoke(ctx)
File "c:\python38\lib\site-packages\click\core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "c:\python38\lib\site-packages\click\core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "c:\python38\lib\site-packages\click\core.py", line 555, in invoke
return callback(*args, **kwargs)
File "c:\python38\lib\site-packages\mkdocs\__main__.py", line 128, in serve_command
serve.serve(
File "c:\python38\lib\site-packages\mkdocs\commands\serve.py", line 124, in serve
_livereload(host, port, config, builder, site_dir)
File "c:\python38\lib\site-packages\mkdocs\commands\serve.py", line 58, in _livereload
server.serve(root=site_dir, host=host, port=port, restart_delay=0)
File "c:\python38\lib\site-packages\livereload\server.py", line 300, in serve
self.application(
File "c:\python38\lib\site-packages\livereload\server.py", line 255, in application
app.listen(port, address=host)
File "c:\python38\lib\site-packages\tornado\web.py", line 2112, in listen
server.listen(port, address)
File "c:\python38\lib\site-packages\tornado\tcpserver.py", line 152, in listen
self.add_sockets(sockets)
File "c:\python38\lib\site-packages\tornado\tcpserver.py", line 165, in add_sockets
self._handlers[sock.fileno()] = add_accept_handler(
File "c:\python38\lib\site-packages\tornado\netutil.py", line 279, in add_accept_handler
io_loop.add_handler(sock, accept_handler, IOLoop.READ)
File "c:\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:\python38\lib\asyncio\events.py", line 498, in add_reader
raise NotImplementedError
NotImplementedError
I would like to get where the error come from and fix it

It seems like mkdocs does not the support the latest version of python which is 3.8.0a3.
In my case I fixed it by downgrading to 3.7

Related

MkDocs RuntimeError: StopIteration on mkdocs serve

I'm trying to run MkDocs and getting a StopIteration error when running mkdocs serve. This is on a fresh MkDocs project. I've installed MkDocs, ran mkdocs new my-project and then mkdocs serve.
It appears the file_match variable is empty on line 345 of config_options.py but I can't figure out what populates file_match. Is there an additional step between installing MkDocs and then using it that I'm missing?
Thanks for any help. My full stack trace is below.
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/mkdocs/config/config_options.py", line 345, in walk_docs_dir
raise StopIteration
StopIteration
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/bin/mkdocs", line 8, in <module>
sys.exit(cli())
File "/usr/local/lib/python3.8/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.8/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/mkdocs/__main__.py", line 110, in serve_command
serve.serve(
File "/usr/local/lib/python3.8/site-packages/mkdocs/commands/serve.py", line 78, in serve
config = builder()
File "/usr/local/lib/python3.8/site-packages/mkdocs/commands/serve.py", line 67, in builder
config = load_config(
File "/usr/local/lib/python3.8/site-packages/mkdocs/config/base.py", line 151, in load_config
errors, warnings = cfg.validate()
File "/usr/local/lib/python3.8/site-packages/mkdocs/config/base.py", line 84, in validate
self._post_validate()
File "/usr/local/lib/python3.8/site-packages/mkdocs/config/base.py", line 73, in _post_validate
config_option.post_validation(self, key_name=key)
File "/usr/local/lib/python3.8/site-packages/mkdocs/config/config_options.py", line 370, in post_validation
for filename in self.walk_docs_dir(config['docs_dir']):
RuntimeError: generator raised StopIteration

How to fix AttributeError: 'bytes' object has no attribute 'encode' if using mysql?

Django development server was running fine using mysql up to yesterday. But today I get the error AttributeError: 'bytes' object has no attribute 'encode'.
I created a new blank django instance by running django-admin startproject newProject. It runs with 'ENGINE': 'django.db.backends.sqlite3'. But produces same error when I change it to 'ENGINE': 'django.db.backends.mysql'
System specification:
os: manjaro linux
virtual environment python version: 3.6
Django version: 2.2
MariaDB version: 10.3.15-1
Have not updated any related package in last 3 days.
The error:
Watching for file changes with StatReloader
Performing system checks...
System check identified no issues (0 silenced).
Exception in thread django-main-thread:
Traceback (most recent call last):
File "/usr/lib64/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/usr/lib64/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "/srv/http/python/env/env36/lib/python3.6/site-packages/django/utils/autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "/srv/http/python/env/env36/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 120, in inner_run
self.check_migrations()
File "/srv/http/python/env/env36/lib/python3.6/site-packages/django/core/management/base.py", line 453, in check_migrations
executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
File "/srv/http/python/env/env36/lib/python3.6/site-packages/django/db/migrations/executor.py", line 18, in __init__
self.loader = MigrationLoader(self.connection)
File "/srv/http/python/env/env36/lib/python3.6/site-packages/django/db/migrations/loader.py", line 49, in __init__
self.build_graph()
File "/srv/http/python/env/env36/lib/python3.6/site-packages/django/db/migrations/loader.py", line 212, in build_graph
self.applied_migrations = recorder.applied_migrations()
File "/srv/http/python/env/env36/lib/python3.6/site-packages/django/db/migrations/recorder.py", line 73, in applied_migrations
if self.has_table():
File "/srv/http/python/env/env36/lib/python3.6/site-packages/django/db/migrations/recorder.py", line 56, in has_table
return self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor())
File "/srv/http/python/env/env36/lib/python3.6/site-packages/django/db/backends/base/base.py", line 256, in cursor
return self._cursor()
File "/srv/http/python/env/env36/lib/python3.6/site-packages/django/db/backends/base/base.py", line 233, in _cursor
self.ensure_connection()
File "/srv/http/python/env/env36/lib/python3.6/site-packages/django/db/backends/base/base.py", line 217, in ensure_connection
self.connect()
File "/srv/http/python/env/env36/lib/python3.6/site-packages/django/db/backends/base/base.py", line 197, in connect
self.init_connection_state()
File "/srv/http/python/env/env36/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 232, in init_connection_state
if self.features.is_sql_auto_is_null_enabled:
File "/srv/http/python/env/env36/lib/python3.6/site-packages/django/utils/functional.py", line 80, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/srv/http/python/env/env36/lib/python3.6/site-packages/django/db/backends/mysql/features.py", line 82, in is_sql_auto_is_null_enabled
cursor.execute('SELECT ##SQL_AUTO_IS_NULL')
File "/srv/http/python/env/env36/lib/python3.6/site-packages/django/db/backends/utils.py", line 103, in execute
sql = self.db.ops.last_executed_query(self.cursor, sql, params)
File "/srv/http/python/env/env36/lib/python3.6/site-packages/django/db/backends/mysql/operations.py", line 147, in last_executed_query
query = query.encode(errors='replace')
AttributeError: 'bytes' object has no attribute 'encode'
How do I fix this ?
Thank to Martijn, I have fixed this.
In the source, stable 2.2 branch line 146 of django/db/backends/mysql/operations.py is
query = query.decode(errors='replace')
In my system path/to/virtualenv/django/db/backends/mysql/operations.py was like
# query = query.decode(errors='replace')
query = query.encode(errors='replace')
I changed it to
query = query.decode(errors='replace')
# query = query.encode(errors='replace')
It is working correctly now.

Getting django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module, while trying to perform the first migration

I am setting up a Django backend for my application. I am trying to change the default sqlite database to mysql. While performing the first migration, I get the following error:
Traceback (most recent call last): File
"/Users/user1/djangoApp/djangoProject/env/lib/python3.6/site-packages/django/db/backends/mysql/base.py",
line 15, in
import MySQLdb as Database File "/Users/user1/djangoApp/djangoProject/env/lib/python3.6/site-packages/MySQLdb/init.py",
line 18, in
import _mysql ImportError: dlopen(/Users/user1/djangoApp/djangoProject/env/lib/python3.6/site-packages/_mysql.cpython-36m-darwin.so,
2): Library not loaded: #rpath/libmysqlclient.21.dylib Referenced
from:
/Users/user1/djangoApp/djangoProject/env/lib/python3.6/site-packages/_mysql.cpython-36m-darwin.so
Reason: image not found
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "manage.py", line 15, in
execute_from_command_line(sys.argv) File "/Users/user1/djangoApp/djangoProject/env/lib/python3.6/site-packages/django/core/management/init.py",
line 381, in execute_from_command_line
utility.execute() File "/Users/user1/djangoApp/djangoProject/env/lib/python3.6/site-packages/django/core/management/init.py",
line 357, in execute
django.setup() File "/Users/user1/djangoApp/djangoProject/env/lib/python3.6/site-packages/django/init.py",
line 24, in setup
apps.populate(settings.INSTALLED_APPS) File "/Users/user1/djangoApp/djangoProject/env/lib/python3.6/site-packages/django/apps/registry.py",
line 112, in populate
app_config.import_models() File "/Users/user1/djangoApp/djangoProject/env/lib/python3.6/site-packages/django/apps/config.py",
line 198, in import_models
self.models_module = import_module(models_module_name) File "/Users/user1/djangoApp/djangoProject/env/lib/python3.6/importlib/init.py",
line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level) File "", line 994, in _gcd_import File
"", line 971, in _find_and_load File
"", line 955, in _find_and_load_unlocked
File "", line 665, in _load_unlocked
File "", line 678, in
exec_module File "", line 219, in
_call_with_frames_removed File "/Users/user1/djangoApp/djangoProject/env/lib/python3.6/site-packages/django/contrib/auth/models.py",
line 2, in
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager File
"/Users/user1/djangoApp/djangoProject/env/lib/python3.6/site-packages/django/contrib/auth/base_user.py",
line 47, in
class AbstractBaseUser(models.Model): File "/Users/user1/djangoApp/djangoProject/env/lib/python3.6/site-packages/django/db/models/base.py",
line 101, in new
new_class.add_to_class('_meta', Options(meta, app_label)) File "/Users/user1/djangoApp/djangoProject/env/lib/python3.6/site-packages/django/db/models/base.py",
line 305, in add_to_class
value.contribute_to_class(cls, name) File "/Users/user1/djangoApp/djangoProject/env/lib/python3.6/site-packages/django/db/models/options.py",
line 203, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length()) File
"/Users/user1/djangoApp/djangoProject/env/lib/python3.6/site-packages/django/db/init.py",
line 33, in getattr
return getattr(connections[DEFAULT_DB_ALIAS], item) File "/Users/user1/djangoApp/djangoProject/env/lib/python3.6/site-packages/django/db/utils.py",
line 202, in getitem
backend = load_backend(db['ENGINE']) File "/Users/user1/djangoApp/djangoProject/env/lib/python3.6/site-packages/django/db/utils.py",
line 110, in load_backend
return import_module('%s.base' % backend_name) File "/Users/user1/djangoApp/djangoProject/env/lib/python3.6/importlib/init.py",
line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level) File "/Users/user1/djangoApp/djangoProject/env/lib/python3.6/site-packages/django/db/backends/mysql/base.py",
line 20, in
) from err django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.
OS:macOS Mojave
Framework: Django
I am using a virtualenv
I have already installed "mysqlclient" using the command
pip3 install mysqlclient
I have verified that the mysqlclient folder exists under the installed location.
I have the mysql server up and running.
I have tried many available solutions online but nothing works
To reproduce:
1 - Start a django project using
"django-admin startproject djangoApp"
2 - Install and start the mysql server.
3 - Update the settings.py file of the entry application to the following
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'djangoApp',
'USER': 'root',
'PASSWORD': 'password',
'HOST': 'localhost',
'PORT': ''
}
}
4 - Now try to migrate using
python manage.py migrate
Expected:The migration should be successful
Actual:Migration fails with the given error
I am new to Django
I needed to symlink the lib files to the /usr/local/lib directory.
Fourth answer in the link worked for me
Thank you #Mohit Harshan #Daniel Rosema for taking time out to help me

Django 1.6 w/ gunicorn - OperationalError: (2006, 'MySQL server has gone away')

In the process of upgrading to Django 1.6 I've started to get a frequent OperationalError: (2006, 'MySQL server has gone away') message on requests to the gunicorn server I use to run the django app. These errors occur instantly from the moment the server is started, on requests that should only take a second which makes me doubt that it is a timeout issue. This error isn't present on the old 1.4 branch of the project and the 1.6 branch doesn't behave this way if it's served simply through django-admin.py runserver.
I generally run gunicorn through an sv process (though it errors if I run it manually too) with the command django-admin.py run_gunicorn --workers=4 -b localhost:8000 which results in many requests, even ones for static media, returning with:
[ERROR] 2015-07-29 14:30:27,931 - gunicorn.error:260 - Error handling request
Traceback (most recent call last):
File "/opt/envs/maplecroft/local/lib/python2.7/site-packages/gunicorn/workers/sync.py", line 125, in handle_request
respiter = self.wsgi(environ, resp.start_response)
File "/opt/envs/maplecroft/local/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 187, in __call__
self.load_middleware()
File "/opt/envs/maplecroft/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 47, in load_middleware
mw_instance = mw_class()
File "/opt/envs/maplecroft/local/lib/python2.7/site-packages/django/middleware/locale.py", line 24, in __init__
for url_pattern in get_resolver(None).url_patterns:
File "/opt/envs/maplecroft/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 365, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/opt/envs/maplecroft/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 360, in urlconf_module
self._urlconf_module = import_module(self.urlconf_name)
File "/opt/envs/maplecroft/local/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module
__import__(name)
File "/opt/apps/maplecroft/versions/current/websites/maplecroft/urls.py", line 2, in <module>
from maplecroft.views import RiskAtlasesLandingView
File "/opt/apps/maplecroft/versions/current/maplecroft/views.py", line 40, in <module>
import maplecroft.search as _search
File "/opt/apps/maplecroft/versions/current/maplecroft/search.py", line 71, in <module>
class MaplecroftSearchForm(SearchForm):
File "/opt/apps/maplecroft/versions/current/maplecroft/search.py", line 111, in MaplecroftSearchForm
choices=model_choices(),
File "/opt/apps/maplecroft/versions/current/maplecroft/search.py", line 57, in model_choices
for category in reversed(Category.objects.filter(parent=None)):
File "/opt/envs/maplecroft/local/lib/python2.7/site-packages/django/db/models/query.py", line 77, in __len__
self._fetch_all()
File "/opt/envs/maplecroft/local/lib/python2.7/site-packages/django/db/models/query.py", line 857, in _fetch_all
self._result_cache = list(self.iterator())
File "/opt/envs/maplecroft/local/lib/python2.7/site-packages/django/db/models/query.py", line 220, in iterator
for row in compiler.results_iter():
File "/opt/envs/maplecroft/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 713, in results_iter
for rows in self.execute_sql(MULTI):
File "/opt/envs/maplecroft/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 786, in execute_sql
cursor.execute(sql, params)
File "/opt/envs/maplecroft/local/lib/python2.7/site-packages/django/db/backends/util.py", line 69, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/opt/envs/maplecroft/local/lib/python2.7/site-packages/django/db/backends/util.py", line 53, in execute
return self.cursor.execute(sql, params)
File "/opt/envs/maplecroft/local/lib/python2.7/site-packages/django/db/utils.py", line 99, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/opt/envs/maplecroft/local/lib/python2.7/site-packages/django/db/backends/util.py", line 53, in execute
return self.cursor.execute(sql, params)
File "/opt/envs/maplecroft/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 124, in execute
return self.cursor.execute(query, args)
File "/opt/envs/maplecroft/local/lib/python2.7/site-packages/MySQLdb/cursors.py", line 174, in execute
self.errorhandler(self, exc, value)
File "/opt/envs/maplecroft/local/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
raise errorclass, errorvalue
OperationalError: (2006, 'MySQL server has gone away')
However, if I drop to --workers=1 everything seems to run smoothly so my current thoughts are that it is an issue with the threaded workers feature of gunicorn?
Edit: I just tried upgrading gunicorn to the latest version (was on 0.17.2) but that doesn't seem to have made a difference.
I am wondering if this question: https://serverfault.com/questions/407612/error-2006-mysql-server-has-gone-away is relevant, but struggling to overlay it with my current issues
It appears that it was the gunicorn version after all- I tried upgrading gunicorn but was still using the django-admin.py run_gunicorn method of starting the server. Upgrading gunicorn and switching to the non-deprecated gunicorn wsgi:application method solved it.

Question regarding Mercurial 1.8.2

i have a big problem with Mercurial 1.8.2 on Mac OSX 10.6
I used for long time with a lot of projects. Now i haven't used for about 4 weeks. Today i tried and OSX crashed with "hg add" command.
So i googled a little bit and found out, that there was a bug in OSX 10.5 where i have to deactive the SET LOCAL in Terminal Preferences.
I've done so - now
hg add
hg commit -m "message"
works, but when i run
hg push
i get the following error message where i find no information about
** unknown exception encountered, please report by visiting
** http://mercurial.selenic.com/wiki/BugTracker
** Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49) [GCC 4.2.1 (Apple Inc. build 5646)]
** Mercurial Distributed SCM (version 1.8.2+20110401)
** Extensions loaded:
Traceback (most recent call last):
File "/usr/local/bin/hg", line 38, in <module>
mercurial.dispatch.run()
File "/Library/Python/2.6/site-packages/mercurial/dispatch.py", line 16, in run
sys.exit(dispatch(sys.argv[1:]))
File "/Library/Python/2.6/site-packages/mercurial/dispatch.py", line 36, in dispatch
return _runcatch(u, args)
File "/Library/Python/2.6/site-packages/mercurial/dispatch.py", line 58, in _runcatch
return _dispatch(ui, args)
File "/Library/Python/2.6/site-packages/mercurial/dispatch.py", line 601, in _dispatch
cmdpats, cmdoptions)
File "/Library/Python/2.6/site-packages/mercurial/dispatch.py", line 406, in runcommand
ret = _runcommand(ui, options, cmd, d)
File "/Library/Python/2.6/site-packages/mercurial/dispatch.py", line 655, in _runcommand
return checkargs()
File "/Library/Python/2.6/site-packages/mercurial/dispatch.py", line 609, in checkargs
return cmdfunc()
File "/Library/Python/2.6/site-packages/mercurial/dispatch.py", line 598, in <lambda>
d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
File "/Library/Python/2.6/site-packages/mercurial/util.py", line 433, in check
return func(*args, **kwargs)
File "/Library/Python/2.6/site-packages/mercurial/commands.py", line 3002, in push
ui.status(_('pushing to %s\n') % url.hidepassword(dest))
File "/Library/Python/2.6/site-packages/mercurial/demandimport.py", line 75, in __getattribute__
self._load()
File "/Library/Python/2.6/site-packages/mercurial/demandimport.py", line 47, in _load
mod = _origimport(head, globals, locals)
File "/Library/Python/2.6/site-packages/mercurial/url.py", line 354, in <module>
class httpconnection(keepalive.HTTPConnection):
File "/Library/Python/2.6/site-packages/mercurial/demandimport.py", line 75, in __getattribute__
self._load()
File "/Library/Python/2.6/site-packages/mercurial/demandimport.py", line 47, in _load
mod = _origimport(head, globals, locals)
File "/Library/Python/2.6/site-packages/mercurial/keepalive.py", line 361, in <module>
class HTTPResponse(httplib.HTTPResponse):
File "/Library/Python/2.6/site-packages/mercurial/demandimport.py", line 76, in __getattribute__
return getattr(self._module, attr)
AttributeError: 'module' object has no attribute 'HTTPResponse'
Do you have any ideas?
Thanks,
Sascha
I think you should do exactly as said in the error message :
** unknown exception encountered, please report by visiting
** https://www.mercurial-scm.org/wiki/BugTracker