【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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM