How Do You Troubleshoot the Python3 Error “No such file or directory: ‘/usr/local/lib/python3.6/site-packages/” on RHEL 8.x?

One or more of the following problems are happening to you:

Problem scenario #1
You run python3 install on RHEL 8.x, but you get an error message like this:

running install
error: can't create or remove files in install directory

The following error occurred while trying to add or remove files in the
installation directory:

    [Errno 2] No such file or directory: '/usr/local/lib/python3.6/site-packages/test-easy-install-52191.write-test'

The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:


This directory does not currently exist.  Please create it and try again, or
choose a different installation directory (using the -d or --install-dir

Problem scenario #2
You try to "--install-dir" flag, but you get a message like this: error: option --install-dir not recognized

Problem scenario #3
You saw an error message about "error: bad install directory or PYTHONPATH", but you do not know what to do.

What should you do?


  1. First, identify which directory is attempted. sudo python3 install --prefix=/tmp
  2. Secondly, find where the site-packages (or most child, or most "sub", subdirectory) that was in the first error. Run a command like this (but replace "site-packages" with the most child subdirectory in the error): sudo find / -name site-packages -type d
  3. Figure out how to use the --prefix= option based on the findings of the above. We do not recommend using absolute paths to have logic to get the directory to be passed (for this specific purpose of using We recommend using relative paths. Here is an example that could work:

sudo python3 install --prefix ../..

Leave a comment

Your email address will not be published. Required fields are marked *