5

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.

Richard O'Brien
  • 61
  • 1
  • 1
  • 3
  • Did you not accidentally delete one of your directories/files? – Pythoneer Dec 27 '22 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. – Richard O'Brien Dec 29 '22 at 03:38

5 Answers5

1

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.

Richard O'Brien
  • 61
  • 1
  • 1
  • 3
1

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.

  • 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? – Jeremy Caney Sep 13 '22 at 00:11
1

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.
Meric Ozcan
  • 678
  • 5
  • 25
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

Vincent Casey
  • 178
  • 2
  • 11
  • 4
    I also looked for the file mentioned in the error and did not find it indeed. However, I followed the steps in this answer (https://stackoverflow.com/a/63712528/10141530) and the issue was resolved successfully. – Tedpac Dec 31 '21 at 23:37
0

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.