pythondjangodjango-1.8

Getting permission denied when I `python manage.py runserver` locally


I am running a Django app locally and I cant seem to understand why I am getting this error when I runserver. I am in a virtualenv and so I don't see why it is grabbing from outside.

[ERROR 2020-10-21 19:00:36,868] base.py [:256] handle_uncaught_exception: Internal Server Error: /favicon.ico
Traceback (most recent call last):
  File "/opt/anaconda3/envs/py2/lib/python2.7/site-packages/django/core/handlers/base.py", line 108, in get_response
    response = middleware_method(request)
  File "/opt/anaconda3/envs/py2/lib/python2.7/site-packages/django/middleware/common.py", line 74, in process_request
    if (not urlresolvers.is_valid_path(request.path_info, urlconf) and
  File "/opt/anaconda3/envs/py2/lib/python2.7/site-packages/django/core/urlresolvers.py", line 647, in is_valid_path
    resolve(path, urlconf)
  File "/opt/anaconda3/envs/py2/lib/python2.7/site-packages/django/core/urlresolvers.py", line 522, in resolve
    return get_resolver(urlconf).resolve(path)
  File "/opt/anaconda3/envs/py2/lib/python2.7/site-packages/django/core/urlresolvers.py", line 366, in resolve
    for pattern in self.url_patterns:
  File "/opt/anaconda3/envs/py2/lib/python2.7/site-packages/django/core/urlresolvers.py", line 402, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/opt/anaconda3/envs/py2/lib/python2.7/site-packages/django/core/urlresolvers.py", line 396, in urlconf_module
    self._urlconf_module = import_module(self.urlconf_name)
  File "/opt/anaconda3/envs/py2/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/Users/andynguyen/Documents/AggrigatorCode/aggrigator/site_aggrigator/urls.py", line 5, in <module>
    url(r'', include('accounts.urls')),
  File "/opt/anaconda3/envs/py2/lib/python2.7/site-packages/django/conf/urls/__init__.py", line 33, in include
    urlconf_module = import_module(urlconf_module)
  File "/opt/anaconda3/envs/py2/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/Users/andynguyen/Documents/AggrigatorCode/aggrigator/accounts/urls.py", line 1, in <module>
    from accounts import views
  File "/Users/andynguyen/Documents/AggrigatorCode/aggrigator/accounts/views.py", line 27, in <module>
    import geonameszip
  File "/opt/anaconda3/envs/py2/lib/python2.7/site-packages/geonameszip/__init__.py", line 21, in <module>
    os.makedirs(BASE_DIR)
  File "/opt/anaconda3/envs/py2/lib/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/var/lib/geonameszip/'

Solution

  • Put the project file in the user folder as I saw project is in var/lib folder which requires root access. Or you can writesudo python manage.py runserver