简体   繁体   English

如何为 Python 安装 CPLEX 以便我可以通过 Jupyter 访问它?

[英]How can I install CPLEX for Python so I can access it via Jupyter?

I have already downloaded the CPLEX Studio.我已经下载了 CPLEX Studio。 I am an absolute command prompt beginner, so following IBM's tutorials to install the API is proving to be very difficult.我是一个绝对的命令提示符初学者,因此按照 IBM 的教程安装 API 被证明是非常困难的。 I want to get to the point where I can import cplex in Jupyter.我想达到可以在 Jupyter 中导入 cplex 的地步。 I have reviewed other similar questions, but those answers are difficult to understand (for me).我已经回顾了其他类似的问题,但这些答案很难理解(对我来说)。 Is anyone able to explicitly explain how to do this in layman's terms?有没有人能够用外行的术语明确解释如何做到这一点?

If you can provide your OS, CPLEX version, python version and how you run jupyter, I can provide you the exact commands to run.如果您可以提供您的操作系统、CPLEX 版本、python 版本以及您如何运行 jupyter,我可以为您提供要运行的确切命令。

You basically want to have a command prompt setup with the same python interpreter you use for jupyter.您基本上希望使用用于 jupyter 的相同 python 解释器设置命令提示符。 Assuming CPLEX 12.10, you want to假设 CPLEX 12.10,您想要

$ cd $CPLEX_STUDIO_DIR1210/python/VERSION/PLATFORM
$ python setup.py install

(where VERSION is your python version, likely 3.6 or 3.7, PLATFORM is your OS platform) (其中 VERSION 是您的 Python 版本,可能是 3.6 或 3.7,PLATFORM 是您的操作系统平台)

For reference the doc is here: https://www.ibm.com/support/knowledgecenter/SSSA5P_12.10.0/ilog.odms.cplex.help/CPLEX/GettingStarted/topics/set_up/Python_setup.html参考文档在这里: https : //www.ibm.com/support/knowledgecenter/SSSA5P_12.10.0/ilog.odms.cplex.help/CPLEX/GettingStarted/topics/set_up/Python_setup.html

You can do the installation from a jupyter notebook.您可以从 jupyter notebook 进行安装。 Just create a new notebook, then:只需创建一个新笔记本,然后:

If you are using the Community Edition, just create a cell with:如果您使用的是社区版,只需创建一个单元格:

!pip install cplex

If you want to use an edition already downloaded on your disk, create a cell with:如果要使用磁盘上已下载的版本,请使用以下命令创建单元:

%cd "C:\Program Files\IBM\ILOG\CPLEX_Studio1210\cplex\python\3.7\x64_win64"
!pip install .

You need to do this only once.您只需执行此操作一次。 After pip finishes, you just need to restart your jupyter. pip 完成后,您只需要重新启动 jupyter。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM