Django Error on Travis: RuntimeError: populate() isn't reentrant [closed] - python

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
I am maintaining a project, with Travis CI implemented, and from one day. All my builds start failing without me touching anything or any dependence update ...
I guess that Travis changed something, I tried to investigate, but honestly I have no clue.
If I run a previous build which perfectly worked, now it fails with this everytime I call python manage.py ##whatever##
$ python manage.py collectstatic --noinput
Traceback (most recent call last):
File "manage.py", line 35, in <module>
execute_from_command_line(sys.argv)
File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/core/management/__init__.py", line 357, in execute
django.setup()
File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/apps/registry.py", line 81, in populate
raise RuntimeError("populate() isn't reentrant")
RuntimeError: populate() isn't reentrant
By the way, I obtain the exact same error with Python 3.6 and 3.5.
$ python manage.py collectstatic --noinput
Traceback (most recent call last):
File "manage.py", line 35, in <module>
execute_from_command_line(sys.argv)
File "/home/travis/virtualenv/python3.5.6/lib/python3.5/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/home/travis/virtualenv/python3.5.6/lib/python3.5/site-packages/django/core/management/__init__.py", line 357, in execute
django.setup()
File "/home/travis/virtualenv/python3.5.6/lib/python3.5/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/travis/virtualenv/python3.5.6/lib/python3.5/site-packages/django/apps/registry.py", line 81, in populate
raise RuntimeError("populate() isn't reentrant")
RuntimeError: populate() isn't reentrant
And naturally, this issue is impossible to reproduce on my own machine ... It's running just fine locally.
Additional Information:
If I take a former build which already passed without any issue:
Link: Travis Build #1336
And I decide to relaunch the build, as you can see the builds are now failing for an obscure reason...
Any idea how to solve this issue ?

Related

Why does Dash throw a TypeError when debugging through PyCharm? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
When I try to run a Dash app from PyCharm in debug mode I keep getting the below TypeError. What can I do to fix this so that I can break on breakpoints in PyCharm?
I'm using: Dash 2.0.0, Python 3.9.6, PyCharm Community Edition 2021.1.3, Windows 10.
Connected to pydev debugger (build 212.4746.96)
Traceback (most recent call last):
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2021.1.3\plugins\python-ce\helpers\pydev\pydevd.py", line 1483, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2021.1.3\plugins\python-ce\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "C:/redacted/dashboard/dashboard.py", line 170, in <module>
_app = dash.Dash(__name__, external_stylesheets=[dbc.themes.DARKLY])
File "C:\redacted\.venv\lib\site-packages\dash\dash.py", line 304, in __init__
self.server = flask.Flask(name) if server else None
File "C:\redacted\.venv\lib\site-packages\flask\app.py", line 406, in __init__
instance_path = self.auto_find_instance_path()
File "C:\redacted\.venv\lib\site-packages\flask\app.py", line 638, in auto_find_instance_path
prefix, package_path = find_package(self.import_name)
File "C:\redacted\.venv\lib\site-packages\flask\scaffold.py", line 850, in find_package
package_path = _find_package_path(root_mod_name)
File "C:\redacted\.venv\lib\site-packages\flask\scaffold.py", line 801, in _find_package_path
return os.path.dirname(next(iter(spec.submodule_search_locations)))
TypeError: 'NoneType' object is not iterable
python-BaseException
Process finished with exit code 1
Here's how I've setup my PyCharm run configuration:
Likely a bug in PyCharm. Solved by upgrading PyCharm to 2021.2.3.

Error from Python job scheduling module each time I stop server

My models.py file in my Django project contains the code based on the following tutorial:
import schedule
import time
def job():
print("I'm working...")
schedule.every(3).seconds.do(job)
while True:
schedule.run_pending()
time.sleep(1)
Each time I run the application, I get the following output:
"C:\Program Files (x86)\JetBrains\PyCharm 2016.1\bin\runnerw.exe" C:\Python27\python.exe D:/blogpodapi/manage.py runserver 8000
I'm working...
I'm working...
It works as expected, but whenever I close the application, I get the following output:
Traceback (most recent call last):
File "D:/blogpodapi/manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 353, in execute_from_command_line
utility.execute()
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 302, in execute
settings.INSTALLED_APPS
File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 55, in __getattr__
self._setup(name)
File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 43, in _setup
self._wrapped = Settings(settings_module)
File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 99, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "C:\Python27\lib\importlib\__init__.py", line 37, in import_module
__import__(name)
File "D:\blogpodapi\blogpodapi\__init__.py", line 13, in <module>
time.sleep(1)
KeyboardInterrupt
Process finished with exit code 1
Further to this, my server does not start... as when I remove the abovementioned code, I get the following output:
"C:\Program Files (x86)\JetBrains\PyCharm 2016.1\bin\runnerw.exe" C:\Python27\python.exe D:/blogpodapi/manage.py runserver 8000
Performing system checks...
System check identified no issues (0 silenced).
August 14, 2016 - 14:00:32
Django version 1.9.6, using settings 'blogpodapi.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
I am not to sure what is causing this error. The server won't start when the scheduler is in place and there is an error each time I try to stop the server when it is in place. Ideally I would like the server to start as expected, and the scheduled tasks to start running after this. Any recommendations on how I can fix this?
The entirety of the models.py file can be found here: http://pastebin.com/0DwQWqM8.
There does not seem to be any problem.
The Traceback you posted reports a KeyboardInterrupt which is commonly used to force-quit an application and thus completely normal.
The server also seems to have started.
Have you tried visiting http://127.0.0.1:8000/ while the server is running?
The last line just tells you to use CTRL-C in the command line if you want to stop the server.

Populate() isn't reentrant Django Google App Engine

I'm running google app engine, python 2.7, and importing Django 1.8. After pulling in python-firebase (-e git://github.com/ozgur/python-firebase.git#egg=python-firebase), I get the following error
Traceback (most recent call last):
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
File "/base/data/home/apps/s~trac-us/1.392706776803493304/main.py", line 25, in <module>
application = django.core.wsgi.get_wsgi_application()
File "/base/data/home/apps/s~trac-us/1.392706776803493304/libs/django/core/wsgi.py", line 14, in get_wsgi_application
django.setup()
File "/base/data/home/apps/s~trac-us/1.392706776803493304/libs/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/base/data/home/apps/s~trac-us/1.392706776803493304/libs/django/apps/registry.py", line 78, in populate
raise RuntimeError("populate() isn't reentrant")
RuntimeError: populate() isn't reentrant
Many of the other solutions have suggested to alter the wsgi.py file, because django gets installed right before deployment in the requirements.txt file.
Ultimately this leads to the server stating: "Error: Server Error
The server encountered an error and could not complete your request.
Please try again in 30 seconds." How can I resolve this?
I was facing the same issue and removing the database configuration for a sqlite database connection fixed this for me. Issue might've been that the sqlite library that django is looking for underneath was not present and thus, removing the sqlite configuration fixed that for me. pff, I was not using sqlite in that project any way.
However, as per a google groups thread I landed on, the error:
raise RuntimeError("populate() isn't reentrant")
RuntimeError: populate() isn't reentrant
is caused when one of the application that you're trying to load leads to an error within, which leads to this. I'll provide a link to the thread here, and although it's different from your problem(you probably solved it already), you might still find it useful:
Link to groups thread
The answer I was talking about
Hope you find it useful.

Django 1.8- Stack trace referencing file that doesn't exist

When I run a custom command in Django 1.8.3, I'm getting the following stack trace:
(env)MacBook-Air:backend user$ python manage.py questions
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Users/user/WeVote/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "/Users/user/WeVote/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 330, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/user/WeVote/env/lib/python2.7/site-packages/django/core/management/base.py", line 393, in run_from_argv
self.execute(*args, **cmd_options)
File "/Users/user/WeVote/env/lib/python2.7/site-packages/django/core/management/base.py", line 444, in execute
output = self.handle(*args, **options)
File "/Users/user/WeVote/wevote/questions/management/commands/questions.py", line 14, in handle
OSError: [Errno 2] No such file or directory: '/Users/user/WeVote/backend/questions/question_files'
The error is valid, that filepath doesn't exist. I go to look at line 14 in questions.py, except that file doesn't exist. Boo.
As you can see, the file structure is different in referencing questions.py file. As some point, I'm sure that was the file structure. I also wrote this in Djano 1.7 and upgraded to 1.8. However, all the other custom commands (written both before and after the upgrade) are working just fine.
Just as a sanity check, I tried a
cd /Users/user/WeVote/wevote/questions/management/commands/
Nope. This is an issue because when I now edit my properly-located questions.py in the management/commands directory, the changes aren't reflected. It's like it's reading a cached version and location of this file.
Also tried deleting and rebuilding both virtualenv and database. No love on either. I'm sure it's something simple I'm overlooking, but I'm out of ideas.
Reference for anyone coming afterwards: The comments from yuvi and Paul Collingwood above succeeded in solving my issue. I ran
find . -name '*.pyc' -delete
and the next time I ran questions.py everything worked well. Thanks both for your comments.

Change requires_model_validation in a project

I've uploaded from django 1.6 to django 1.7 and from python 3.2.3 to python 3.4.1.
Suddenly when I try to run the makemessages command to catch the translating messages I find this error:
django.core.exceptions.ImproperlyConfigured: Command Command defines both "requires_model_validation" and "requires_system_checks", which is illegal. Use only "requires_system_checks".
I've googled it and I don't find where or what I should edit. In fact I've never used this parameter so...
Any idea?
The traceback
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/pablo/Workspaces/milao/lib/python3.4/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/home/pablo/Workspaces/milao/lib/python3.4/site-packages/django/core/management/__init__.py", line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/pablo/Workspaces/milao/lib/python3.4/site-packages/django/core/management/__init__.py", line 238, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/home/pablo/Workspaces/milao/lib/python3.4/site-packages/django/core/management/__init__.py", line 42, in load_command_class
return module.Command()
File "/home/pablo/Workspaces/milao/lib/python3.4/site-packages/django/core/management/base.py", line 228, in __init__
'"requires_system_checks".' % self.__class__.__name__)
django.core.exceptions.ImproperlyConfigured: Command Command defines both "requires_model_validation" and "requires_system_checks", which is illegal. Use only "requires_system_checks".
Finally I've found the answer and it's not related with django core at all. I was not using any command. However one of my installed apps was using it. In this case it's django vinaigrette.
I'll upload the patch ASAP to port this app to django 1.7.
Regards.
Thanks to #Paul Pepper for pointing me in the right direction. For me it was Django devserver causing the issue and updating to the latest version fixed it for me:
pip install -e git://github.com/dcramer/django-devserver.git#HEAD#egg=django-devserver
HEAD was commit e6c882fc11fba013b85d37f04db8f11b531eda9a at the time of this writing.

Categories