I installed a Python module from GitHub. Here is an example of the commands I ran:
cd ~/modules/
git clone https://github.com/user/xyz
cd xyz
python setup.py develop
this installed the the module successfully in the current folder. Then from some other 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 I wanted to move the install folder. For example,
cd ~/modules/xyz
mv xyz xyz2
But now Python cannot find the module any longer. For example:
cd ~/test
python -c 'import inspect; import xyz; print(inspect.getfile(xyz))'
With output:
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'xyz'
According to the documentation for setup tools develop command:
The develop command works by creating an
.egg-linkfile (named for the project) in the given staging area. If the staging area is Python’s site-packages directory, it also updates aneasy-install.pthfile so that the project is onsys.pathby default for all programs run using that Python installation.
So to answer the question to update the location after you have moved the project folder you can rerun the develop command (from the new folder):
python setup.py develop
Note: you could also unregister the project before you moved it:
python setup.py develop --unistall
but this is not necessary if you just want to update the location.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With