我已经从python 32位跳到了64位,当我尝试运行服务器时,出现错误:
ImportError: DLL load failed while importing _socket: %1 is not a valid Win32 application.
完整的追溯在这里,
Traceback (most recent call last):
File "C:\Users\Sheraram Prajapat\OneDrive\Desktop\venv\mysite\lib\site-packages\django\core\management\__init__.py", line 357, in execute
autoreload.check_errors(django.setup)()
File "C:\Users\Sheraram Prajapat\OneDrive\Desktop\venv\mysite\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "C:\Users\Sheraram Prajapat\OneDrive\Desktop\venv\mysite\lib\site-packages\django\__init__.py", line 16, in setup
from django.urls import set_script_prefix
File "C:\Users\Sheraram Prajapat\OneDrive\Desktop\venv\mysite\lib\site-packages\django\urls\__init__.py", line 1, in <module>
from .base import (
File "C:\Users\Sheraram Prajapat\OneDrive\Desktop\venv\mysite\lib\site-packages\django\urls\base.py", line 9, in <module>
from .exceptions import NoReverseMatch, Resolver404
File "C:\Users\Sheraram Prajapat\OneDrive\Desktop\venv\mysite\lib\site-packages\django\urls\exceptions.py", line 1, in <module>
from django.http import Http404
File "C:\Users\Sheraram Prajapat\OneDrive\Desktop\venv\mysite\lib\site-packages\django\http\__init__.py", line 2, in <module>
from django.http.request import (
File "C:\Users\Sheraram Prajapat\OneDrive\Desktop\venv\mysite\lib\site-packages\django\http\request.py", line 1, in <module>
import cgi
File "C:\Users\Sheraram Prajapat\AppData\Local\Programs\Python\Python38\lib\cgi.py", line 39, in <module>
from email.parser import FeedParser
File "C:\Users\Sheraram Prajapat\AppData\Local\Programs\Python\Python38\lib\email\parser.py", line 12, in <module>
from email.feedparser import FeedParser, BytesFeedParser
File "C:\Users\Sheraram Prajapat\AppData\Local\Programs\Python\Python38\lib\email\feedparser.py", line 27, in <module>
from email._policybase import compat32
File "C:\Users\Sheraram Prajapat\AppData\Local\Programs\Python\Python38\lib\email\_policybase.py", line 9, in <module>
from email.utils import _has_surrogates
File "C:\Users\Sheraram Prajapat\AppData\Local\Programs\Python\Python38\lib\email\utils.py", line 29, in <module>
import socket
File "C:\Users\Sheraram Prajapat\AppData\Local\Programs\Python\Python38\lib\socket.py", line 49, in <module>
import _socket
ImportError: DLL load failed while importing _socket: %1 is not a valid Win32 application.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "C:\Users\Sheraram Prajapat\OneDrive\Desktop\venv\mysite\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
utility.execute()
File "C:\Users\Sheraram Prajapat\OneDrive\Desktop\venv\mysite\lib\site-packages\django\core\management\__init__.py", line 370, in execute
_parser = self.fetch_command('runserver').create_parser('django', 'runserver')
File "C:\Users\Sheraram Prajapat\OneDrive\Desktop\venv\mysite\lib\site-packages\django\core\management\__init__.py", line 244, in fetch_command
klass = load_command_class(app_name, subcommand)
File "C:\Users\Sheraram Prajapat\OneDrive\Desktop\venv\mysite\lib\site-packages\django\core\management\__init__.py", line 37, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "C:\Users\Sheraram Prajapat\AppData\Local\Programs\Python\Python38\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\Sheraram Prajapat\OneDrive\Desktop\venv\mysite\lib\site-packages\django\core\management\commands\runserver.py", line 4, in <module>
import socket
File "C:\Users\Sheraram Prajapat\AppData\Local\Programs\Python\Python38\lib\socket.py", line 49, in <module>
import _socket
ImportError: DLL load failed while importing _socket: %1 is not a valid Win32 application.
我已经卸载了32位版本。因此,当我创建一个新项目并使用runserver命令时,它可以正常运行,但是旧项目会出现此错误。有什么方法可以运行那些项目,还是必须从头开始创建所有那些项目?