0
votes

I have the following problem after having installed matplotlib and seaborn :

from docplex.mp.model import Model
Traceback (most recent call last):

  File "<ipython-input-1-ee0d9503867b>", line 1, in <module>
    from docplex.mp.model import Model

ModuleNotFoundError: No module named 'docplex'

my environment has installed docplex and docloud ,but I only use the local version.Conda list output:

enter image description here

The programs that I install:

  1. cplex_studio1210.win-x86-64
  2. Anaconda3-2019.10-Windows-x86_64

and my environment :

conda create --name PythonOPT1 python=3.7
1
As an IDE I use spyder and as a operating system windows 7 - robintux
That configuration detail is solved. As the documentation says, create the PYTHONPATH environment variable - robintux
Then present more details. Is the error observed through spyder or skipping spyder and run something from the conda shell? What happens if you run one of the cplex low-level API examples without docplex? - sascha
Do you mean run one of the examples using CPLEX Studio? . There everything works without problem. I think my problem is a matter of module versions. - robintux
What does there mean? In the windows-console? The conda-shell? From Spyder? It's hard to read out details here. I would not be surprised to see that this is another spyder is misconfigured thing which i observe all the time here (and i see no reason why some versioning should be the problem). As a non-spyder user, i don't know what it does with your OS-environment-variables (which seems to be your way of installing cplex; i prefer the other one from the docs). - sascha

1 Answers

0
votes

This error usually occurs when the PYTHONPATH environment variable is not set correctly. To debug this add this code before trying to import anything from docplex:

import os
print('PYTHONPATH="%s"' % os.environ['PYHTHONPATH'])

Then double check that the printed value contains the folder that contains the docplex and docloud installation.

Note that the installation usually sets up the PYTHONPATH correctly, but there may be some programs (like certain spyder instances) that may still miss this setting.