ModuleNotFoundError: No module named 'paypal' - python

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

Related

Django error by adding Channels to settings.py INSTALLED_APPS

I'm trying to learn Django channels, so for the beginning, I simply installed and added "channels" to the Django project, INSTALLED_APPS in the settings.py, as showing below.
Installed channels with pip:
pip install channels
Installed versions:
channels 3.0.3
daphne 3.0.1
Django 2.2.13
settings.py > INSTALLED_APPS:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
...
'django_ace',
'channels', # added this
]
I just installed one package and added one line to the settings.py so this shouldn't be an error, but when I try to run the server python .\source\manage.py runserver I got an error as showing below.
> python .\source\manage.py runserver --noreload
Traceback (most recent call last):
File ".\source\manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "C:\pg\django\win\simple-django-login-and-register\venv\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
utility.execute()
File "C:\pg\django\win\simple-django-login-and-register\venv\lib\site-packages\django\core\management\__init__.py", line 357, in execute
django.setup()
File "C:\pg\django\win\simple-django-login-and-register\venv\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\pg\django\win\simple-django-login-and-register\venv\lib\site-packages\django\apps\registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "C:\pg\django\win\simple-django-login-and-register\venv\lib\site-packages\django\apps\config.py", line 116, in create
mod = import_module(mod_path)
File "c:\python37\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:\pg\django\win\simple-django-login-and-register\venv\lib\site-packages\channels\apps.py", line 4, in <module>
import daphne.server
File "C:\pg\django\win\simple-django-login-and-register\venv\lib\site-packages\daphne\server.py", line 32, in <module>
from .ws_protocol import WebSocketFactory
File "C:\pg\django\win\simple-django-login-and-register\venv\lib\site-packages\daphne\ws_protocol.py", line 6, in <module>
from autobahn.twisted.websocket import (
File "C:\pg\django\win\simple-django-login-and-register\venv\lib\site-packages\autobahn\twisted\__init__.py", line 40, in <module>
from autobahn.twisted.websocket import \
File "C:\pg\django\win\simple-django-login-and-register\venv\lib\site-packages\autobahn\twisted\websocket.py", line 42, in <module>
from autobahn.util import public
File "C:\pg\django\win\simple-django-login-and-register\venv\lib\site-packages\autobahn\util.py", line 464, in <module>
_ = _rtime() # this starts wallclock
DeprecationWarning: time.clock has been deprecated in Python 3.3 and will be removed from Python 3.8: use time.perf_counter or time.process_time instead
I did google and seems it's not version compatibility issue between django and channels, what's wrong with my project?
(added)
I tried pip install pypiwin32 seeing Error after adding Django channels to installed_apps in settings file - Stack Overflow, but it didn't solve anything, and stil the same error.

ModuleNotFoundError: No module named 'debug_toolbar' Django 3.1

I'm facing a "common" problem apparently as I searched and found several topics about it. None of the answer provided worked for me as I already did everything mentionned.
I setup the virtualenv
Then, I installed django-degub-toolbar
pip install django-debug-toolbar
Add the application in the settings
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
# External apps
'debug_toolbar',
# Internal apps
...,
]
And edited the middleware
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
# Django Toolbar interaction with the middleware
'debug_toolbar.middleware.DebugToolbarMiddleware',
]
But nothing worked and I still got the error when I run the server.
Traceback
Exception in thread django-main-thread:
Traceback (most recent call last):
File "/Users/saiko-san/Documents/app-mangas-collection/venv/lib/python3.7/site-packages/django/core/servers/basehttp.py", line 45, in get_internal_wsgi_application
return import_string(app_path)
File "/Users/saiko-san/Documents/app-mangas-collection/venv/lib/python3.7/site-packages/django/utils/module_loading.py", line 17, in import_string
module = 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/saiko-san/Documents/app-mangas-collection/mangas_collection/mangas_collection/wsgi.py", line 16, in <module>
application = get_wsgi_application()
File "/Users/saiko-san/Documents/app-mangas-collection/venv/lib/python3.7/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
return WSGIHandler()
File "/Users/saiko-san/Documents/app-mangas-collection/venv/lib/python3.7/site-packages/django/core/handlers/wsgi.py", line 127, in __init__
self.load_middleware()
File "/Users/saiko-san/Documents/app-mangas-collection/venv/lib/python3.7/site-packages/django/core/handlers/base.py", line 40, in load_middleware
middleware = import_string(middleware_path)
File "/Users/saiko-san/Documents/app-mangas-collection/venv/lib/python3.7/site-packages/django/utils/module_loading.py", line 17, in import_string
module = 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 953, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'debug_toolbar'
Have you activate your virtual environment.?
if not please activate first with the command pipenv shell

Django: No module named 'project'

I was working on a Django project on my personal laptop. Then I cloned the project to my work laptop and I'm getting a very weird error when I try to run any command, such as python manage.py runserver:
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "/Users/jmetz/github/personal/golf-swings-api/venv/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/Users/jmetz/github/personal/golf-swings-api/venv/lib/python3.7/site-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/jmetz/github/personal/golf-swings-api/venv/lib/python3.7/site-packages/django/core/management/base.py", line 336, in run_from_argv
connections.close_all()
File "/Users/jmetz/github/personal/golf-swings-api/venv/lib/python3.7/site-packages/django/db/utils.py", line 219, in close_all
for alias in self:
File "/Users/jmetz/github/personal/golf-swings-api/venv/lib/python3.7/site-packages/django/db/utils.py", line 213, in __iter__
return iter(self.databases)
File "/Users/jmetz/github/personal/golf-swings-api/venv/lib/python3.7/site-packages/django/utils/functional.py", line 80, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/Users/jmetz/github/personal/golf-swings-api/venv/lib/python3.7/site-packages/django/db/utils.py", line 147, in databases
self._databases = settings.DATABASES
File "/Users/jmetz/github/personal/golf-swings-api/venv/lib/python3.7/site-packages/django/conf/__init__.py", line 79, in __getattr__
self._setup(name)
File "/Users/jmetz/github/personal/golf-swings-api/venv/lib/python3.7/site-packages/django/conf/__init__.py", line 66, in _setup
self._wrapped = Settings(settings_module)
File "/Users/jmetz/github/personal/golf-swings-api/venv/lib/python3.7/site-packages/django/conf/__init__.py", line 157, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/Users/jmetz/miniconda3/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 953, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'project'
Any idea what the issue is?
Add project to your INSTALLED_APPS in settings.py file
settings.py
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'project',
]
My solution to a similar problem was to export PYTHONPATH into my shell. That was throwing a warning about project, even though the INSTALLED_APPS was correct.

django-axes installed, but axes.middleware module not available

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

Python 3.3 + Django 1.6 + Connector/Python Django Backend + South

I want to use this set: Ubuntu 12.04 + Python 3.3 + Django 1.6 + MySQL 5.5;
For support MySQL i used "Connector/Python Django Backend" (link).
My settings:
DATABASES = {
'default': {
'NAME': 'test',
'ENGINE': 'mysql.connector.django',
'USER': 'root',
'PASSWORD': '****',
'OPTIONS': {
'autocommit': True,
},
}
}
This is work.
But yet i want to use "South". I successfully installed "South".
pip install south==0.8.4
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'south',
)
Here's what happened
python manage.py syncdb
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/mikhail/virtualenv/python3.3/lib/python3.3/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "/home/mikhail/virtualenv/python3.3/lib/python3.3/site-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/mikhail/virtualenv/python3.3/lib/python3.3/site-packages/django/core/management/__init__.py", line 272, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/home/mikhail/virtualenv/python3.3/lib/python3.3/site-packages/django/core/management/__init__.py", line 75, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "/home/mikhail/virtualenv/python3.3/lib/python3.3/importlib/__init__.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1584, in _gcd_import
File "<frozen importlib._bootstrap>", line 1565, in _find_and_load
File "<frozen importlib._bootstrap>", line 1512, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 313, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1584, in _gcd_import
File "<frozen importlib._bootstrap>", line 1565, in _find_and_load
File "<frozen importlib._bootstrap>", line 1532, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 584, in _check_name_wrapper
File "<frozen importlib._bootstrap>", line 1022, in load_module
File "<frozen importlib._bootstrap>", line 1003, in load_module
File "<frozen importlib._bootstrap>", line 560, in module_for_loader_wrapper
File "<frozen importlib._bootstrap>", line 868, in _load_module
File "<frozen importlib._bootstrap>", line 313, in _call_with_frames_removed
File "/home/mikhail/virtualenv/python3.3/lib/python3.3/site-packages/south/management/commands/__init__.py", line 13, in <module>
from south.management.commands.syncdb import Command as SyncCommand
File "/home/mikhail/virtualenv/python3.3/lib/python3.3/site-packages/south/management/commands/syncdb.py", line 19, in <module>
from south.db import dbs
File "/home/mikhail/virtualenv/python3.3/lib/python3.3/site-packages/south/db/__init__.py", line 83, in <module>
db = dbs[DEFAULT_DB_ALIAS]
KeyError: 'default'
What to do?
To support the MySQL need to use MySQL-for-Python-3 (link)
Install:
$ tar xfz MySQL-python-1.2.1.tar.gz
$ cd MySQL-python-1.2.1
$ python setup.py build
$ sudo python setup.py install
Next on the official Django manual.

Categories