0

I hosted my Django website on pythonanywhere but while deploying I got error.

I have to make project in django and ML. So i want to deploy my project on free environment like pythonanywhere. So just I started deploying my project and I got following error.

Environment:

Request Method: POST
Request URL: http://vishalbarad.pythonanywhere.com/home

Django Version: 3.0.7
Python Version: 3.7.5
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'testapp']
Installed 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']

Error:

Traceback (most recent call last):
  File "/home/vishalbarad/.virtualenvs/deploy_django1.git-virtualenv/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/home/vishalbarad/.virtualenvs/deploy_django1.git-virtualenv/lib/python3.7/site-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/home/vishalbarad/.virtualenvs/deploy_django1.git-virtualenv/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/vishalbarad/deploy_django1/testapp/views.py", line 10, in home
    model = joblib.load("LInear_regression.pkl")
  File "/home/vishalbarad/.virtualenvs/deploy_django1.git-virtualenv/lib/python3.7/site-packages/joblib/numpy_pickle.py", line 585, in load
    obj = _unpickle(fobj, filename, mmap_mode)
  File "/home/vishalbarad/.virtualenvs/deploy_django1.git-virtualenv/lib/python3.7/site-packages/joblib/numpy_pickle.py", line 504, in _unpickle
    obj = unpickler.load()
  File "/usr/lib/python3.7/pickle.py", line 1088, in load
    dispatch[key[0]](self)
  File "/usr/lib/python3.7/pickle.py", line 1376, in load_global
    klass = self.find_class(module, name)
  File "/usr/lib/python3.7/pickle.py", line 1426, in find_class
    __import__(module, level=0)
  File "/home/vishalbarad/.virtualenvs/deploy_django1.git-virtualenv/lib/python3.7/site-packages/sklearn/__init__.py", line 80, in <module>
    from .base import clone
  File "/home/vishalbarad/.virtualenvs/deploy_django1.git-virtualenv/lib/python3.7/site-packages/sklearn/base.py", line 17, in <module>
    import numpy as np
  File "/home/vishalbarad/.virtualenvs/deploy_django1.git-virtualenv/lib/python3.7/site-packages/numpy/__init__.py", line 151, in <module>
    from . import polynomial

Exception Type: ImportError at /home
Exception Value: cannot import name 'polynomial' from 'numpy' (/home/vishalbarad/.virtualenvs/deploy_django1.git-virtualenv/lib/python3.7/site-packages/numpy/__init__.py)enter code here
1
  • seems like a library referencing issue, your code pointing to local path for numpy. please list down the tutorial which you are referring to. Commented Jun 21, 2020 at 7:37

1 Answer 1

2

I see that this error is coming from a pickled file. Did you pickle the file on PythonAnywhere or a different machine? Could it have been pickled with a different version of numpy vs where it is being unpickled?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.