本文介绍了ImportError:Linux上没有名为“ cplex” Python的模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在HPC计算机(RedHatEntrepriseServer)上运行python脚本。管理员已经安装了CPLEX模块,但是在python中导入cplex模块时仍然出现此错误。

I am trying to run python scripts on a HPC machine (RedHatEntrepriseServer). CPLEX module is already installed by adminastrators but I still have this error in importing cplex module in python.

ImportError:没有名为 cplex的模块

我知道这是常见错误,我发现可能需要使用cplex主目录更新PYTHONPATH变量,但找不到该主目录。有人有解决这个问题的想法或建议吗?!

I know it is common error and I found that I may need to update PYTHONPATH variable with cplex home directory, but I can't find this home directory. Does anyone have an idea or suggestion to solve this problem?!

非常感谢!

推荐答案

感谢skr和danche注释,这是我解决问题的方法:

Thanks to skr and danche comments, here is how I solved the problem:

我通过使用以下命令查找了cplex位置:

I looked for cplex location by using this command:

find / -iname "cplex"

然后我在以下位置更新了 PYTHONPATH 变量:

Then I updated the PYTHONPATH variable with this location:

export PYTHONPATH=$PYTHONPATH:/local/software/cplex/12.6.1/cplex/python/2.6/x86-64_linux

我使用上一条命令更新了 .bashrc 文件,因此每次登录时都会自动对其进行设置。

I updated my .bashrc file with last command so each time I log in it is set automatically.

这篇关于ImportError:Linux上没有名为“ cplex” Python的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 16:18