简体   繁体   English

如何在Linux Ubuntu 10.04上为Python安装lpsolve模块?

[英]how to install lpsolve module for Python on Linux Ubuntu 10.04?

I am using Ubuntu 12.04 64-bit, and started learning python today.(I tried to install a pirate version of MATLAB but failed...) I have a linear programming problem to solve, and I want to use lp_solve module for Python. 我正在使用64位Ubuntu 12.04,今天开始学习python。(我试图安装盗版的MATLAB,但失败了...)我有一个线性编程问题要解决,我想将lp_solve模块用于Python。 I tried for 1~2 hours to find the download file and install the module. 我尝试了1到2个小时来找到下载文件并安装模块。

I am not sure if I downloaded a right thing, and I could not install it until now. 我不确定是否下载了正确的东西,并且直到现在我都无法安装。

How can I install this? 我该如何安装? There is no download link in http://lpsolve.sourceforge.net/ , and it tells me to run a command http://lpsolve.sourceforge.net/中没有下载链接,它告诉我运行命令

python setup.py install python setup.py安装

but there is no setup.py file in anywhere, including the lpsolve source file I downloaded somewhere. 但是任何地方都没有setup.py文件,包括我从某处下载的lpsolve源文件。

If you know where to download it, and install it, could you teach me how to do them, step by step? 如果您知道从何处下载和安装它,可以一步一步教我如何做吗?

I am not sure about the version of my Python. 我不确定我的Python版本。

Thank you. 谢谢。

Adding few more details to the answer provided by dnozay. 向dnozay提供的答案添加更多细节。

Download the following two files from http://sourceforge.net/projects/lpsolve/files/lpsolve/ http://sourceforge.net/projects/lpsolve/files/lpsolve/下载以下两个文件

  • lp_solve_5.5.2.0_dev_ux64.tar.gz - contains the .so files lp_solve_5.5.2.0_dev_ux64.tar.gz包含.so文件
  • lp_solve_5.5.2.0_Python2.5_exe_ux64.tar.gz - contains the python wrapper scripts for lpsolver, which helps to invoke the native library from .so files. lp_solve_5.5.2.0_Python2.5_exe_ux64.tar.gz包含lp_solve_5.5.2.0_Python2.5_exe_ux64.tar.gz的python包装器脚本,该脚本有助于从.so文件调用本机库。

Unzip the above downloaded files, where each directory formed by unzip will have an lpsolve55.so file, though at different locations. 解压缩上面下载的文件,尽管通过解压缩形成的每个目录在不同的位置,但都有一个lpsolve55.so文件。

Specify the paths to lpsolve55.so file in each directory by setting the following two environment variables: 通过设置以下两个环境变量,在每个目录中指定lpsolve55.so文件的路径:

  • export LD_LIBRARY_PATH=/usr/local/lib:/home/xxx/lp_solve_dev/
  • export PYTHONPATH=/home/xxx/usr/lib/python2.5/site-packages

To test if lpsolver is configured as expected : 要测试lpso​​lver是否按预期配置:

[xx-xxxx@ip-xx-x-x-xx ~]$ python
>>>Python 2.7.9 (default, Apr  1 2015, 18:18:03)
[GCC 4.8.2 20140120 (Red Hat 4.8.2-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>from lpsolve55 import *
>>>lpsolve()
lpsolve  Python Interface version 5.5.0.9
using lpsolve version 5.5.2.0
Usage: ret = lpsolve('functionname', arg1, arg2, ...)

PS: make sure you have installed python-dev (if not, type sudo apt-get install python-dev at the command line) before you do this all. PS:在执行所有操作之前,请确保已安装python-dev(如果未sudo apt-get install python-dev ,请在命令行中键入sudo apt-get install python-dev )。

The download link is: 下载链接是:

Once you have it installed, you may need to tweak your PYTHONPATH . 安装后,您可能需要调整PYTHONPATH

You also may want to look into cvexp : 您可能还需要研究cvexp

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

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