4

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?.....

Jaimin Sagar
  • 123
  • 1
  • 3
  • 9
  • Make sure that django-paypal is installed in the virtual environment. On Windows I think you can do: `py -3 -m pip freeze`. To install it, try `py -3 -m pip install django-paypal`. – Alasdair Apr 02 '20 at 19:19
  • I already installed django-paypal in my venv – Jaimin Sagar Apr 03 '20 at 06:20
  • Are you sure? What is the output of the pip freeze command? The simplest explanation for `No module named 'paypal'` is that it isn't installed in the current environment. – Alasdair Apr 03 '20 at 10:12
  • `(env) PS J:\jaimin (E)\Programming Practice\Django\Payment Gateway using Paypal\simple_ecommerce> pip list Package Version ------------- ---------- asgiref 3.2.7 certifi 2019.11.28 chardet 3.0.4 Django 2.0.2 django-paypal 1.0.0 django-payu 0.5 ` – Jaimin Sagar Apr 03 '20 at 11:24
  • That's not the command I suggested. I think that's using `pip` from a different environment. Note that Django is 2.0.2, not 3.0 as you say in your question. – Alasdair Apr 03 '20 at 11:28
  • But My environment is already activated......so how the pip comes from a different environment ?? And Yes I installed Django 2.0 later to check whether it is working or not. – Jaimin Sagar Apr 03 '20 at 12:50
  • 1
    Sometimes `pip` doesn't point to the Python you think it does. It's one of the frustrations of Python, there's [a famous xkcd cartoon about it](https://m.xkcd.com/1987/). That's why I always recommend `python -m pip` because it guarantees you are using the same version of Python. I'm not familiar with Windows so can't really help with that, but [the docs](https://docs.python.org/3/installing/index.html#work-with-multiple-versions-of-python-installed-in-parallel) say that `py -3 -m pip` will work. – Alasdair Apr 03 '20 at 13:33
  • Anyway, please try the exact command I suggested yesterday and show the result. The worst that can happen is that my theory is wrong and we confirm that Django-paypal is installed correctly in the environment. – Alasdair Apr 03 '20 at 13:40
  • 1
    Thanks, bro, it's work. I tried exactly what you have suggested..... thanks a lot.... – Jaimin Sagar Apr 04 '20 at 17:59

2 Answers2

1

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

Saikat Mukherjee
  • 500
  • 5
  • 11
0

You just need to install django-paypal.

pip install django-paypal
monofal
  • 1,928
  • 1
  • 13
  • 15