Forums

cannot import name 'path'

Hi all,

I am new in the development world. I just completed a web app that runs perfectly on my local drive. But serious need in getting this project run on Pythonanywhere. However, I am getting " cannot import name 'path'" error.

Please review and advise.

Thanks in advance.

~ Stan30000

Environment:

Request Method: GET Request URL: http://stan30000.pythonanywhere.com/

Django Version: 1.11b1 Python Version: 3.6.0 Installed Applications: ['webapp', 'safety', 'management', 'sustainability', 'Dashboard', 'compliance_matrix', 'facilities', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles'] 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:

File "/usr/local/lib/python3.6/dist-packages/django/core/handlers/exception.py" in inner 41. response = get_response(request)

File "/usr/local/lib/python3.6/dist-packages/django/core/handlers/base.py" in _get_response 172. resolver_match = resolver.resolve(request.path_info)

File "/usr/local/lib/python3.6/dist-packages/django/urls/resolvers.py" in resolve 362. for pattern in self.url_patterns:

File "/usr/local/lib/python3.6/dist-packages/django/utils/functional.py" in get 35. res = instance.dict[self.name] = self.func(instance)

File "/usr/local/lib/python3.6/dist-packages/django/urls/resolvers.py" in url_patterns 405. patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)

File "/usr/local/lib/python3.6/dist-packages/django/utils/functional.py" in get 35. res = instance.dict[self.name] = self.func(instance)

File "/usr/local/lib/python3.6/dist-packages/django/urls/resolvers.py" in urlconf_module 398. return import_module(self.urlconf_name)

File "/usr/lib/python3.6/importlib/init.py" in import_module 126. return _bootstrap._gcd_import(name[level:], package, level)

File "./myproject/urls.py" in <module> 17. from django.urls import path, include

Exception Type: ImportError at / Exception Value: cannot import name 'path'

You are using django 1.11 on PythonAnywhere, but your local machine is probably running django 2.0.

Upgrade django by installing it into a virtualenv, and set your webapp to use it.