# Windows10从应用商店安装的python在使用pip过程中出现的对超长路径支持的问题以及解决方式

ERROR: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory:'C:\\Users\\UserName\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\\LocalCache\\localpackages\\Python37\\sitepackages\\caffe2\\python\\serialized_test\\data\\operator_test\\collect_and_distribute_fpn_rpn_proposals_op_test.test_collect_and_dist.zip

https://stackoverflow.com/questions/54778630/could-not-install-packages-due-to-an-environmenterror-errno-2-no-such-file-or

I got here by having this kind of error when I tried installing tensorflow library. My error was the following:

Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: 'c:\moj ifajlovi\faks\11master\1semestar\siap-sistemizaistrazivanjeianalizupodataka_(datamining)\projek at\rad\venvs\siap_venv\Lib\site-packages\tensorflow_estimator\python\estimator\canned\line ar_optimizer\python\utils\__pycache__\sharded_mutable_dense_hashtable.cpython-37.pyc'

So, there was no sharded_mutable_dense_hashtable.cpython-37.pyc file in the __pycache__ directory. But, sharded_mutable_dense_hashtable.cpython-37.pyc file was in the utils directory (which is the parent directory of __pycache__ directory).

That's why I tried manually copying the sharded_mutable_dense_hashtable.cpython-37.pyc file in the __pycache__ directory. When I tried that, I had a copy error which stated that the path was too long, so it couldn't put the file in the directory.

So, the solution:

Install the desired python package (in my case tensorflow) in the folder which has a shorter path (for example C:/my_py_packages/some_package) or set the registry value HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem@LongPathsEnabled to 1 as mentioned here.

The same error message can bite you when you pip install pytorch after getting python from Microsoft Store. +1 since your post got me onto the root cause "path too long", see reddit.com/r/pytorch/comments/c6cllq/issue_installing_pytorch – Jonas Heidelberg Aug 5 at 22:05

https://docs.python.org/3.7/using/windows.html

### 3.1.2. Removing the MAX_PATH Limitation¶

Windows historically has limited path lengths to 260 characters. This meant that paths longer than this would not resolve and errors would result.

In the latest versions of Windows, this limitation can be expanded to approximately 32,000 characters. Your administrator will need to activate the “Enable Win32 long paths” group policy, or set the registry value HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem@LongPathsEnabled to 1.

This allows the open() function, the os module and most other path functionality to accept and return paths longer than 260 characters when using strings. (Use of bytes as paths is deprecated on Windows, and this feature is not available when using bytes.)

After changing the above option, no further configuration is required.

Changed in version 3.6: Support for long paths was enabled in Python.

• 0
点赞
• 4
评论
• 3
收藏
• 打赏
• 扫一扫，分享海报

11-29 96
03-28 1万+
07-18 407
05-31 775
03-08 2384
10-23 1273
©️2022 CSDN 皮肤主题：大白 设计师：CSDN官方博客

ZWYZG

¥2 ¥4 ¥6 ¥10 ¥20

1.余额是钱包充值的虚拟货币，按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载，可以购买VIP、C币套餐、付费专栏及课程。