TypeError:_getfullpathname:路径应为字符串,字节或os.PathLike,而不是函数(wsgi.py错误)

时间:2019-01-24 15:11:46

标签: python django wsgi

我使用Django 2.0和Postgresql在ubuntu上开发了这个django项目,在将其克隆为可在Windows上运行之前,它运行良好。当我运行python manage.py runserver迁移数据库后,它将引发以下类型错误。

跟踪     正在执行系统检查...

System check identified no issues (0 silenced).
January 24, 2019 - 20:02:45
Django version 2.1.2, using settings 'main.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x03A378A0>
Traceback (most recent call last):
  File "C:\Users\HP\Desktop\django\crowd-social\crowdsocial_env\lib\site-packages\django\utils\autoreload.py", line 225, in wrapper
    fn(*args, **kwargs)
  File "C:\Users\HP\Desktop\django\crowd-social\crowdsocial_env\lib\site-packages\django\core\management\commands\runserver.py", line 137, in inner_run
    handler = self.get_handler(*args, **options)
  File "C:\Users\HP\Desktop\django\crowd-social\crowdsocial_env\lib\site-packages\django\contrib\staticfiles\management\commands\runserver.py", line 27, in
get_handler
    handler = super().get_handler(*args, **options)
  File "C:\Users\HP\Desktop\django\crowd-social\crowdsocial_env\lib\site-packages\django\core\management\commands\runserver.py", line 64, in get_handler
    return get_internal_wsgi_application()
  File "C:\Users\HP\Desktop\django\crowd-social\crowdsocial_env\lib\site-packages\django\core\servers\basehttp.py", line 44, in get_internal_wsgi_application
    return import_string(app_path)
  File "C:\Users\HP\Desktop\django\crowd-social\crowdsocial_env\lib\site-packages\django\utils\module_loading.py", line 17, in import_string
    module = import_module(module_path)
  File "C:\python3\Lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\Users\HP\Desktop\django\crowd-social\main\main\wsgi.py", line 19, in <module>
    application = get_wsgi_application()
  File "C:\Users\HP\Desktop\django\crowd-social\crowdsocial_env\lib\site-packages\django\core\wsgi.py", line 13, in get_wsgi_application
    return WSGIHandler()
  File "C:\Users\HP\Desktop\django\crowd-social\crowdsocial_env\lib\site-packages\django\core\handlers\wsgi.py", line 136, in __init__
    self.load_middleware()
  File "C:\Users\HP\Desktop\django\crowd-social\crowdsocial_env\lib\site-packages\django\core\handlers\base.py", line 36, in load_middleware
    mw_instance = middleware(handler)
  File "C:\Users\HP\Desktop\django\crowd-social\crowdsocial_env\lib\site-packages\django\contrib\staticfiles\storage.py", line 376, in __init__
    self.hashed_files = self.load_manifest()
  File "C:\Users\HP\Desktop\django\crowd-social\crowdsocial_env\lib\site-packages\django\contrib\staticfiles\storage.py", line 386, in load_manifest
    content = self.read_manifest()
  File "C:\Users\HP\Desktop\django\crowd-social\crowdsocial_env\lib\site-packages\django\contrib\staticfiles\storage.py", line 380, in read_manifest
    with self.open(self.manifest_name) as manifest:
  File "C:\Users\HP\Desktop\django\crowd-social\crowdsocial_env\lib\site-packages\django\core\files\storage.py", line 33, in open
    return self._open(name, mode)
  File "C:\Users\HP\Desktop\django\crowd-social\crowdsocial_env\lib\site-packages\django\core\files\storage.py", line 218, in _open
    return File(open(self.path(name), mode))
  File "C:\Users\HP\Desktop\django\crowd-social\crowdsocial_env\lib\site-packages\django\contrib\staticfiles\storage.py", line 42, in path
    if not self.location:
  File "C:\Users\HP\Desktop\django\crowd-social\crowdsocial_env\lib\site-packages\django\utils\functional.py", line 37, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "C:\Users\HP\Desktop\django\crowd-social\crowdsocial_env\lib\site-packages\django\core\files\storage.py", line 201, in location
    return os.path.abspath(self.base_location)
  File "C:\python3\Lib\ntpath.py", line 526, in abspath
    return normpath(_getfullpathname(path))

TypeError: _getfullpathname: path should be string, bytes or os.PathLike, not function

wsgi.py

import os
from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", 'main.settings')
application = get_wsgi_application()

错误源于此行application = get_wsgi_application()

0 个答案:

没有答案