blackducksoftware / hub-rest-api-python

HUB REST API Python bindings
Apache License 2.0
89 stars 104 forks source link

Client class not found #202

Closed psp300xxx closed 2 years ago

psp300xxx commented 2 years ago

Hi, as the guide state, I installed blackduck using the command pip3 install blackduck, and everything looked fine, but when I run the test code I receive the following message: ImportError: cannot import name 'Client' from partially initialized module 'blackduck' (most likely due to a circular import) (C:\Users\luigi.demarco\blackduck_examples\blackduck.py), do you have any solution? I am running under Windows 10

gsnyder2007 commented 2 years ago

Hi,

I did a quick test to see if I could reproduce the issue you are reporting,

  1. Created a new python virtualenv using pyenv and python 3.9.1
  2. Installed the blackduck PyPi library using "pip3 install blackduck"
  3. Ran the example script .../examples/client/generate_notices_report_for_project_version.py and it worked.

I happen to be on a Mac running Big Sur but that shouldn't matter cause it's python! :-)

So, I'm not able to reproduce the issue.

Could you supply more details regarding what you ran? and how you ran it?

psp300xxx commented 2 years ago

Hi, thank you for your answer. I created a virtual env, there I ran : python -m pip install blackduck (my python version is 3.9.8) Then I ran the following script:

from blackduck import Client
import logging
import os
from pprint import pprint

logging.basicConfig(
    level=logging.INFO,
    format="[%(asctime)s] {%(module)s:%(lineno)d} %(levelname)s - %(message)s"
)

bd = Client(
    token=os.environ.get('blackduck_token'),
    base_url="https://your.blackduck.url",
    # verify=False  # TLS certificate verification
)

Getting the error I mentioned

skiyooka commented 2 years ago

Try renaming your script from blackduck.py to something else. Having a script with the same name as a package you are trying to import may cause a problem.

psp300xxx commented 2 years ago

Thank you, renaming the script solved my issue!

skiyooka commented 2 years ago

Super! Good luck with the Client class.