0

I run Concept Annotation Tool (CAT) using Docker and then I installed it in the same way as in the following website: https://libraries.io/pypi/medcat These steps were successful.

Then I wanted to implement it in my Python code. When I run the code I get an error from the import lines:

Traceback (most recent call last):

  File "<ipython-input-10-32d167ab52db>", line 1, in <module>
    runfile('C:/Users/as/Desktop/Data/Preprocessing.py', wdir='C:/Users/as/Desktop/Data')

  File "C:\Users\as\AppData\Local\Continuum\anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 786, in runfile
    execfile(filename, namespace)

  File "C:\Users\as\AppData\Local\Continuum\anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "C:/Users/as/Desktop/Data/Preprocessing.py", line 27, in <module>
    from medcat.cat import CAT

  File "C:\Users\as\AppData\Local\Continuum\anaconda3\lib\site-packages\medcat\cat.py", line 4, in <module>
    from medcat.cdb import CDB

  File "C:\Users\as\AppData\Local\Continuum\anaconda3\lib\site-packages\medcat\cdb.py", line 9, in <module>
    from medcat.utils.loggers import basic_logger

  File "C:\Users\as\AppData\Local\Continuum\anaconda3\lib\site-packages\medcat\utils\loggers.py", line 6, in <module>
    logging.basicConfig(filename='/tmp/cat.log', level=logging.DEBUG)

  File "C:\Users\as\AppData\Local\Continuum\anaconda3\lib\logging\__init__.py", line 1900, in basicConfig
    h = FileHandler(filename, mode)

  File "C:\Users\as\AppData\Local\Continuum\anaconda3\lib\logging\__init__.py", line 1092, in __init__
    StreamHandler.__init__(self, self._open())

  File "C:\Users\as\AppData\Local\Continuum\anaconda3\lib\logging\__init__.py", line 1121, in _open
    return open(self.baseFilename, self.mode, encoding=self.encoding)

  FileNotFoundError: [Errno 2] No such file or directory: 'C:\\tmp\\cat.log'

The code I run is:

from medcat.cat import CAT
from medcat.utils.vocab import Vocab
from medcat.prepare_cdb import PrepareCDB
from medcat.cdb import CDB

vocab = Vocab()
#Load the vocab model
vocab.load_dict('C:/Users/as/Desktop/Data/med_ann_norm_dict.dat')

#build a special CDB from a .csv file
preparator = PrepareCDB(vocab=vocab)
csv_paths = ['C:/Users/as/Desktop/Data/codes.csv']
cdb = preparator.prepare_csvs(csv_paths)

#Annotate the text
doc = text
cat = CAT(cdb=cdb, vocab=vocab)

I also tried to find the file so I searched for the %tmp% directory. The search returned me the Temp directory, and there is no file called cat.log.

Alan
  • 129
  • 1
  • 13
  • When you run *what* code? You haven't posted any code. – Scott Hunter Jun 24 '19 at 14:02
  • Please edit your question to post the full traceback. – bruno desthuilliers Jun 24 '19 at 14:09
  • 1
    I just edited the question. – Alan Jun 24 '19 at 14:13
  • 1
    And you are sure that the directory `C:\tmp` exists? There's a difference between "temp" and "tmp". – Matthias Jun 24 '19 at 14:15
  • Yes, I also typed in the CMD `ECHO %Temp%` and it returned me the pathway. – Alan Jun 24 '19 at 14:18
  • Did you try to add the directory? I mean, it probably wouldn't hurt to 'mkdir tmp' in the root directory of your C partition or 'touch C:\tmp\cat.log' to create the file itself. – meissner_ Jun 24 '19 at 14:45
  • You are right, I only had the Temp directory. I created the tmp one, then I installed the medcat package again. But I still get the same error..and there's no cat.log file in the new tmp directory – Alan Jun 24 '19 at 14:58
  • Well, to get the file itself you just need to create it in your file explorer or use 'touch cat.log' in C:\tmp (not sure if cmd knows the touch command tho...) – meissner_ Jun 24 '19 at 16:04

0 Answers0