Python 'hubspot' is not a package

Hi all, I have been banging my head against the wall for a while on this one. I had several Python scripts utilizing the HubSpot API that were working fine for me, but upon re-visiting them and writing a new one, I keep running into this error:

ModuleNotFoundError: No module named ‘hubspot.crm’; ‘hubspot’ is not a package

Here is my code (super basic script to try and get this working):

import hubspot

from pprint import pprint

from hubspot.crm.contacts import ApiException

client = hubspot.Client.create(access_token=“YOUR_ACCESS_TOKEN”)

try:

api_response = client.crm.contacts.basic_api.get_page(limit=10, archived=False)

pprint(api_response)

except ApiException as e:

print(“Exception when calling basic_api->get_page: %s\n” % e)

Hi, @HHawley :waving_hand: Welcome to the community! Hey, @taran42 @MichaelC @albertsg, can you lend a hand here? Or do you have thoughts on how @HHawley can troubleshoot here?

Thank you! — Jaycee

It does not make sense.

The current version of hubspot-api-client exists in the .venv directory.

I have this import in for the class HubSpotContactRepos:

from hubspot.crm.contacts import SimplePublicObjectInputForCreate

The import of the class is

from shared_hubspot.lib.repos.hubspot_contact_repos import HubSpotContactRepos

When I import the class in a pytest script, it works. Whem I put a python script in the same folder, it doesn’t. In addition, I get this missleading error message when import hubspot faills indirectly by importing HubSpotContactRepos:

ImportError: cannot import name 'HubSpotContactRepos' from partially initialized module 'shared_hubspot.lib.repos.hubspot_contact_repos' (most likely due to a circular import) (C:\path\to\shared_hubspot\lib\repos\hubspot_contact_repos.py)

It was a name conflict in my case. I named the script hubspot.py. After renaming the file, it worked.

@HHawley I would maybe say, since you rebuilt the script, to double check that the module is installed and in the correct directory. Also try updating Python. There are multiple version of the API, so it may be conflicting with your current version.