pfc
pfc

Reputation: 1910

How to permanently remove a path from python import path

I'm using python. I installed an erroneous module and now I want to delete and reinstall it. Since it is erroneous, I cannot use pip uninstall to remove it. Instead, I have to manually delete the packages. I managed to delete the packages, but problem happened to the import path. When I delete the directory of the package, say /home/mypath/directory/, from my PC. Then the import path disappears when I run the commands:

import sys
print sys.path

There is no that directory in the printed results. However, when I recreate that directory, and run the commands again:

import sys
print sys.path

that directory appears again. How can I make the system not visit that directory? I know there is an environment variable PYTHONPATH, but I only know how to add path using PYTHONPATH, I don't know how to remove path. Thank you all for helping me!!!

Upvotes: 4

Views: 4706

Answers (1)

xioxox
xioxox

Reputation: 2680

The path is likely being picked up from a pth file in your user-specific package directory.

For me easy-install.pth contains packages installed by pip. You can look for this file and edit out the offending directory.

Upvotes: 2

Related Questions