1

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
robintux
  • 93
  • 1
  • 9
  • As an IDE I use spyder and as a operating system windows 7 – robintux Dec 24 '19 at 01:41
  • That configuration detail is solved. As the documentation says, create the PYTHONPATH environment variable – robintux Dec 24 '19 at 02:12
  • 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 Dec 24 '19 at 02:14
  • 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 Dec 24 '19 at 02:18
  • 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 Dec 24 '19 at 02:20

2 Answers2

1

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.

Daniel Junglas
  • 5,830
  • 1
  • 5
  • 22
0

Using

pip install docplex

solved my problem.

Dandelion
  • 744
  • 2
  • 13
  • 34