lundi 2 novembre 2020

Tensorflow Object Detection API - PYTHONPATH unsets itself, when using different terminal

This might be a silly question, but I didn't find anything on the internet. I am trying to run the object_detection API of tensorflow in Windows 10. I've installed all the packages correctly and I've also added the "models" directory to the PYTHONPATH, using windows cmd:

set PYTHONPATH=C:\Program Files\Tensorflow\models

And I also verify that the PYTHONPATH is set correctly, by typing set PYTHONPATH, which gives me this output:

PYTHONPATH=C:\Program Files\Tensorflow\models

Running the following test

python research/object_detection/builders/model_builder_tf2_test.py

I get the output:

Ran 20 tests in 37.331s
OK (Skipped 1)

Which is great. However, If I open another terminal and type

python research/object_detection/builders/model_builder_tf2_test.py

I get the error: ModuleNotFoundError: No Module named official

However, If i type set PYTHONPATH command to verify that the PYTHONPATH is correct I get:

PYTHONPATH=C:\Users\Kohli\AppData\Local\Programs\Python\Python37\Scripts\Tensorflow\models;C:\Users\Kohli\AppData\Local\Programs\Python\Python37\Scripts\Tensorflow\models\official;C:\Users\Kohli\AppData\Local\Programs\Python\Python37\Scripts\Tensorflow\models\research

which is different from the previous terminal output. Moreover, when I open the "Enviroment Variables" tab, I can see that PYTHONPATH exists.

If I add the models directory to PYTHONPATH once again, It will work, but Only for that particular terminal. However, I don't understand why this is happening. Does the "set PYTHONPATH" command creates a virtual environment for that particular terminal or something? How can i permanently add models dir to PYTHONPATH, without typing set PYTHONPATH or os.path.append('path/to/models') ?

Thanks in advance

Aucun commentaire:

Enregistrer un commentaire