OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Interesting FileNotFound error while running pymetamap

  • Thread starter Thread starter Alex K
  • Start date Start date
A

Alex K

Guest
I have been attempting to setup and use MetaMap as outlined by Dr. Weissman here:

https://gweissman.github.io/post/us...s-the-umls-metathesaurus-a-quick-start-guide/

However, I seem to have reached an error while running this code cell:

Code:
cons, errs = metam.extract_concepts(note_list,
                                word_sense_disambiguation = True,
                                restrict_to_sts = ['sosy'], # signs and symptoms
                                composite_phrase = 1, # for memory issues
                                prune = 30)

The error is as follows:

Code:
---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
Cell In[66], line 1
----> 1 cons, errs = metam.extract_concepts(note_list,
      2                                 word_sense_disambiguation = True,
      3                                 restrict_to_sts = ['sosy'], # signs and symptoms
      4                                 composite_phrase = 1, # for memory issues
      5                                 prune = 30)

File ~\AppData\Local\anaconda3\Lib\site-packages\pymetamap\SubprocessBackend.py:190, in SubprocessBackend.extract_concepts(self, sentences, ids, composite_phrase, filename, file_format, allow_acronym_variants, word_sense_disambiguation, allow_large_n, strict_model, relaxed_model, allow_overmatches, allow_concept_gaps, term_processing, no_derivational_variants, derivational_variants, ignore_word_order, unique_acronym_variants, prefer_multiple_concepts, ignore_stop_phrases, compute_all_mappings, prune, mm_data_version, exclude_sources, restrict_to_sources, restrict_to_sts, exclude_sts, no_nums)
    187 input_command.append('-e')
    188 input_command.append(input_text)
--> 190 input_process = subprocess.Popen(input_command, stdout=subprocess.PIPE)
    191 metamap_process = subprocess.Popen(command, stdout=subprocess.PIPE, stdin=input_process.stdout)
    193 output, error = metamap_process.communicate()

File ~\AppData\Local\anaconda3\Lib\subprocess.py:1026, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group)
   1022         if self.text_mode:
   1023             self.stderr = io.TextIOWrapper(self.stderr,
   1024                     encoding=encoding, errors=errors)
-> 1026     self._execute_child(args, executable, preexec_fn, close_fds,
   1027                         pass_fds, cwd, env,
   1028                         startupinfo, creationflags, shell,
   1029                         p2cread, p2cwrite,
   1030                         c2pread, c2pwrite,
   1031                         errread, errwrite,
   1032                         restore_signals,
   1033                         gid, gids, uid, umask,
   1034                         start_new_session, process_group)
   1035 except:
   1036     # Cleanup if the child failed starting.
   1037     for f in filter(None, (self.stdin, self.stdout, self.stderr)):

File ~\AppData\Local\anaconda3\Lib\subprocess.py:1538, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, unused_restore_signals, unused_gid, unused_gids, unused_uid, unused_umask, unused_start_new_session, unused_process_group)
   1536 # Start the process
   1537 try:
-> 1538     hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
   1539                              # no special security
   1540                              None, None,
   1541                              int(not close_fds),
   1542                              creationflags,
   1543                              env,
   1544                              cwd,
   1545                              startupinfo)
   1546 finally:
   1547     # Child is launched. Close the parent's copy of those pipe
   1548     # handles that only the child should have open.  You need
   (...)
   1551     # pipe will not close when the child process exits and the
   1552     # ReadFile will hang.
   1553     self._close_pipe_fds(p2cread, p2cwrite,
   1554                          c2pread, c2pwrite,
   1555                          errread, errwrite)

FileNotFoundError: [WinError 2] The system cannot find the file specified

What I struggle to understand is the actual file being specified. In the last line, it seems a pipe is being closed; however, I don't see where the FileNotFoundError becomes relevant.

A helpful question posed on StackOverflow was the following:

FileNotFoundError: [WinError 2] The system cannot find the file specified:

However, in this case the unknown file was explicitly obvious and a solution by changing paths was viable. This doesn't seem to work in my situation, but I could be wrong as I am not very experienced.

Please advise - any feedback would be greatly appreciated.
<p>I have been attempting to setup and use MetaMap as outlined by Dr. Weissman here:</p>
<p><a href="https://gweissman.github.io/post/us...s-the-umls-metathesaurus-a-quick-start-guide/" rel="nofollow noreferrer">https://gweissman.github.io/post/us...s-the-umls-metathesaurus-a-quick-start-guide/</a></p>
<p>However, I seem to have reached an error while running this code cell:</p>
<pre><code>
cons, errs = metam.extract_concepts(note_list,
word_sense_disambiguation = True,
restrict_to_sts = ['sosy'], # signs and symptoms
composite_phrase = 1, # for memory issues
prune = 30)
</code></pre>
<p>The error is as follows:</p>
<pre><code>
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
Cell In[66], line 1
----> 1 cons, errs = metam.extract_concepts(note_list,
2 word_sense_disambiguation = True,
3 restrict_to_sts = ['sosy'], # signs and symptoms
4 composite_phrase = 1, # for memory issues
5 prune = 30)

File ~\AppData\Local\anaconda3\Lib\site-packages\pymetamap\SubprocessBackend.py:190, in SubprocessBackend.extract_concepts(self, sentences, ids, composite_phrase, filename, file_format, allow_acronym_variants, word_sense_disambiguation, allow_large_n, strict_model, relaxed_model, allow_overmatches, allow_concept_gaps, term_processing, no_derivational_variants, derivational_variants, ignore_word_order, unique_acronym_variants, prefer_multiple_concepts, ignore_stop_phrases, compute_all_mappings, prune, mm_data_version, exclude_sources, restrict_to_sources, restrict_to_sts, exclude_sts, no_nums)
187 input_command.append('-e')
188 input_command.append(input_text)
--> 190 input_process = subprocess.Popen(input_command, stdout=subprocess.PIPE)
191 metamap_process = subprocess.Popen(command, stdout=subprocess.PIPE, stdin=input_process.stdout)
193 output, error = metamap_process.communicate()

File ~\AppData\Local\anaconda3\Lib\subprocess.py:1026, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group)
1022 if self.text_mode:
1023 self.stderr = io.TextIOWrapper(self.stderr,
1024 encoding=encoding, errors=errors)
-> 1026 self._execute_child(args, executable, preexec_fn, close_fds,
1027 pass_fds, cwd, env,
1028 startupinfo, creationflags, shell,
1029 p2cread, p2cwrite,
1030 c2pread, c2pwrite,
1031 errread, errwrite,
1032 restore_signals,
1033 gid, gids, uid, umask,
1034 start_new_session, process_group)
1035 except:
1036 # Cleanup if the child failed starting.
1037 for f in filter(None, (self.stdin, self.stdout, self.stderr)):

File ~\AppData\Local\anaconda3\Lib\subprocess.py:1538, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, unused_restore_signals, unused_gid, unused_gids, unused_uid, unused_umask, unused_start_new_session, unused_process_group)
1536 # Start the process
1537 try:
-> 1538 hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
1539 # no special security
1540 None, None,
1541 int(not close_fds),
1542 creationflags,
1543 env,
1544 cwd,
1545 startupinfo)
1546 finally:
1547 # Child is launched. Close the parent's copy of those pipe
1548 # handles that only the child should have open. You need
(...)
1551 # pipe will not close when the child process exits and the
1552 # ReadFile will hang.
1553 self._close_pipe_fds(p2cread, p2cwrite,
1554 c2pread, c2pwrite,
1555 errread, errwrite)

FileNotFoundError: [WinError 2] The system cannot find the file specified
</code></pre>
<p>What I struggle to understand is the actual file being specified. In the last line, it seems a pipe is being closed; however, I don't see where the FileNotFoundError becomes relevant.</p>
<p>A helpful question posed on StackOverflow was the following:</p>
<p><a href="https://stackoverflow.com/questions...r-2-the-system-cannot-find-the-file-specified">FileNotFoundError: [WinError 2] The system cannot find the file specified:</a></p>
<p>However, in this case the unknown file was explicitly obvious and a solution by changing paths was viable. This doesn't seem to work in my situation, but I could be wrong as I am not very experienced.</p>
<p>Please advise - any feedback would be greatly appreciated.</p>
 
Top