简体   繁体   English

如何在Windows上将CPLEX与PYTHON一起使用

[英]How to use CPLEX with PYTHON on windows

Though I've already install Cplex, and could import cplex in Jupyter Notebook. 虽然我已经安装了Cplex,并且可以在Jupyter Notebook中导入cplex。

When I use "cplex.infinity", error arises and it says "module 'cplex' has no attribute 'infinity'" 当我使用“ cplex.infinity”时,会出现错误,并说“模块'cplex'没有属性'infinity'”

I don't know the reason, hoping you could help me. 我不知道原因,希望您能帮助我。

This is because virtual environments in Jupyter are different.If you don't tell your Jupiter kernel which environment it should use it won't use your environment from python terminal (even launching the jupyter notebook command with this virtual environment activated). 这是因为Jupyter中的虚拟环境不同。如果您不告诉Jupiter内核它应该使用哪个环境,则不会在python终端上使用您的环境(即使在激活此虚拟环境的情况下启动jupyter notebook命令)。

You can follow this guide . 您可以按照本指南进行操作

Basically: 基本上:

  1. You have to install your virtual environment for Jupyter 您必须为Jupyter安装虚拟环境
  2. You have to tell the kernel to use this environment in the top bar of your notebook 您必须在笔记本顶部栏中告诉内核使用此环境。

You will have then all the dependencies installed in your virtual environment available from Jupyter. 然后,您将可以从Jupyter获得虚拟环境中安装的所有依赖项。

Cheers! 干杯!

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

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