尝试安装python异步IO时失败

尝试安装python异步IO时失败,python,Python,我尝试为python安装asyncio,但失败了 我不知道失败是否是“重叠的。c:68:error:'PyExc_ConnectionRefusedError'未声明” 或“错误:命令'c:\mingw\bin\gcc.exe'失败,退出状态为1” 解决方案是什么 命令: C:\Users\AA>pip安装异步IO 输出: Collecting asyncio Using cached asyncio-3.4.3.tar.gz Installing collected packages: a

我尝试为python安装asyncio,但失败了 我不知道失败是否是“重叠的。c:68:error:'PyExc_ConnectionRefusedError'未声明” 或“错误:命令'c:\mingw\bin\gcc.exe'失败,退出状态为1” 解决方案是什么

命令:

C:\Users\AA>pip安装异步IO

输出:

Collecting asyncio
  Using cached asyncio-3.4.3.tar.gz
Installing collected packages: asyncio
  Running setup.py install for asyncio ... error
    Complete output from command C:\Python27\python.exe -u -c "import setuptools
, tokenize;__file__='c:\\users\\ait\\appdata\\local\\temp\\pip-build-eucukh\\asy
ncio\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replac
e('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --recor
d c:\users\ait\appdata\local\temp\pip-4yjfsw-record\install-record.txt --single-
version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build\lib.win32-2.7
    creating build\lib.win32-2.7\asyncio
    copying asyncio\base_events.py -> build\lib.win32-2.7\asyncio
    copying asyncio\base_subprocess.py -> build\lib.win32-2.7\asyncio
    copying asyncio\constants.py -> build\lib.win32-2.7\asyncio
    copying asyncio\coroutines.py -> build\lib.win32-2.7\asyncio
    copying asyncio\events.py -> build\lib.win32-2.7\asyncio
    copying asyncio\futures.py -> build\lib.win32-2.7\asyncio
    copying asyncio\locks.py -> build\lib.win32-2.7\asyncio
    copying asyncio\log.py -> build\lib.win32-2.7\asyncio
    copying asyncio\proactor_events.py -> build\lib.win32-2.7\asyncio
    copying asyncio\protocols.py -> build\lib.win32-2.7\asyncio
    copying asyncio\queues.py -> build\lib.win32-2.7\asyncio
    copying asyncio\selectors.py -> build\lib.win32-2.7\asyncio
    copying asyncio\selector_events.py -> build\lib.win32-2.7\asyncio
    copying asyncio\sslproto.py -> build\lib.win32-2.7\asyncio
    copying asyncio\streams.py -> build\lib.win32-2.7\asyncio
    copying asyncio\subprocess.py -> build\lib.win32-2.7\asyncio
    copying asyncio\tasks.py -> build\lib.win32-2.7\asyncio
    copying asyncio\test_support.py -> build\lib.win32-2.7\asyncio
    copying asyncio\test_utils.py -> build\lib.win32-2.7\asyncio
    copying asyncio\transports.py -> build\lib.win32-2.7\asyncio
    copying asyncio\unix_events.py -> build\lib.win32-2.7\asyncio
    copying asyncio\windows_events.py -> build\lib.win32-2.7\asyncio
    copying asyncio\windows_utils.py -> build\lib.win32-2.7\asyncio
    copying asyncio\__init__.py -> build\lib.win32-2.7\asyncio
    running build_ext
    building 'asyncio._overlapped' extension
    creating build\temp.win32-2.7
    creating build\temp.win32-2.7\Release
    c:\mingw\bin\gcc.exe -mdll -O -Wall -IC:\Python27\include -IC:\Python27\PC -
c overlapped.c -o build\temp.win32-2.7\Release\overlapped.o
    overlapped.c: In function 'SetFromWindowsErr':
    overlapped.c:68: error: 'PyExc_ConnectionRefusedError' undeclared (first use
 in this function)
    overlapped.c:68: error: (Each undeclared identifier is reported only once
    overlapped.c:68: error: for each function it appears in.)
    overlapped.c:71: error: 'PyExc_ConnectionAbortedError' undeclared (first use
 in this function)
    overlapped.c: At top level:
    overlapped.c:83: error: expected '=', ',', ';', 'asm' or '__attribute__' bef
ore 'Py_AcceptEx'
    overlapped.c:84: error: expected '=', ',', ';', 'asm' or '__attribute__' bef
ore 'Py_ConnectEx'
    overlapped.c:85: error: expected '=', ',', ';', 'asm' or '__attribute__' bef
ore 'Py_DisconnectEx'
    overlapped.c: In function 'initialize_function_pointers':
    overlapped.c:96: error: 'WSAID_ACCEPTEX' undeclared (first use in this funct
ion)
    overlapped.c:97: error: 'WSAID_CONNECTEX' undeclared (first use in this func
tion)
    overlapped.c:98: error: 'WSAID_DISCONNECTEX' undeclared (first use in this f
unction)
    overlapped.c:109: error: 'Py_AcceptEx' undeclared (first use in this functio
n)
    overlapped.c:110: error: 'Py_ConnectEx' undeclared (first use in this functi
on)
    overlapped.c:111: error: 'Py_DisconnectEx' undeclared (first use in this fun
ction)
    overlapped.c: In function 'overlapped_RegisterWaitWithQueue':
    overlapped.c:271: warning: implicit declaration of function 'RegisterWaitFor
SingleObject'
    overlapped.c:272: error: 'WAITORTIMERCALLBACK' undeclared (first use in this
 function)
    overlapped.c:272: error: expected ')' before 'PostToQueueCallback'
    overlapped.c: In function 'overlapped_UnregisterWait':
    overlapped.c:298: warning: implicit declaration of function 'UnregisterWait'

    overlapped.c: In function 'overlapped_UnregisterWaitEx':
    overlapped.c:321: warning: implicit declaration of function 'UnregisterWaitE
x'
    overlapped.c: In function 'Overlapped_dealloc':
    overlapped.c:580: warning: unknown conversion type character 'R' in format
    overlapped.c:580: warning: too many arguments for format
    overlapped.c: In function 'Overlapped_ReadFile':
    overlapped.c:714: warning: implicit declaration of function 'Py_MIN'
    overlapped.c:716: warning: implicit declaration of function 'Py_MAX'
    overlapped.c: In function 'Overlapped_AcceptEx':
    overlapped.c:948: warning: implicit declaration of function 'Py_AcceptEx'
    overlapped.c: In function 'Overlapped_ConnectEx':
    overlapped.c:1035: warning: implicit declaration of function 'Py_ConnectEx'
    overlapped.c: In function 'Overlapped_DisconnectEx':
    overlapped.c:1075: warning: implicit declaration of function 'Py_DisconnectE
x'
    overlapped.c: In function 'ConnectPipe':
    overlapped.c:1145: warning: implicit declaration of function 'PyUnicode_AsWi
deCharString'
    overlapped.c:1145: warning: assignment makes pointer from integer without a
cast
    overlapped.c: At top level:
    overlapped.c:1287: error: variable 'overlapped_module' has initializer but i
ncomplete type
    overlapped.c:1288: error: 'PyModuleDef_HEAD_INIT' undeclared here (not in a
function)
    overlapped.c:1288: warning: excess elements in struct initializer
    overlapped.c:1288: warning: (near initialization for 'overlapped_module')
    overlapped.c:1289: warning: excess elements in struct initializer
    overlapped.c:1289: warning: (near initialization for 'overlapped_module')
    overlapped.c:1290: warning: excess elements in struct initializer
    overlapped.c:1290: warning: (near initialization for 'overlapped_module')
    overlapped.c:1291: warning: excess elements in struct initializer
    overlapped.c:1291: warning: (near initialization for 'overlapped_module')
    overlapped.c:1292: warning: excess elements in struct initializer
    overlapped.c:1292: warning: (near initialization for 'overlapped_module')
    overlapped.c:1293: warning: excess elements in struct initializer
    overlapped.c:1293: warning: (near initialization for 'overlapped_module')
    overlapped.c:1294: warning: excess elements in struct initializer
    overlapped.c:1294: warning: (near initialization for 'overlapped_module')
    overlapped.c:1295: warning: excess elements in struct initializer
    overlapped.c:1295: warning: (near initialization for 'overlapped_module')
    overlapped.c:1297: warning: excess elements in struct initializer
    overlapped.c:1297: warning: (near initialization for 'overlapped_module')
    overlapped.c: In function 'PyInit__overlapped':
    overlapped.c:1310: warning: 'return' with a value, in function returning voi
d
    overlapped.c:1314: warning: 'return' with a value, in function returning voi
d
    overlapped.c:1317: warning: 'return' with a value, in function returning voi
d
    overlapped.c:1319: warning: implicit declaration of function 'PyModule_Creat
e'
    overlapped.c:1319: warning: assignment makes pointer from integer without a
cast
    overlapped.c:1321: warning: 'return' with a value, in function returning voi
d
    overlapped.c:1333: error: 'SO_UPDATE_CONNECT_CONTEXT' undeclared (first use
in this function)
    overlapped.c:1336: warning: 'return' with a value, in function returning voi
d
    error: command 'c:\\mingw\\bin\\gcc.exe' failed with exit status 1

    ----------------------------------------
Command "C:\Python27\python.exe -u -c "import setuptools, tokenize;__file__='c:\
\users\\ait\\appdata\\local\\temp\\pip-build-eucukh\\asyncio\\setup.py';f=getatt
r(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close(
);exec(compile(code, __file__, 'exec'))" install --record c:\users\ait\appdata\l
ocal\temp\pip-4yjfsw-record\install-record.txt --single-version-externally-manag
ed --compile" failed with error code 1 in c:\users\ait\appdata\local\temp\pip-bu
ild-eucukh\asyncio\
当我尝试安装trollius时,出现以下错误:

  C:\Users\Administrator\Downloads\trollius-2.1>c:\Python27\python.exe setup.py bdist_wheel upload
!!! WARNING !!! The Trollius project is now deprecated!

running bdist_wheel
running build
running build_py/
running build_ext
building 'trollius._overlapped' extension
c:\mingw\bin\gcc.exe -mdll -O -Wall -Ic:\Python27\include -Ic:\Python27\PC -c overlapped.c -o build\temp.win32-2.7\
Release\overlapped.o
overlapped.c:99: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Py_AcceptEx'
overlapped.c:100: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Py_ConnectEx'
overlapped.c:101: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Py_DisconnectEx'
overlapped.c: In function 'initialize_function_pointers':
overlapped.c:112: error: 'WSAID_ACCEPTEX' undeclared (first use in this function)
overlapped.c:112: error: (Each undeclared identifier is reported only once
overlapped.c:112: error: for each function it appears in.)
overlapped.c:113: error: 'WSAID_CONNECTEX' undeclared (first use in this function)
overlapped.c:114: error: 'WSAID_DISCONNECTEX' undeclared (first use in this function)
overlapped.c:125: error: 'Py_AcceptEx' undeclared (first use in this function)
overlapped.c:126: error: 'Py_ConnectEx' undeclared (first use in this function)
overlapped.c:127: error: 'Py_DisconnectEx' undeclared (first use in this function)
overlapped.c: In function 'overlapped_RegisterWaitWithQueue':
overlapped.c:287: warning: implicit declaration of function 'RegisterWaitForSingleObject'
overlapped.c:288: error: 'WAITORTIMERCALLBACK' undeclared (first use in this function)
overlapped.c:288: error: expected ')' before 'PostToQueueCallback'
overlapped.c: In function 'overlapped_UnregisterWait':
overlapped.c:314: warning: implicit declaration of function 'UnregisterWait'
overlapped.c: In function 'overlapped_UnregisterWaitEx':
overlapped.c:337: warning: implicit declaration of function 'UnregisterWaitEx'
overlapped.c: In function 'Overlapped_dealloc':
overlapped.c:600: warning: unknown conversion type character 'R' in format
overlapped.c:600: warning: too many arguments for format
overlapped.c: In function 'Overlapped_AcceptEx':
overlapped.c:976: warning: implicit declaration of function 'Py_AcceptEx'
overlapped.c: In function 'Overlapped_ConnectEx':
overlapped.c:1062: warning: implicit declaration of function 'Py_ConnectEx'
overlapped.c: In function 'Overlapped_DisconnectEx':
overlapped.c:1102: warning: implicit declaration of function 'Py_DisconnectEx'
overlapped.c: In function 'ConnectPipe':
overlapped.c:1165: warning: unused variable 'AddressObj'
overlapped.c: In function '_init_overlapped':
overlapped.c:1379: error: 'SO_UPDATE_CONNECT_CONTEXT' undeclared (first use in this function)
error: command 'c:\\mingw\\bin\\gcc.exe' failed with exit status 1

asyncio
是Python3中的内置包,在Python2中不可用,即使通过pip安装也不可用。如果您真的需要使用协同程序,那么是时候切换到使用Python3了

除此之外,python 2还有一个名为asyncio的端口,如果您愿意,可以使用它(仍然可用,但现在已弃用)。但我仍然建议更新到Python3


正如您所看到的,是针对python3.3+的,它没有预先安装
asyncio
,并不意味着要替代Python2中的
asyncio

如果您想使用asyncio安装python3,可以。 安装python3并通过下面的命令使python3成为默认值

别名python=/usr/bin/python3 在~/.bash\u别名文件中编写此命令 sudo nano~/.bash_别名
当你打开你的终端时,这会自动将python路径设置为python 3。我试图安装trollius,但是我遇到了这个错误,我能做什么?谢谢!因此,通常在使用
pip
时,您应该先查看Python包索引(PyPI网站)并阅读该包的安装说明?在遇到这个问题之前,我没有这样做。