Search code examples
pythonpython-3.xtorsystem-paths

TOR with python stem (basic) - 'tor' not in PATH


I'm trying to get an .onion website's content to python, a little research showed that 'stem' and as i am running this tutorial script, or more specifically, when i'm trying to use stem.process.launch_tor_with_config, i get this error:

'tor' isn't available on your system. Maybe it's not in your PATH?

I supposed to have some sort of tor process installed, I got the tor browser bundle and put the /Tor library (with the tor.exe) in it in my path, and it's not helping... Obviously I'm missing something VERY BASIC, please advise....

Many thanks...


Solution

  • I had the same issue on my Mac. Try specifying exactly where the tor file is located to the tor_cmd parameter:

    tor_process = stem.process.launch_tor_with_config(
        tor_cmd = '/Applications/TorBrowser.app/Tor/tor.real',
        config = { SocksPort': str(SOCKS_PORT),
                   'ExitNodes': '{ru}',},
        init_msg_handler = print_bootstrap_lines,
    )