问题
While running Stem's To Russia With Love example, I got the following error:
'tor' isn't available on your system. Maybe it's not in your PATH
To solve this, I added the following path to tor_cmd as shown in the example over here:
tor_process = stem.process.launch_tor_with_config(
tor_cmd = '~/Downloads/tor-browser_en-US/Browser/TorBrowser/Tor/tor',
config = {
'SocksPort': str(SOCKS_PORT),
'ExitNodes': '{ru}',
},
init_msg_handler = print_bootstrap_lines,
)
However, its now giving me the error:
OSError: '~/Downloads/tor-browser_en-US/Browser/TorBrowser/Tor/tor' doesn't exist
when it clearly does. I am adding the snapshot of the listed files in the folder path:
Could anyone please help me resolve this problem? Thanks.
EDIT: I am using Ubuntu 14.04 on VirtualBox.
回答1:
The ~
character is a Bash shell feature that expands to the value of the environment variable $HOME
. It doesn't work in Python or other programming languages.
Instead, specify the the full path to Tor, or create a link to it somewhere in the $PATH
Python is using in that case.
来源:https://stackoverflow.com/questions/35552724/stem-not-recognizing-tors-path