当我在本地 `python manage.py runserver` 时获取权限被拒绝
Getting permission denied when I `python manage.py runserver` locally
我是 运行 本地的 Django 应用程序,我似乎无法理解为什么我在 runserver
时会收到此错误。我在一个 virtualenv 中,所以我不明白为什么它从外面抓取。
[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/'
将项目文件放在用户文件夹中,因为我看到项目位于 var/lib 需要 root 访问权限的文件夹中。或者你可以这样写sudo python manage.py runserver
我是 运行 本地的 Django 应用程序,我似乎无法理解为什么我在 runserver
时会收到此错误。我在一个 virtualenv 中,所以我不明白为什么它从外面抓取。
[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/'
将项目文件放在用户文件夹中,因为我看到项目位于 var/lib 需要 root 访问权限的文件夹中。或者你可以这样写sudo python manage.py runserver