Import from Github : How to fix ImportError
I want to use the open source person re-identification library in Python


on Ubuntu 19.04
with Anaconda
no CUDA
in the terminal PyCharm (or not)
Python version 3.7.3
PyTorch version 1.1.0


For that I have to follow instruction like on their deposite git :

git clone https://github.com/Cysu/open-reid.git
cd open-reid
python setup.py install

python examples/softmax_loss.py -d viper -b 64 -j 2 -a resnet50 --logs-dir logs/softmax-loss/viper-resnet50


I receive the following error:

from sklearn.utils.extmath
import pinvh



  ImportError: cannot import name 'pinvh'


I have tried to create virtual environments with previous versions of PyTorch (0.4.1, 0.4.0 and 1.0.1) but I always got:

  File "examples/softmax_loss.py", line 12, in &lt;module&gt;
    from reid import datasets
ModuleNotFoundError: No module named 'reid'


I do not know how to fix it.

EDIT : 

Hi thanks for the answer, the problem is that the import are like :

from reid import datasets
from reid import models
from reid.dist_metric import DistanceMetric
from reid.trainers import Trainer
from reid.evaluators import Evaluator
from reid.utils.data import transforms as T
from reid.utils.data.preprocessor import Preprocessor
from reid.utils.logging import Logger
from reid.utils.serialization import load_checkpoint, save_checkpoint


I tried :

from ../reid import datasets


But I got a

File "examples/softmax_loss.py", line 12
from ../reid import datasets
   ^
SyntaxError: invalid syntax


EDIT 2 :
After re-installing Python 3.7.3 and pytorch 1.1.0 the problem persist with pinvh... I still got this message :

ImportError: cannot import name 'pinvh' from 'sklearn.utils.extmath' 


If you can tell me how to fix it or try to tell me if it works please 

Since the directory structure is as below:

/(root)--&gt;|
          |
          |--&gt;reid |--&gt; (contents inside reid)
          |
          |
          |--&gt;examples | --&gt;softmax_loss.py
          |
          |--&gt;(Other  contents in root directory)


It can be observed that reid is not in the same directory as softmax_loss.py, but instead in the parent directory.

So, in the file softmax_loss.py, at line number 12 and below, replace reid with ../reid, this looks for the directory reid in the parent directory.

The other method is to use: import ../reid as R or any other variable; Then use from R import datasets, and so on
