charlesbel/Microsoft-Rewards-Farmer

Getting error on Windows as well as Linux

TheHimanshuRastogi opened this issue · 6 comments

I tried running this script on my Windows computer, but I was getting this error:

Traceback (most recent call last):
  File "C:\Users\<username>\AppData\Local\Programs\Python\Python312\Lib\site-packages\seleniumwire\undetected_chromedriver\webdriver.py", line 6, in <module>    import undetected_chromedriver as uc
  File "C:\Users\<username>\AppData\Local\Programs\Python\Python312\Lib\site-packages\undetected_chromedriver\__init__.py", line 44, in <module>
    from .patcher import IS_POSIX
  File "C:\Users\<username>\AppData\Local\Programs\Python\Python312\Lib\site-packages\undetected_chromedriver\patcher.py", line 4, in <module>
    from distutils.version import LooseVersion
ModuleNotFoundError: No module named 'distutils'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\<username>\Documents\Microsoft-Rewards-Farmer-master\main.py", line 9, in <module>
    from src import Browser, DailySet, Login, MorePromotions, PunchCards, Searches
  File "C:\Users\<username>\Documents\Microsoft-Rewards-Farmer-master\src\__init__.py", line 1, in <module>
    from .browser import Browser
  File "C:\Users\<username>\Documents\Microsoft-Rewards-Farmer-master\src\browser.py", line 9, in <module>
    import seleniumwire.undetected_chromedriver as webdriver
  File "C:\Users\<username>\AppData\Local\Programs\Python\Python312\Lib\site-packages\seleniumwire\undetected_chromedriver\__init__.py", line 1, in <module>
    from .webdriver import Chrome, ChromeOptions
  File "C:\Users\<username>\AppData\Local\Programs\Python\Python312\Lib\site-packages\seleniumwire\undetected_chromedriver\webdriver.py", line 8, in <module>    raise ImportError(
ImportError: undetected_chromedriver not found. Install it with `pip install undetected_chromedriver`.

even I installed, uninstalled undetected-chromedriver multiple times but still I was getting same error so I toaught why not try on another Windows computer, but after trying on another computer I got the following error:

Traceback (most recent call last):
  File "C:\Users\<username>\Documents\Microsoft-Rewards-Farmer\main.py", line 9, in <module>
    from src import Browser, DailySet, Login, MorePromotions, PunchCards, Searches
  File "C:\Users\<username>\Documents\Microsoft-Rewards-Farmer\src\__init__.py", line 1, in <module>
    from .browser import Browser
  File "C:\Users\<username>\Documents\Microsoft-Rewards-Farmer\src\browser.py", line 9, in <module>
    import seleniumwire.undetected_chromedriver as webdriver
  File "C:\Users\<username>\AppData\Local\Programs\Python\Python311\Lib\site-packages\seleniumwire\undetected_chromedriver\__init__.py", line 1, in <module>
    from .webdriver import Chrome, ChromeOptions
  File "C:\Users\<username>\AppData\Local\Programs\Python\Python311\Lib\site-packages\seleniumwire\undetected_chromedriver\webdriver.py", line 14, in <module>
    from seleniumwire.webdriver import DriverCommonMixin
  File "C:\Users\<username>\AppData\Local\Programs\Python\Python311\Lib\site-packages\seleniumwire\webdriver.py", line 28, in <module>
    from seleniumwire import backend, utils
  File "C:\Users\<username>\AppData\Local\Programs\Python\Python311\Lib\site-packages\seleniumwire\backend.py", line 4, in <module>
    from seleniumwire.server import MitmProxy
  File "C:\Users\<username>\AppData\Local\Programs\Python\Python311\Lib\site-packages\seleniumwire\server.py", line 7, in <module>
    from seleniumwire.thirdparty.mitmproxy import addons
  File "C:\Users\<username>\AppData\Local\Programs\Python\Python311\Lib\site-packages\seleniumwire\thirdparty\mitmproxy\addons\__init__.py", line 1, in <module>
    from seleniumwire.thirdparty.mitmproxy.addons import core
  File "C:\Users\<username>\AppData\Local\Programs\Python\Python311\Lib\site-packages\seleniumwire\thirdparty\mitmproxy\addons\core.py", line 5, in <module>
    from seleniumwire.thirdparty.mitmproxy import command, ctx, exceptions, optmanager, platform
  File "C:\Users\<username>\AppData\Local\Programs\Python\Python311\Lib\site-packages\seleniumwire\thirdparty\mitmproxy\ctx.py", line 2, in <module>
    import seleniumwire.thirdparty.mitmproxy.master
  File "C:\Users\<username>\AppData\Local\Programs\Python\Python311\Lib\site-packages\seleniumwire\thirdparty\mitmproxy\master.py", line 7, in <module>
    from seleniumwire.thirdparty.mitmproxy import (
  File "C:\Users\<username>\AppData\Local\Programs\Python\Python311\Lib\site-packages\seleniumwire\thirdparty\mitmproxy\addonmanager.py", line 8, in <module>
    from seleniumwire.thirdparty.mitmproxy import controller, eventsequence, exceptions
  File "C:\Users\<username>\AppData\Local\Programs\Python\Python311\Lib\site-packages\seleniumwire\thirdparty\mitmproxy\eventsequence.py", line 3, in <module>
    from seleniumwire.thirdparty.mitmproxy import controller, http, tcp, websocket
  File "C:\Users\<username>\AppData\Local\Programs\Python\Python311\Lib\site-packages\seleniumwire\thirdparty\mitmproxy\websocket.py", line 5, in <module>
    from wsproto.frame_protocol import CloseReason, Opcode
  File "C:\Users\<username>\AppData\Local\Programs\Python\Python311\Lib\site-packages\wsproto\__init__.py", line 9, in <module>
    from .connection import Connection, ConnectionState, ConnectionType
  File "C:\Users\<username>\AppData\Local\Programs\Python\Python311\Lib\site-packages\wsproto\connection.py", line 23, in <module>
    from .utilities import LocalProtocolError
  File "C:\Users\<username>\AppData\Local\Programs\Python\Python311\Lib\site-packages\wsproto\utilities.py", line 12, in <module>
    from h11._headers import Headers as H11Headers
ImportError: cannot import name 'Headers' from 'h11._headers' (C:\Users\<username>\AppData\Local\Programs\Python\Python311\Lib\site-packages\h11\_headers.py)

After trying on 2 Windoes computers I felt like it's not optimized for Windows so I should try it on Linux, I tried running it on GitHub Codespaces but than I got this error:

Traceback (most recent call last):
  File "/workspaces/Microsoft-Rewards-Farmer/main.py", line 24, in main
    executeBot(currentAccount, notifier, args)
  File "/workspaces/Microsoft-Rewards-Farmer/main.py", line 127, in executeBot
    with Browser(mobile=False, account=currentAccount, args=args) as desktopBrowser:
  File "/workspaces/Microsoft-Rewards-Farmer/src/browser.py", line 41, in __init__
    self.webdriver = self.browserSetup()
  File "/workspaces/Microsoft-Rewards-Farmer/src/browser.py", line 77, in browserSetup
    driver = webdriver.Chrome(
  File "/usr/local/python/3.10.8/lib/python3.10/site-packages/seleniumwire/undetected_chromedriver/webdriver.py", line 61, in __init__
    super().__init__(*args, **kwargs)
  File "/usr/local/python/3.10.8/lib/python3.10/site-packages/undetected_chromedriver/__init__.py", line 372, in __init__
    options.binary_location = (
  File "/usr/local/python/3.10.8/lib/python3.10/site-packages/selenium/webdriver/chromium/options.py", line 52, in binary_location
    raise TypeError(self.BINARY_LOCATION_ERROR)
TypeError: Binary Location Must be a String

Anyone here who would help me why I'm getting errors on Windows as well as Linux? help me please.

I also receive a chrome related error
log.log

To solve on Linux, you just need to install Chrome:
sudo apt install google-chrome-stable (on Debian, Ubuntu, Mint)
Did you tried install modules at "requirements.txt"? If not, use: "pip install -r requirements.txt"
And remember, it's not working on Windows 11, only Windows 10.

Hm it may was broken due to me executing winget upgrade -all which broke many things. Should i try to reinstall chrome?

To solve on Linux, you just need to install Chrome: sudo apt install google-chrome-stable (on Debian, Ubuntu, Mint) Did you tried install modules at "requirements.txt"? If not, use: "pip install -r requirements.txt" And remember, it's not working on Windows 11, only Windows 10.

I also tried on Windows 10 and 11, Anyways, Now I've updated the code for Windows, Now I'm thinking to create a pull in few week.

dudeua commented

I solved this by running:
pip install setuptools

cybx commented

I solved this by running: pip install setuptools

that worked for me too