I recently refactored a lot of code and wanted a clean environment, so I deleted and recreated the database schema, created a new venv, and installed dependencies from pip3 one-by-one so I didn't have any superfluous packages left over from the old environment. I quickly installed half a dozen packages, then migrate passed. However, runserver complaines that axes.middleware isn't found (it is installed).
I have django-axes 2.2.0 installed in my virtual environment (Edit: python 3.5, django 1.10).
I verfied the installation was present with pip3 freeze, after
uninstalling and reinstalling just to be sure. django-axes==2.2.0
I have axes listed in INSTALLED_APPS
I have axes.middleware.FailedLoginMiddleware listed in MIDDLEWARE_CLASSES. Note that if I comment out this line, django doesn't attempt to import axes.middleware and consequently runserver succeeds.
I can do import axes; axes.get_version() and also from axes.decorators import watch_login on the shell, so clearly axes is available to the environment.
What is going wrong here?
Traceback from ./manage.py runserver:
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7f2d43a381e0>
Traceback (most recent call last):
File "/webapps/my_app/lib/python3.5/site-packages/django/core/servers/basehttp.py", line 49, in get_internal_wsgi_application
return import_string(app_path)
File "/webapps/my_app/lib/python3.5/site-packages/django/utils/module_loading.py", line 20, in import_string
module = import_module(module_path)
File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 665, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "/webapps/my_app/wsgi.py", line 14, in <module>
application = get_wsgi_application()
File "/webapps/my_app/lib/python3.5/site-packages/django/core/wsgi.py", line 14, in get_wsgi_application
return WSGIHandler()
File "/webapps/my_app/lib/python3.5/site-packages/django/core/handlers/wsgi.py", line 153, in __init__
self.load_middleware()
File "/webapps/my_app/lib/python3.5/site-packages/django/core/handlers/base.py", line 56, in load_middleware
mw_class = import_string(middleware_path)
File "/webapps/my_app/lib/python3.5/site-packages/django/utils/module_loading.py", line 20, in import_string
module = import_module(module_path)
File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 956, in _find_and_load_unlocked
ImportError: No module named 'axes.middleware'
As of 2.0.0, django-axes has default_app_config so you can just use axes in INSTALLED_APPS without installing middleware. Hence, delete the relevant MIDDLEWARE_CLASSES line in settings.py
Related
I'm using,
Python: 3.8,
Django: 3.0,
django-paypal: 1.0.0
I'm trying to implement a simple Payment Gateway using Django-Paypal lib.
And I'm getting this error during the migration.....
(project-venv) PS J:\jaimin (E)\Programming Practice\Django\Payment Gateway using Paypal\simple_ecommerce\django_project> py -3 .\manage.py migrate
Traceback (most recent call last):
File ".\manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\jaimi\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
utility.execute()
File "C:\Users\jaimi\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\management\__init__.py", line 377, in execute
django.setup()
File "C:\Users\jaimi\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\jaimi\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\apps\registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "C:\Users\jaimi\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\apps\config.py", line 116, in create
mod = import_module(mod_path)
File "C:\Users\jaimi\AppData\Local\Programs\Python\Python38-32\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'paypal'
And here is my settings.py
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'ecommerce_app',
'paypal.standard.ipn',
]
What can I do Now?.....
it is happening because of circular import in init.py file
follow the steps :
don't install this ...maybe u have done it ...
pip uninstall paypal
no need to delete migrations unistall it and reinstall it properly
pip install django-paypal
don't forget to add " - " in that because this is the reason for that issue ...
this worked for me !
try and give a upvote if works . Thank You in advance
You just need to install django-paypal.
pip install django-paypal
I recently upgraded my pip to 19.3. When I did that I cannot use any pip commands. OS - Mac
When I googled and researched more, most of the suggestions were to downgrade the pip package. However, even when I tried that I am getting the same result. In fact, force installs or uninstall or sudo commands nothing works.
Traceback (most recent call last):
File "/Users/.virtualenvs/myvenv/bin/pip", line 10, in <module>
sys.exit(main())
File "/Users/.virtualenvs/myvenv/lib/python3.7/site-packages/pip/_internal/main.py", line 45, in main
command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
File "/Users/.virtualenvs/myvenv/lib/python3.7/site-packages/pip/_internal/commands/__init__.py", line 96, in create_command
module = importlib.import_module(module_path)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/Users/.virtualenvs/myvenv/lib/python3.7/site-packages/pip/_internal/commands/install.py", line 24, in <module>
from pip._internal.cli.req_command import RequirementCommand
File "/Users/.virtualenvs/myvenv/lib/python3.7/site-packages/pip/_internal/cli/req_command.py", line 21, in <module>
from pip._internal.operations.prepare import RequirementPreparer
File "/Users/.virtualenvs/myvenv/lib/python3.7/site-packages/pip/_internal/operations/prepare.py", line 17, in <module>
from pip._internal.download import unpack_url
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 668, in _load_unlocked
File "<frozen importlib._bootstrap>", line 638, in _load_backward_compatible
File "/Users/.virtualenvs/myvenv/lib/python3.7/site-packages/wrapt/importer.py", line 158, in load_module
notify_module_loaded(module)
File "/Users/.virtualenvs/myvenv/lib/python3.7/site-packages/wrapt/decorators.py", line 443, in _synchronized
return wrapped(*args, **kwargs)
File "/Users/.virtualenvs/myvenv/lib/python3.7/site-packages/wrapt/importer.py", line 136, in notify_module_loaded
hook(module)
File "/Users/.virtualenvs/myvenv/lib/python3.7/site-packages/pip_system_certs/wrapt_pip.py", line 8, in apply_patches
override_ssl_handler(download)
File "/Users/.virtualenvs/myvenv/lib/python3.7/site-packages/pip_system_certs/wrapt_pip.py", line 17, in override_ssl_handler
class SslContextHttpAdapter(download.HTTPAdapter):
AttributeError: module 'pip._internal.download' has no attribute 'HTTPAdapter'
Can somebody help, please?
This appears to be because you installed the pip-system-certs package, which hooks into pip internals in a way that was never supported. This promptly broke as soon as you updated pip and the stuff pip-system-certs wanted to mess with got changed.
You will at least need to get rid of pip-system-certs. It looks like it was installed in a virtualenv, so you can probably just deactivate the env and make a new one... but if so, it seems like you would have already tried that. If you didn't already try that, make sure to try it next time! If you did already try that, then you probably wrecked more stuff than we can see, and you may need more drastic measures, such as a full Python reinstall.
What worked for me was to go to <your conda environment>\Lib\site-packages and remove all occurences of pip-system-certs. In my case it was one file and two folders.
pip-tools~=4.2.0 is compatible with pip>=19.3
I have this new remote job, where I had to clone all the code from a repository, and I have to make an export of the database from MySQL hosted in RDS.
The first problem is that when I set up the configuration to start the app, it raise an error telling me this:
Run Configuration Error: Broken configuration due to unavailable plugin or invalid configuration data.
The other thing is that I already have the data dumped and set up in my local storage (the app works this way, is no longer using AWS Cloud) but when I try to do an python manage.py migrate , this error comes up...
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\Tony-App\Documents\App\venv\lib\site-packages\django\core\management\__init__.py", line 338, in execute_from_command_line
utility.execute()
File "C:\Users\Tony-App\Documents\App\venv\lib\site-packages\django\core\management\__init__.py", line 312, in execute
django.setup()
File "C:\Users\Tony-App\Documents\App\venv\lib\site-packages\django\__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\Tony-App\Documents\App\venv\lib\site-packages\django\apps\registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "C:\Users\Tony-App\Documents\App\venv\lib\site-packages\django\apps\config.py", line 86, in create
module = import_module(entry)
File "C:\Users\Tony-App\AppData\Local\Programs\Python\Python37-32\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\Tony-App\Documents\App\venv\lib\site-packages\liststyle\__init__.py", line 1, in <module>
from admin import ListStyleAdminMixin
ModuleNotFoundError: No module named 'admin'
First, django-liststyle is a dependency in your project, so make sure it has been installed.
py -m pip install django-liststyle
Second, make sure to add that package to INSTALLED_APPS:
INSTALLED_APPS = {
...
'liststyle',
...
'django.contrib.admin',
...
}
Third, I think the error you are getting is because of the way you are importing ListStyleAdminMixin. This should be the correct way to import it:
from liststyle.admin import ListStyleAdminMixin
I have created a Django Project in Eclipse. When I run manage.py from the commad line, it runs just fine, but when I run manage.py in Eclipse I get the Error Message below. The Project lives in an virtual environment that is stored at "C:\Users\Johanna\Envs\myproject\Scripts\python.exe".
Traceback (most recent call last):
File "C:\Users\Johanna\workspace\Hide and Seek Game\manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\Johanna\Envs\myproject\lib\site-packages\django\core\management\__init__.py", line 353, in execute_from_command_line
utility.execute()
File "C:\Users\Johanna\Envs\myproject\lib\site-packages\django\core\management\__init__.py", line 302, in execute
settings.INSTALLED_APPS
File "C:\Users\Johanna\Envs\myproject\lib\site-packages\django\conf\__init__.py", line 55, in __getattr__
self._setup(name)
File "C:\Users\Johanna\Envs\myproject\lib\site-packages\django\conf\__init__.py", line 43, in _setup
self._wrapped = Settings(settings_module)
File "C:\Users\Johanna\Envs\myproject\lib\site-packages\django\conf\__init__.py", line 99, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "C:\Users\Johanna\Envs\myproject\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 944, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 956, in _find_and_load_unlocked
ImportError: No module named 'Hide and Seek Game'
I am happy for suggestions why this is the case.
I solved this problem by going to the project properties -> PyDev Django and setting the Django settings module.
I have two Python VE's one in which I created a Django project that is located on the Desktop. I recently created another VE to start another Django project. However, when I run django-admin startproject projectname within the new VE, I get an ImportError saying that the other Django app couldn't be imported.
What would be trying to import my old app? Why would this be happening?
I am running Django 1.9 on Debian 8.
Traceback (most recent call last):
File "/home/lie/.virtualenvs/tagger/bin/django-admin", line 11, in <module>
sys.exit(execute_from_command_line())
File "/home/lie/.virtualenvs/tagger/lib/python3.4/site-packages/django/core/management/__init__.py", line 350, in execute_from_command_line
utility.execute()
File "/home/lie/.virtualenvs/tagger/lib/python3.4/site-packages/django/core/management/__init__.py", line 302, in execute
settings.INSTALLED_APPS
File "/home/lie/.virtualenvs/tagger/lib/python3.4/site-packages/django/conf/__init__.py", line 55, in __getattr__
self._setup(name)
File "/home/lie/.virtualenvs/tagger/lib/python3.4/site-packages/django/conf/__init__.py", line 43, in _setup
self._wrapped = Settings(settings_module)
File "/home/lie/.virtualenvs/tagger/lib/python3.4/site-packages/django/conf/__init__.py", line 99, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/home/lie/.virtualenvs/tagger/lib/python3.4/importlib/__init__.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2212, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2224, in _find_and_load_unlocked
ImportError: No module named 'AUVSIDataProc'
I found there was an Environment Variable called DJANGO_SETTINGS_MODULE.
I just unset it: export DJANGO_SETTINGS_MODULE="". and I was able to start a new project.