在pythonanywhere上部署网站会产生与Numpy相关的错误

时间:2020-06-20 13:20:15

标签: python django numpy pythonanywhere

我在pythonanywhere上托管了Django网站,但是在部署时出现错误。

我必须用django和ML制作项目。所以我想在像pythonanywhere这样的自由环境上部署我的项目。所以我刚开始部署我的项目,却出现以下错误。

环境:

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']

错误:

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 个答案:

答案 0 :(得分:2)

我看到此错误是由腌制的文件引起的。您是否在PythonAnywhere或其他计算机上对文件进行了腌制?可以用不同版本的numpy对其进行腌制与将其未腌制一起使用吗?