Zubda
Zubda

Reputation: 963

Remove package path from `sys.path` installed via `pip install -e`

I think I messed up a bit... I was trying to use pip to install a local project as a dependency of another project, and I used pip install -e PATH_TO_PROJECT and now the path to the project is in sys.path, (I have already changed the way I install the local project (I installed it in the client code using github)) and I deleted the .egg-info file from the pip install -e project.

How can I remove said project path from sys.path?

(Here is my sys.path output)

>>> import sys
>>> sys.path
['',
 '/usr/lib/python37.zip',
 '/usr/lib/python3.7',
 '/usr/lib/python3.7/lib-dynload',
 '~/.local/lib/python3.7/site-packages',
 '~/Projects/my_project', # <- local project path installed via `pip install -e`
 '/usr/local/lib/python3.7/dist-packages',
 '/usr/lib/python3/dist-packages']

EDIT: when I try uninstalling via pip uninstall project_name or pip uninstall PATH_TO_PROJECT I get this error

You must give at least one requirement to uninstall (see "pip help uninstall")

Upvotes: 3

Views: 2083

Answers (1)

phd
phd

Reputation: 94676

In ~/.local/lib/python3.7/site-packages/ lookup the file my_project.egg-link. Remove it. From the file easy-install.pth in the same site-packages/ delete the line ~/Projects/my_project. Check with pip list --local and python -c "import sys; print(sys.path)".

Upvotes: 3

Related Questions