# Momentum trading with snaptrade - can't initialize client

**URL:** <https://forum.freecodecamp.org/t/momentum-trading-with-snaptrade-cant-initialize-client/802410>\
**Category:** General\
**Created:** [October 18, 2026, 6:40pm UTC](https://forum.freecodecamp.org/t/momentum-trading-with-snaptrade-cant-initialize-client/802410 "2026-10-18T18:40:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![TCRemsperger](https://avatars.discourse-cdn.com/v4/letter/t/c68b51/32.png) [@TCRemsperger](https://forum.freecodecamp.org/u/TCRemsperger)\
**Post date:** [October 18, 2026, 6:40pm UTC](https://forum.freecodecamp.org/t/momentum-trading-with-snaptrade-cant-initialize-client/802410/1 "2026-10-18T18:40:57Z")

</div>

I using Python 3.13.5 and have used pip install snaptrade-python-sdk==13.0.39

My error is “SnapTrade is not defined” so I cannot even initialize the snaptrade client

My code:

import os

from SnapTrade import snaptrade\_client

# 1) Initialize a client with your clientID and consumerKey.

snaptrade = SnapTrade(

```
consumer_key=os.environ\["xxxxxxxxxx"\],

client_id=os.environ\["xxxxxxxx"\],

```

)

**Exception has occurred: ModuleNotFoundError**

No module named ‘SnapTrade’

File “C:\_\_\_\_PYTHON\SnapTrade\InitializeClient.py”, line 3, in   
from SnapTrade import snaptrade\_client  
ModuleNotFoundError: No module named ‘SnapTrade’

---

<div class="post-metadata">

**Author:** ![camilaferreira87](https://avatars.discourse-cdn.com/v4/letter/c/b5e925/32.png) [@camilaferreira87](https://forum.freecodecamp.org/u/camilaferreira87)\
**Post date:** [October 19, 2026, 4:23am UTC](https://forum.freecodecamp.org/t/momentum-trading-with-snaptrade-cant-initialize-client/802410/2 "2026-10-19T04:23:52Z")

</div>

The import is reversed. The installed SDK provides the `snaptrade_client` module, which contains the `SnapTrade` class:

```python
import os
from snaptrade_client import SnapTrade

snaptrade = SnapTrade(
    consumer_key=os.environ["SNAPTRADE_CONSUMER_KEY"],
    client_id=os.environ["SNAPTRADE_CLIENT_ID"],
)

```

The strings inside `os.environ[...]` must be environment variable names, not the actual key values.

If `from snaptrade_client import SnapTrade` still fails, check that pip installed the package for the same Python interpreter that runs the script:

```bash
python -m pip show snaptrade-python-sdk
python -c "from snaptrade_client import SnapTrade; print('import ok')"

```

Also make sure the project does not have a local file or folder named `snaptrade_client`, which could shadow the installed package.

---

<div class="post-metadata">

**Author:** ![TCRemsperger](https://avatars.discourse-cdn.com/v4/letter/t/c68b51/32.png) [@TCRemsperger](https://forum.freecodecamp.org/u/TCRemsperger)\
**Post date:** [October 20, 2026, 8:13pm UTC](https://forum.freecodecamp.org/t/momentum-trading-with-snaptrade-cant-initialize-client/802410/3 "2026-10-20T20:13:52Z")

</div>

Camila, Thank you for your response. I have been running this from VSCode (is this the problem?)

I have no file or directory named snaptrade\_client.

after running python -c “from snaptrade\_client import SnapTrade; print(‘import ok’)”

I get

Requires: aiohttp, certifi, cryptography, frozendict, python-dateutil, typing\_extensions, urlib3

Additionally, I understand for security reasons it’s best to use an .env file for my consumer key and client ID. But using actual key values should work, correct? Perhaps I should use a virtual environment and get VSCode to use that? Once I get a connection I’ll make quick progress. Thanks again.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/freecodecamp/original/3X/e/1/e1c433102e34b46dfaa3e15d13ab9a514b127078.svg) [@system](https://forum.freecodecamp.org/u/system)\
**Post date:** [November 17, 2026, 8:14pm UTC](https://forum.freecodecamp.org/t/momentum-trading-with-snaptrade-cant-initialize-client/802410/4 "2026-11-17T20:14:39Z")

</div>

Closed on November 17, 2026, 8:14pm UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
