Error: "target path exists but is not a directory, will not continue" pip installation problems

Question:

I tried installing a new package with pip on Python 3.8.5 (it was working previously) and got this error. I also tried upgrading pip with pip, and it looked like it was upgrading but didn’t do so. Tried a fresh install of 3.8.5, still got it. Then I tried installing Python 3.8.0 and got the error again. I’ve deleted virtual environments, created new ones, checked PATH variables, uninstalled and reinstalled Python with it both in and out of the PATH.

I’m at a complete loss for words. If anyone can help, that’d be GREATLY appreciated.

I’ve ran pip install terminaltables, py -m pip install terminaltables, and specified both destination folders and target folders; e.g. py -m pip install terminaltables --target C:UsersmeAppDataLocalPythonPython38Libsite-packages. The error, every time, is ERROR: Target path exists but is not a directory, will not continue.

This is the pip install -vvv output:

Exception information:
Traceback (most recent call last):
  File "c:usersxappdatalocalprogramspythonpython38libsite-packagespip_internalclibase_command.py", line 188, in main
    status = self.run(options, args)
  File "c:usersxappdatalocalprogramspythonpython38libsite-packagespip_internalcommandsinstall.py", line 275, in run
    raise CommandError(
pip._internal.exceptions.CommandError: Target path exists but is not a directory, will not continue.

Also, I got the machine about 2 months ago and it’s been working fine up until this issue. I’ve tried disabling things in Windows Security, unencrypting my drives, etc.

Asked By: Terreras

||

Answers:

Try typing in "pip config list" you may find configuration settings. If you see one that starts with :env: it is in an environment variable. if you have :env:.target for example it will be an environment variable named PIP_TARGET. "target may also be set at the pip global, user or site level in the pip.ini file. Most standard installations will not have any config entries. If you see a site.target, user.target, global.target or :env:.target you can unset it using "pip config unset user.target" for example. You can also delete it from the pip.ini file directly. If it is a system environment variables you can delete/unset it and try again.

Answered By: John Beaulieu

pip did not install the package in the correct site-packages path.To find the correct package path, inside your IDE run:

from distutils.sysconfig import get_python_lib
print(get_python_lib())

The output should be site-packages path, for example:

/home/user/.pyenv/versions/3.8.9/lib/python3.8/site-packages

In the terminal, to set pip to intall in this path:

pip config set global.target /home/user/.pyenv/versions/3.8.9/lib/python3.8/site-packages
Answered By: Tirelo SHIKWAMABANA

In my case, pip config list returns something. It turns out, I have set the global default pip install location at $HOME/.pip/pip.conf . I removed that file and the problem is solved.

Source: https://stackoverflow.com/a/24175174

Answered By: Jordan He
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.