<p>正如另一个答案中建议的那样,您可以使用<code>PYTHONPATH</code>环境变量。另一种选择是在免费“社区版”的顶部安装学术版的<code>cplex</code>包<em>。这对您的系统Python或virtualenv都是有效的。例如,可以执行以下操作:</p>
<pre><code>$ cd <COSDIR>/cplex/python/2.7/<platform>/
$ pip install .
Processing /home/rkersh/opt/CPLEX_Studio128/cplex/python/2.7/x86-64_linux
Building wheels for collected packages: cplex
Running setup.py bdist_wheel for cplex ... done
Stored in directory: /home/rkersh/.cache/pip/wheels/88/19/c6/6545d3d5ac65b18b796b44986272e17f3a8429df7b12472624
Successfully built cplex
Installing collected packages: cplex
Found existing installation: cplex 12.8.0.1
Uninstalling cplex-12.8.0.1:
Successfully uninstalled cplex-12.8.0.1
Successfully installed cplex-12.8.0.0
</code></pre>
<p>对于第一个命令,<code>COSDIR</code>是安装CPLEX Optimization Studio的位置,<code>platform</code>类似于<code>x86-64_linux</code>,<code>x64_win64</code>,<code>x86-64_osx</code>等等。在上面的示例中,您可以看到<code>COSDIR</code>是{<cd9>},而{<cd4>}是{<cd5>}。完成此操作后,不应再获得<a href="https://www.ibm.com/support/knowledgecenter/SSSA5P_12.8.0/ilog.odms.cplex.help/refcallablelibrary/macros/CPXERR_RESTRICTED_VERSION.html" rel="nofollow noreferrer">CPXERR_RESTRICTED_VERSION</a>。在</p>