0

I am using a module by another party (from github) and I installed it via its setup.py. Now I wanted to change some things and test my changes, similarly to this:

def function(a, testA=False, testB=False):
    print(a)
    if testA:
        print('test A true')
    if testB:
        print('test B true')

In the original code, only test A exists. Now I removed the installed module according to the accepted answer of this question: python setup.py uninstall

Afterwards I reinstalled the module with setup.py, this time I had included my change. The module again works as expected, but when I call:

function('a', testB=True)

I get a TypeError function() got an unexpected keyword argument 'testB'. This doesn't make sense to me. It behaves as if I never had changed anything. Can anybody explain what I am probably missing here?

fruchti
  • 53
  • 10
  • Quite hard to guess what went wrong. Did you make sure that you built the install files including your changes with `python setup.py build` before installing? – JE_Muc Jul 24 '20 at 14:14
  • no, I had not, but I did it now, iterating the process and still no change – fruchti Jul 24 '20 at 14:20
  • Import your module, f.i. with `import othermodule as om`, and then check the output of `om.__file__` and `om.__path__`. Now go to this folder and look for the file where you added the lines. Are the lines in the file? If no: Try adding them to this file. This may not be the "correct" way to do it, but it is quick and dirty. The correct way would imho be: Clone the repo and set up the module in your own env to enable changing the module and including the changes in the build. – JE_Muc Jul 24 '20 at 14:27
  • what if the lines are already in the file there? – fruchti Jul 24 '20 at 16:24

1 Answers1

0

Even though I did not find the cause of the specific error, I did find something that is actually what I wanted to do (without knowing of the possibility). It helps a lot and may help with troubleshooting similar problems:

remove the package

navigate to the folder of the package

pip install -e .

With the -e option pip installs the package as a symlink, which means that the installation uses the python files contained in the folder as the installation. This allows to use changes in these files directly and without repeated reinstallation.

fruchti
  • 53
  • 10