8

I'm trying to install TensorFlow but I keep getting a longpath error , I have Python 3.9 installed and pip 21.3.1. Whenever I run pip install tensorflow I receive the following error:

ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: 'C:\Users\obrie\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\tensorflow\include\external\com_github_grpc_grpc\src\core\ext\filters\client_channel\lb_policy\grpclb\client_load_reporting_filter.h' HINT: This error might have occurred since this system does not have Windows Long Path support enabled. You can find information on how to enable this at https://pip.pypa.io/warnings/enable-long-paths

This seems to clearly be an error caused by the fact that LongPathsEnabled was set to false by default. I've got into my registry editor, gone to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem and changed LongPathsEnabled to a value of 1.

LongPathsEnabled set to 1

I've restarted my computer, but still get the longpaths error. Please help me understand what I am missing.

2
  • Did you not accidentally delete one of your directories/files? Commented Dec 27, 2022 at 15:30
  • Not to my knowledge. I believe the root of the error consisted of a combination of not originally having the longpathenabled parameter set to 1, and having Python installed from the Microsoft store, instead of just installing from the website with their wizard. But, to this day I'm not exactly sure what the exact problem was. Commented Dec 29, 2022 at 3:38

6 Answers 6

12

This fixed the problem for me!! Here are the steps to enable long path support:

  1. Open the Start menu and type "gpedit.msc" in the search bar. Press Enter to open the Local Group Policy Editor.
  2. In the editor, navigate to "Computer Configuration" > "Administrative Templates" > "System" > "Filesystem".
  3. Double-click the "Enable Win32 long paths" policy and set it to "Enabled".
  4. Click "OK" to save the policy changes.
  5. Restart your computer to apply the changes.
Sign up to request clarification or add additional context in comments.

Comments

5

For those trying to solve it without admin rights to change registry, I solved it using subst command in cmd terminal:

subst j: c:\path\to\the\folder\of\your\python\environment

Then activate the environment using new short path j:\python_env. Once it's done pip doesn't raise an error anymore.

Comments

3

After some struggle, I found that there is no gpedit on Windows 11 Home
We can still we can do regedit as below.
Also I was looking for some pictures in answer for quick help, here it is:

regedit LongPathsEnabled 1

2 Comments

Working perfectly! June 2025
Yer it's working
2

I solved the problem though, I'm a bit unsure how, so I will post my process so that way if anyone else runs into this same problem, they can not run into such a frustrating issue.

  1. I uninstalled python and Pip.
  2. Instead of downloading python from the Microsoft Store, I downloaded it from the python website - Be sure to add it to your path as you when installing it. I downloaded Python 3.9.8
  3. Do not update pip
  4. Pip install tensorflow

I suspect the problem was either with updating pip, or with installing python via the Microsoft store, not via the installer on the website. But regardless is works now.

Comments

2

I recently encountered this error. The changing the enablelongpaths to 1 in the registry resolved it. I couldn't get gpedit changes to take hold.

1 Comment

The question says that setting LongPathsEnabled to 1 in the registry did not resolve the issue for them, however. Are you suggesting they should have used EnableLongPaths instead of LongPathsEnabled? Or was that a typo on your part?
0

When going to the file that it suggested did not exist, I found that the file (as a matter of fact) did not exist at the location.

Here is the source code for said file: https://clickhouse.com/codebrowser/html_report/ClickHouse/contrib/grpc/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h.html

Once you are able to alter files again you may add it to fix the issue

1 Comment

I also looked for the file mentioned in the error and did not find it indeed. However, I followed the steps in this answer (stackoverflow.com/a/63712528/10141530) and the issue was resolved successfully.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.