AnthonyMRios/pymetamap

Unable to use pymetamap in windows

Closed this issue · 14 comments

I installed the pymetamap setup in windows and try to use it, but the metamap instance was unable to extract concepts from the sentences. I tried to run the same code given i.e

from pymetamap import MetaMap
mm = MetaMap.get_instance('...../public_mm/bin/metamap14')
sents = ['Heart Attack', 'John had a huge heart attack']
concepts,error = mm.extract_concepts(sents,[1,2])
but after this I get the error:
Traceback (most recent call last):
File "", line 1, in
File "C:\Anaconda2\lib\site-packages\pymetamap-0.1-py2.7.egg\pymetamap\Subproc
essBackend.py", line 127, in extract_concepts
os.remove(input_file.name)
WindowsError: [Error 32] The process cannot access the file because it is being
used by another process: 'c:\users\abhila~1.kas\appdata\local\temp\tmp00rn
u0'
I have metamap14 installed on my pc.

Currently the Subprocess backend does not work with windows currently. This is because I'm using NamedTemporaryFile. I will see what I can do to get it to work for you.

Thanks for your response, I would be grateful to you if you could help me in this.

Any update on this ?

Send me an email at anthonymrios@gmail.com. I will send a zip file with a quick fix. I'm not really sure if I want to officially support Windows.

dterg commented

Is it possible to share the solution? Cheers

I am using Linux and I am having also problems with the Subprocess Backend. This is the error that appears.

_Traceback (most recent call last):
File "metamap_trying.py", line 6, in
concepts, error=mm.extract_concepts(sents, [1,2])
File "/home/ijauregi/Desktop/CMCRC/pymetamap-master/pymetamap/SubprocessBackend.py", line 117, in extract_concepts
metamap_process = subprocess.Popen(command, stdout=subprocess.PIPE)
File "/usr/local/python-2.7/lib/python2.7/subprocess.py", line 710, in init
errread, errwrite)
File "/usr/local/python-2.7/lib/python2.7/subprocess.py", line 1335, in execute_child
raise child_exception
OSError: [Errno 2] No such file or directory

Do you know why is that?

Have a code sample?

Have you installed metamap? It looks like you may not be pointing to the correct metamap file.

Please make a new issue since this is not related to the windows problem.

You were right. I wasn't pointing to the correct Metamap file. Anyway, now I have a different problem. This is my error:

Berkeley DB databases (USAbase 2016AA strict model) are open.
Static variants will come from table varsan in /home/ijauregi/Desktop/CMCRC/Journal-Inigo/public_mm/DB/DB.USAbase.2016AA.strict.
Derivational Variants: Adj/noun ONLY.
Variant generation mode: static.

###MetaMap ERROR: Calling socket_client_open for TAGGER Server on host localhost and port 1795:
error(system_error,system_error(SPIO_E_NET_CONNREFUSED))

My code is the following:

from pymetamap import MetaMap
mm=MetaMap.get_instance('/home/ijauregi/Desktop/CMCRC/JournalInigo/public_mm/bin/metamap16)
sents=['Heart Attac','John had a huge heart attack']
concepts, error=mm.extract_concepts(sents, [1,2])
for concept in concepts:
    print concept

Thanks

I found the problem. I forgot to initialize the SKR/Medpost Part-of-Speech Tagger Server and the Word Sense Disambiguation (WSD) Server. I have first initialize them and now the code works.
Thank you anyway!

Glad you got it to work!

Is there any alternative way to make this work in windows.

Hi! Is it possible to share to workaround for getting this API wrapper working in Windows? I am working on a project but have a windows platform.

Hi @AnthonyMRios ,

I have tried using the pymetamap on the windows OS.
It does get installed successfully, but when I try to run it over some sentences, it gives me an OS Error.

Runs Perfectly:

from pymetamap import MetaMap mm = MetaMap.get_instance(r'C:\Users\Kanishk Verma\Desktop\Radmol AI\MetaMap\public_mm\bin\metamap14') sents = ['Heart Attack', 'John had a huge heart attack']

Gives Error

concepts,error = mm.extract_concepts(sents,[1,2])

Error

OSError: [WinError 193] %1 is not a valid Win32 application

During handling of the above exception, another exception occurred:

PermissionError: [WinError 32] The process cannot access the file because it is being used by another process:

I checked the file in the temporary directory, but it is not being used by other applications.