How to install python updater to install dir after folder move?

I have installed a Python module from GitHub. Below is an example of the commands I have executed:

cd ~/modules/
git clone https://github.com/user/xyz
cd xyz
python setup.py develop

      

this installed the module successfully in the current folder. Then from another folder I did:

cd ~/test
python -c 'import inspect; import xyz; print(inspect.getfile(xyz))'

      

which gave the following output:

/home/hakon/modules/xyz/xyz/__init__.py

      

Now I decided to move the installation folder. For example,

cd ~/modules/xyz
mv xyz xyz2

      

But now Python can't find the module anymore. For example:

cd ~/test
python -c 'import inspect; import xyz; print(inspect.getfile(xyz))'

      

With the exit:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'xyz'

      

Questions:

  • Where does Python register module locations?
  • How do I update the registry to the new module location?
+3


source to share


1 answer


According to the documentation for customization tools develop

:

The development team works by creating a file .egg-link

(named for project) in a given staging area. If the staging area is Pythons site-packages, it also updates the file easy-install.pth

, so that the project is on sys.path

by default for all programs run using that Python installation.

So, to answer the question about updating the location after moving the project folder, you can rerun the command develop

(from the new folder):

python setup.py develop

      



Note. You can also unregister a project before moving it:

python setup.py develop --unistall

      

but this is optional if you just want to update the location.

+2


source







All Articles