ImportError: cannot import name parser with tika-python
Asked Answered
R

1

6

Done with :

  • java -jar tika-server-path --port xxxx
  • pip install tika (virtualenv)

parser-tika.py

  import tika 
  from tika import parser 
  parsed = parser.from_file('/path/to/file')
  print parsed["metadata"]
  print parsed["content"]

error : ImportError: cannot import name parser

env setup:

TIKA_VERSION=1.13.1
TIKA_SERVER_JAR=~/parserDev/tika/tika-server-1.13.jar
TIKA_SERVER_ENDPOINT=http://localhost:8989/tika
Rosanne answered 2/10, 2016 at 14:22 Comment(5)
maybe you created file tika.py and now it imports your file instead of expected module.Cavalryman
Such a lame mistake thank you. @CavalrymanRosanne
@Rosanne can you give me a tip, where I need to put the TIKA_SERVER_JAR directive?Flutist
@Flutist You can put it anywhere and start server from the same location. It worked for me.Hopfinger
@Cavalryman you are a saver dudeBombycid
A
4

You can't have a file called tika.py in the current directory because that's the name of a different tika you are trying to import.

Simply rename your file.

Antebellum answered 10/4, 2023 at 18:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.