chrismattmann / tika-python

Tika-Python is a Python binding to the Apache Tika™ REST services allowing Tika to be called natively in the Python community.
Apache License 2.0
1.51k stars 235 forks source link

"module 'os' has no attribute 'setsid'" error in Windows #282

Closed walter-hernandez closed 4 years ago

walter-hernandez commented 4 years ago

Hello all:

I got the following error: TikaServerProcess = Popen(cmd_string, stdout=logFile, stderr=STDOUT, shell=True, preexec_fn=os.setsid) AttributeError: module 'os' has no attribute 'setsid'

This is because os.setsid is only available in Unix based os. In the meantime that the issue is solved, you can run the server independently using the docker image:

docker pull apache/tika

and running: docker run -d -p 9998:9998 apache/tika:<version>

which for version 1.23 is: docker run -d -p 9998:9998 apache/tika:1.23

to use it with the python library: parsed = parser.from_file('/tmp/pdf-sample.pdf', 'http://localhost:9998/tika')

Dobatymo commented 4 years ago

Same here.

  File "tika\parser.py", line 40, in from_file
    output = parse1(service, filename, serverEndpoint, headers=headers, config_path=config_path, requestOptions=requestOptions)
  File "tika\tika.py", line 338, in parse1
    rawResponse=rawResponse, requestOptions=requestOptions)
  File "tika\tika.py", line 531, in callServer
    serverEndpoint = checkTikaServer(scheme, serverHost, port, tikaServerJar, classpath, config_path)
  File "tika\tika.py", line 598, in checkTikaServer
    status = startServer(jarPath, TikaJava, TikaJavaArgs, serverHost, port, classpath, config_path)
  File "tika\tika.py", line 669, in startServer
    TikaServerProcess = Popen(cmd_string, stdout=logFile, stderr=STDOUT, shell=True, preexec_fn=os.setsid)
AttributeError: module 'os' has no attribute 'setsid'
chrismattmann commented 4 years ago

should be fixed when I release 1.23.2 this week.

chrismattmann commented 4 years ago

can you test out the latest from master and report back @walter-hernandez ?

whughes001 commented 4 years ago

Just FYI, it worked for me. Using PyCharm 2019 Professional. Thanks for the quick fix.

walter-hernandez commented 4 years ago

@chrismattmann It is working! Thank you so much for fixing it!

walter-hernandez commented 4 years ago

I am going to close this issue. Thank you again @chrismattmann

chrismattmann commented 4 years ago

awesome thanks I'll update this and publish the new version this week. thanks @walter-hernandez ! if you are able and your company sees value in Tika Python, consider my Github Sponsors page.

LREN721 commented 2 years ago

Hi, Chris! we are student working on a project with tika-python. Our instructor asked us to download version 1.9 yet I am still running the problem with os.setsid no attribute error. I am trying to figure out how to resolve this, should we still try to downgrade to version 1.23 for bypassing this issue?

Thank you so much and regards,