简体   繁体   中英

How to set environment variable to localhost?

I have a very basic question regarding environment variables. The Tika python library that I'm trying to work with mentioned the following:

TIKA_SERVER_ENDPOINT: set to the host (local or remote) for the running Tika server jar

I downloaded the server jar from here and ran it with java -jar jarname.jar I'm trying to set the environment variable to the localhost, but I'm not sure how exactly to do this. I tried the following:

TIKA_SERVER_ENDPOINT=http://localhost:9998

But this simply resulted in a 404 , with Network Error (dns_unresolved_hostname), Your host cannot be resolved by the DNS ,

I also ran ps aux | grep java ps aux | grep java to check if the jar file was running and saw that it was running on the port 9998 ..... ie:

java -cp /tmp/tika-server.jar org.apache.tika.server.TikaServerCLi -- port 9998 --host localhost 

What exactly am I doing wrong here with my environment variable? I'm just very new to messing with jar files and environment variables, so any help would be greatly appreciated, thanks!

I had a similar issue and was able to resolve it by simply downloading the latest server jar from the Apache downloads page and then starting the server on my local machine from bash with:

java -jar tika-server -x.x.jar --port xxxx

Which started the tika server. I was then able to access tika in python through:

from tika import parser
parser.from_file('path_to_file')

Maybe java is installed incorrectly. You can check java installation here

Installation (with pip)

pip install tika

Installation (without pip)

python setup.py build
python setup.py install

Environment Variables

These are read once, when tika/tika.py is initially loaded and used throughout after that.

TIKA_VERSION - set to the version string, eg, 1.12 or default to current Tika version. TIKA_SERVER_JAR - set to the full URL to the remote Tika server jar to download and cache. TIKA_SERVER_ENDPOINT - set to the host (local or remote) for the running Tika server jar. TIKA_CLIENT_ONLY - if set to True, then TIKA_SERVER_JAR is ignored, and relies on the value for TIKA_SERVER_ENDPOINT and treats Tika like a REST client. TIKA_TRANSLATOR - set to the fully qualified class name (defaults to Lingo24) for the Tika translator implementation. TIKA_SERVER_CLASSPATH - set to a string (delimited by ':' for each additional path) to prepend to the Tika server jar path. TIKA_LOG_PATH - set to a directory with write permissions and the tika.log and tika-server.log files will be placed in this directory.

More information you can get here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM