offish / tf2-express

Automated TF2 trading bot with automatic pricing and GUI
MIT License
45 stars 6 forks source link

websocket.sync #26

Closed noah-xo closed 1 month ago

noah-xo commented 1 month ago

Hey! I installed and updated everything.

When I try to run the bot I get the following error:

Python\Python312\Lib\site-packages\tf2_utils\sockets.py", line 6, in <module>
    from websocket.sync.client import ClientConnection, connect
ModuleNotFoundError: No module named 'websocket.sync'

Both for main.pyand panel.py

BenKGIT commented 1 month ago

First make sure websockets is installed:

$ pip install websockets

And then I believe it's a typo and should say websockets.sync The original source file is clean though. If these errors occur more often consider a fresh setup of the repo.

offish commented 1 month ago

I also believe this to be a typo on your end as tf2-utils never mentions websocket.sync, but websockets.sync instead as @BenKGIT mentions. tf2-utils requires websockets-client, you can try to install this using

pip install websockets-client

Make sure you have the latest version of tf2-express (v2.1.0) and you can also upgrade the dependencies to be sure you are running the latest version.

pip install --upgrade tf2-utils tf2-sku tf2-data
noah-xo commented 1 month ago

Thank you. Installing websockets helped the bot progess further. I did still, however run into issues.

Things that I did in order: Clean install of Python 3.12.4 Clean install of MongoDB Installed tf2-express Updated all tf2-express requirements Installed websockets

Upon running the tf2-express test, I got the following log:

C:\Users\x\Desktop\tf2-express>python -m unittest

EEEWARNING:root:Deal 978;6 already exists in the database
WARNING:root:978;6 not found in database, returning empty dict
....FF
======================================================================
ERROR: test_default_config (tests.test_config.TestDefaultConfig.test_default_config)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\x\Desktop\tf2-express\tests\test_config.py", line 22, in test_default_config
    config = read_json_file("./express/config.example.json")
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\x\Desktop\tf2-express\express\utils.py", line 32, in read_json_file
    with open(filename, "r") as f:
         ^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: './express/config.example.json'

======================================================================
ERROR: test_default_global_config (tests.test_config.TestDefaultConfig.test_default_global_config)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\x\Desktop\tf2-express\tests\test_config.py", line 9, in test_default_global_config
    config = read_json_file("./express/config.example.json")
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\x\Desktop\tf2-express\express\utils.py", line 32, in read_json_file
    with open(filename, "r") as f:
         ^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: './express/config.example.json'

======================================================================
ERROR: test_database (tests.test_database.TestDatabase.test_database)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\x\Desktop\tf2-express\tests\test_database.py", line 10, in test_database
    config = get_config()
             ^^^^^^^^^^^^
  File "C:\Users\x\Desktop\tf2-express\express\utils.py", line 39, in get_config
    return read_json_file("./express/config.json")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\x\Desktop\tf2-express\express\utils.py", line 33, in read_json_file
    content = json.loads(f.read())
              ^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Python312\Lib\json\__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Python312\Lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Python312\Lib\json\decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 35 column 17 (char 1205)

======================================================================
FAIL: test_sku_to_item_data (tests.test_utils.TestUtils.test_sku_to_item_data)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\x\Desktop\tf2-express\tests\test_utils.py", line 14, in test_sku_to_item_data
    self.assertEqual(
AssertionError: {'sku': '30469;1', 'name': 'Genuine Horace'[124 chars]455'} != {'color': '4D7455', 'image': 'http://media.[116 chars]9;1'}
  {'color': '4D7455',
   'image': 'http://media.steampowered.com/apps/440/icons/horace.1fa7eb3b1b04da8888d5ee3979916d96d851a53e.png',
-  'name': 'Genuine Horace',
?           --------

+  'name': 'Horace',
   'sku': '30469;1'}

======================================================================
FAIL: test_version (tests.test_utils.TestUtils.test_version)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\x\Desktop\tf2-express\tests\test_utils.py", line 43, in test_version
    self.assertNotEqual(version, __version__)
AssertionError: '2.1.0' == '2.1.0'

----------------------------------------------------------------------
Ran 9 tests in 0.392s

FAILED (failures=2, errors=3)
offish commented 1 month ago

You need to rename the config.example.json to just config.json. You're not supposed to run the tests if you're not developing and changing the source code. Running main.py is a better test to see if everything is working as expected.