No module named 'dwave.system'; 'dwave' is not a package

Hi, in March I checked a few examples and wrote my own code and there were no problems. Now I returned to study, and the code which I checked and which definitely worked returned an error:

No module named 'dwave.system'; 'dwave' is not a package

the same problem is with any other example. Some ideas? 

 

0

Comments

7 comments
  • Hi Aliaksei,

    I noticed that you were able to successfully submit problems after you posted in the community. Would you mind confirming if you are still having this issue?

    If it is not resolved, can you please confirm if you are using a local Ocean SDK setup? If that is the case, please make sure:

    • You are using Python version 3.7 or higher
    • You have installed Ocean SDK in a virtual environment and it is activated before you run your code.

    If you continue to get the error after you have activated the virtual environment, can you please share the output of pip freeze?

    Lastly, if you were able to fix the issue on your own, we would appreciate if you can share your experience or feedback. It helps the community to learn and enables us to improve user experience.

    0
    Comment actions Permalink
  • Hi, 

    I am having the same problem, and I was wondering if you could help me.

    Importing dimod works but importing dwave or dwave.systems, etc. doesn't work... 

    I am using Python 3.10.14 on MacOS, I have installed OceanSDK in a virtual environment and activated it. 

    I ran dwave config and my configuration file is in /Users/ME/Library/Application Support/dwave/dwave.conf


    When I run pip freeze it returns :

    annotated-types==0.7.0
    Authlib==1.3.1
    blinker==1.8.2
    certifi==2024.6.2
    cffi==1.16.0
    charset-normalizer==3.3.2
    click==8.1.7
    cryptography==42.0.8
    dimod==0.12.15
    diskcache==5.6.3
    dwave-cloud-client==0.12.0
    dwave-greedy==0.3.0
    dwave-hybrid==0.6.11
    dwave-inspector==0.5.0.post0
    dwave-neal==0.6.0
    dwave-ocean-sdk==7.0.0
    dwave-optimization==0.1.0
    dwave-preprocessing==0.6.5
    dwave-samplers==1.2.0
    dwave-system==1.25.0
    dwave-tabu==0.5.0
    dwave_networkx==0.8.15
    dwavebinarycsp==0.3.0
    fasteners==0.19
    Flask==3.0.3
    homebase==1.0.1
    idna==3.7
    importlib_metadata==7.2.1
    itsdangerous==2.2.0
    Jinja2==3.1.4
    MarkupSafe==2.1.5
    minorminer==0.2.14
    networkx==3.3
    numpy==1.26.4
    orjson==3.10.5
    packaging==24.1
    penaltymodel==1.1.0
    plucky==0.4.3
    pycparser==2.22
    pydantic==2.7.4
    pydantic_core==2.18.4
    PySocks==1.7.1
    python-dateutil==2.9.0.post0
    requests==2.32.3
    scipy==1.13.1
    six==1.16.0
    typing_extensions==4.12.2
    urllib3==2.2.2
    Werkzeug==3.0.3
    zipp==3.19.2

    Could you help me on that Tanvi M Tanvi M ? 

    Thanks

    0
    Comment actions Permalink
  • Hello,

    Can you please provide a stack trace of the problem you are seeing and steps to reproduce if possible?

    What does your pip freeze look like when the virtual environment is disabled? 

    Did you follow the steps in the Ocean Getting Started guide under Installing Ocean Tools?

    0
    Comment actions Permalink
  • Hi, 

    Here is my code : 

    import dimod
    from dwave import *
    from dwave.system import *

    Here is the Traceback 

    Traceback (most recent call last):
      File "/Users/me/project/import.py", line 3, in <module>
        from dwave.system import *
    ModuleNotFoundError: No module named 'dwave.system'; 'dwave' is not a package

    Importing dwave and dimod does not yield errors, but accessing dwave.system does. 

    Here is the pip freeze of my global environment : 

    appnope==0.1.4
    asttokens==2.4.1
    comm==0.2.2
    debugpy==1.8.1
    decorator==5.1.1
    dill==0.3.8
    docplex==2.27.239
    exceptiongroup==1.2.1
    executing==2.0.1
    ipykernel==6.29.4
    ipython==8.25.0
    jedi==0.19.1
    jupyter_client==8.6.2
    jupyter_core==5.7.2
    matplotlib-inline==0.1.7
    mpmath==1.3.0
    nest-asyncio==1.6.0
    networkx==3.3
    numpy==1.26.4
    packaging==24.1
    parso==0.8.4
    pbr==6.0.0
    pexpect==4.9.0
    platformdirs==4.2.2
    prompt_toolkit==3.0.47
    psutil==6.0.0
    ptyprocess==0.7.0
    pure-eval==0.2.2
    Pygments==2.18.0
    python-dateutil==2.9.0.post0
    pyzmq==26.0.3
    qiskit-algorithms==0.3.0
    qiskit-optimization==0.6.1
    rustworkx==0.14.2
    scipy==1.13.0
    six==1.16.0
    stack-data==0.6.3
    stevedore==5.2.0
    symengine==0.11.0
    sympy==1.12
    tornado==6.4.1
    traitlets==5.14.3
    typing_extensions==4.11.0
    wcwidth==0.2.13

    I did install Ocean tools, I don't understand, this error, it didn't happen when I was coding on Jupyter. 
    (I am now on VScode) 

    Do you have an idea of what's happening ? 

    Thanks

    0
    Comment actions Permalink
  • Hello,

    It could be that VSCode is not using the virtual environment that you had created and activated.

    This would also mean that any libraries installed would not be accessible to the VSCode environment.

    Are you running the commands within VSCode?
    Did you install the Python extension for VSCode?

    I was able to install and run the D-Wave Ocean Tools in VSCode.
    First I installed the Python extension for Visual Studio Code.
    Then I followed the instructions on this page to create the virtual environment:
    https://code.visualstudio.com/docs/python/environments#_creating-environments

    Though I did use the automatic create environment option, I still needed to run the .\.venv\Scripts\activate command before running pip install dwave-ocean-sdk command.
    Running activate prepends the text "(.venv) " to the command line, indicating that the environment is activated. This is a nice check to see that it is indeed active.

    Once I had activated and installed the D-Wave Ocean Tools, I was able to run python from the same command prompt inside of VSCode and run import dwave with no issues.

    It's hard to tell exactly what is going wrong with your environment, but you might want to try running the following command in command prompt:
    Get-Command python

    This will show you which python is being used. Note that if you are inside of the virtual environment it will point to the associated python executable.

    It might also be easiest to start from the beginning and try to verify each step.

    Please let us know if you are able to make any progress or have any more questions.

     

    0
    Comment actions Permalink
  • I have the same issue. I work with PyCharm, the environment has all necessary packages installed. I have reinstalled my environment at least three times. I can import dwave.cloud and dwave.system in the IDE's terminal but when i run my python script I receive the no ModuleNotFound error. We are already paying for Leap and can't do anything because the packages don't work.

     

    Here is my pip freeze: annotated-types==0.7.0
    asttokens==2.4.1
    Authlib==1.3.1
    blinker==1.8.2
    certifi==2024.7.4
    cffi==1.16.0
    charset-normalizer==3.3.2
    click==8.1.7
    colorama==0.4.6
    comm==0.2.2
    contourpy==1.2.1
    cryptography==42.0.8
    cycler==0.12.1
    debugpy==1.8.2
    decorator==5.1.1
    dimod==0.12.15
    diskcache==5.6.3
    dwave-cloud-client==0.12.0
    dwave-greedy==0.3.0
    dwave-hybrid==0.6.11
    dwave-inspector==0.5.0.post0
    dwave-neal==0.6.0
    dwave-ocean-sdk==7.0.0
    dwave-optimization==0.1.0
    dwave-preprocessing==0.6.5
    dwave-samplers==1.2.0
    dwave-system==1.25.0
    dwave-tabu==0.5.0
    dwave_networkx==0.8.15
    dwavebinarycsp==0.3.0
    executing==2.0.1
    fasteners==0.19
    Flask==3.0.3
    fonttools==4.53.1
    homebase==1.0.1
    idna==3.7
    importlib_metadata==8.0.0
    ipykernel==6.29.5
    ipython==8.26.0
    itsdangerous==2.2.0
    jedi==0.19.1
    Jinja2==3.1.4
    jupyter_client==8.6.2
    jupyter_core==5.7.2
    kiwisolver==1.4.5
    MarkupSafe==2.1.5
    matplotlib==3.9.1
    matplotlib-inline==0.1.7
    minorminer==0.2.14
    nest-asyncio==1.6.0
    networkx==3.3
    numpy==1.26.4
    orjson==3.10.6
    packaging==24.1
    parso==0.8.4
    penaltymodel==1.1.0
    pillow==10.4.0
    platformdirs==4.2.2
    plucky==0.4.3
    prompt_toolkit==3.0.47
    psutil==6.0.0
    pure-eval==0.2.2
    pycparser==2.22
    pydantic==2.8.2
    pydantic_core==2.20.1
    Pygments==2.18.0
    pyparsing==3.1.2
    PySocks==1.7.1
    python-dateutil==2.9.0.post0
    pywin32==306
    pyzmq==26.0.3
    requests==2.32.3
    scipy==1.14.0
    setuptools==69.5.1
    six==1.16.0
    stack-data==0.6.3
    tornado==6.4.1
    traitlets==5.14.3
    typing_extensions==4.12.2
    urllib3==2.2.2
    wcwidth==0.2.13
    Werkzeug==3.0.3
    wheel==0.43.0
    zipp==3.19.2

     

    I have also tried out different python versions. The last time we bought computational time, it worked fine. Please help quickly. These are the imports 

    from dwave.cloud import Client
    from dwave.system import EmbeddingComposite, DWaveSampler
    0
    Comment actions Permalink
  • Hello,

    Were you following the Getting Started guide for D-Wave Ocean Tools?

    In PyCharm, if you go to File > Settings > Project: [project-name] > Python Interpreter, do you see dwave-ocean-tools in the list of Packages in the window?

    If not, you will need to install the D-Wave Ocean Tools here by using the + sign to install packages.

    This is a bit of a tricky feature with PyCharm. Basically, it has its own virtual environment out of the box.

    Alternatively, you might also be able to add the Python interpreter associated with the virtual environment you had previously set up by changing the value of "Python Interpreter:". You might also need to add the interpreter with the "Add Interpreter" option to the right.

    0
    Comment actions Permalink

Please sign in to leave a comment.

Didn't find what you were looking for?

New post