You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

subprocess.py触发FileNotFoundError,求Tor浏览器启动问题解决办法

问题:启动Tor连接脚本时触发FileNotFoundError错误

报错信息

File "C:\Users\A\Documents\dw_pipeline_test\MarketPlaces\Initialization\markets_mining.py", line 79, in <module>
    opentor()
  File "C:\Users\A\Documents\dw_pipeline_test\MarketPlaces\Initialization\markets_mining.py", line 70, in opentor
    pro = subprocess.Popen(config.get('TOR', 'firefox_binary_path'))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\A\Documents\Anaconda\Lib\subprocess.py", line 1026, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\A\Documents\Anaconda\Lib\subprocess.py", line 1538, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [WinError 2] The system cannot find the file specified

Process finished with exit code 1

背景信息

  • 新手,从未使用过firefox_binary或selenium
  • 已检查代码,不确定是否和Anaconda解释器有关
  • 涉及的函数代码:
def opentor():
    global pid
    print("Connecting Tor...")
    pro = subprocess.Popen(config.get('TOR', 'firefox_binary_path'))
    pid = pro.pid
    # time.sleep(7.5)
    input('Press ENTER when Tor is connected to continue')
    return

解决步骤

  • 检查配置文件中的路径正确性
    找到你的配置文件(比如config.ini),查看[TOR]区块下的firefox_binary_path值:

    • 确认路径指向实际存在的浏览器可执行文件,Windows下普通Firefox默认路径是C:\Program Files\Mozilla Firefox\firefox.exe或C:\Program Files (x86)\Mozilla Firefox\firefox.exe
    • 路径中的反斜杠要转义为\\,或者改用正斜杠/,比如C:/Program Files/Mozilla Firefox/firefox.exe
  • 确认Tor浏览器的正确启动路径
    如果你要启动的是Tor Browser而非普通Firefox,路径应该指向Tor自带的firefox程序,默认安装后通常是C:\Users\你的用户名\Desktop\Tor Browser\Browser\firefox.exe(若安装在桌面),找到实际安装目录下的对应路径

  • 验证路径有效性
    打开CMD,把配置文件里的路径用双引号包裹后输入,比如"C:\Program Files\Mozilla Firefox\firefox.exe",能正常启动浏览器说明路径正确,否则调整路径

  • 关于Anaconda的疑问
    这个错误和Anaconda解释器无关,本质是subprocess.Popen找不到你指定的可执行文件,修正路径即可

内容的提问来源于stack exchange,提问作者Ani

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.05 15:53:11