【Azure 环境】Windows中安装Python azure-eventhub-checkpointstoreblob-aio模块时出错 ERROR: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory:
问题描述
在使用Python代码接受EventHub的消息时,根据文档要求安装azure-eventhub-checkpointstoreblob-aio模块时,出现了如下错误:
ERROR: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: 'C:\\Users\\myaccount\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python38\\site-packages\\azure\\eventhub\\extensions\\checkpointstoreblobaio\\_vendor\\storage\\blob\\_generated\\aio\\operations_async\\_append_blob_operations_async.py'
问题原因
因为Python Page模块文件的文件路径太长,如果超过了260个字符这文件不能被创建成功。所以需要解决Windows中对长文件名的限制问题。通过修改注册表中 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem 的LongPathsEnabled 值由0改为1
解决办法
1) 打开 registry editor
2)修改HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem 中 LongPathsEnabled值为1
3)重启机器后,再次运行pip install azure-eventhub-checkpointstoreblob-aio即成功安装
PS C:\LBWorkSpace\EventHub\aadeventhubdemo> pip install azure-eventhub-checkpointstoreblob-aio Requirement already satisfied: azure-eventhub-checkpointstoreblob-aio in c:\users\bulu\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (1.1.1) Requirement already satisfied: msrest>=0.6.10 in c:\users\bulu\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from azure-eventhub-checkpointstoreblob-aio) (0.6.16) Requirement already satisfied: azure-core<2.0.0,>=1.2.2 in c:\users\bulu\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from azure-eventhub-checkpointstoreblob-aio) (1.8.2) Requirement already satisfied: azure-eventhub<6.0.0,>=5.0.0 in c:\users\bulu\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from azure-eventhub-checkpointstoreblob-aio) (5.2.0) Requirement already satisfied: aiohttp<4.0,>=3.0 in c:\users\bulu\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from azure-eventhub-checkpointstoreblob-aio) (3.7.3) Requirement already satisfied: cryptography>=2.1.4 in c:\users\bulu\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from azure-eventhub-checkpointstoreblob-aio) (2.9.2) Requirement already satisfied: requests-oauthlib>=0.5.0 in c:\users\bulu\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from msrest>=0.6.10->azure-eventhub-checkpointstoreblob-aio) (1.3.0) Requirement already satisfied: certifi>=2017.4.17 in c:\users\bulu\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from msrest>=0.6.10->azure-eventhub-checkpointstoreblob-aio) (2020.4.5.2) ache\local-packages\python38\site-packages (from msrest>=0.6.10->azure-eventhub-checkpointstoreblob-aio) (2.24.0) Requirement already satisfied: isodate>=0.6.0 in c:\users\bulu\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from msrest>=0.6.10->azure-eventhub-checkpointstoreblob-aio) (0.6.0) Requirement already satisfied: six>=1.6 in c:\users\bulu\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from azure-core<2.0.0,>=1.2.2->azure-eventhub-checkpointstoreblob-aio) (1.15.0) Requirement already satisfied: uamqp<2.0,>=1.2.7 in c:\users\bulu\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from azure-eventhub<6.0.0,>=5.0.0->azure-eventhub-checkpointstoreblob-aio) (1.2.12) Requirement already satisfied: multidict<7.0,>=4.5 in c:\users\bulu\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from aiohttp<4.0,>=3.0->azure-eventhub-checkpointstoreblob-aio) (5.0.2) Requirement already satisfied: chardet<4.0,>=2.0 in c:\users\bulu\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from aiohttp<4.0,>=3.0->azure-eventhub-checkpointstoreblob-aio) (3.0.4) Requirement already satisfied: typing-extensions>=3.6.5 in c:\users\bulu\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from aiohttp<4.0,>=3.0->azure-eventhub-checkpointstoreblob-aio) (3.7.4.3) Requirement already satisfied: yarl<2.0,>=1.0 in c:\users\bulu\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from aiohttp<4.0,>=3.0->azure-eventhub-checkpointstoreblob-aio) (1.6.3) Requirement already satisfied: async-timeout<4.0,>=3.0 in c:\users\bulu\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from aiohttp<4.0,>=3.0->azure-eventhub-checkpointstoreblob-aio) (3.0.1) Requirement already satisfied: attrs>=17.3.0 in c:\users\bulu\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from aiohttp<4.0,>=3.0->azure-eventhub-checkpointstoreblob-aio) (20.3.0) Requirement already satisfied: cffi!=1.11.3,>=1.8 in c:\users\bulu\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from cryptography>=2.1.4->azure-eventhub-checkpointstoreblob-aio) (1.14.0) Requirement already satisfied: oauthlib>=3.0.0 in c:\users\bulu\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from requests-oauthlib>=0.5.0->msrest>=0.6.10->azure-eventhub-checkpointstoreblob-aio) (3.1.0) Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in c:\users\bulu\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from requests~=2.16->msrest>=0.6.10->azure-eventhub-checkpointstoreblob-aio) (1.25.9) Requirement already satisfied: idna<3,>=2.5 in c:\users\bulu\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from requests~=2.16->msrest>=0.6.10->azure-eventhub-checkpointstoreblob-aio) (2.9) Requirement already satisfied: pycparser in c:\users\bulu\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from cffi!=1.11.3,>=1.8->cryptography>=2.1.4->azure-eventhub-checkpointstoreblob-aio) (2.20) WARNING: You are using pip version 20.2.1; however, version 20.2.4 is available. You should consider upgrading via the 'C:\Users\bulu\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\python.exe -m pip install --upgrade pip' command.
参考资料:
Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory \\METADATA : https://stackoverflow.com/questions/54778630/could-not-install-packages-due-to-an-environmenterror-errno-2-no-such-file-or
ERROR: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: https://www.admindiary.com/os/linux/error-could-not-install-packages-due-to-an-environmenterror-errno-2-no-such-file-or-directory.html
当在复杂的环境中面临问题,格物之道需:浊而静之徐清,安以动之徐生。 云中,恰是如此!