python - 安装 OR-tools 时没有版本属性

标签 python ubuntu or-tools

我正在尝试在 Linux for Python 上安装 OR-tools,这是 Google 的一个优化库。
https://developers.google.com/optimization/introduction/installing.html#unix_binary

我正在使用新下载的虚拟机(操作系统盒中的 Ubuntu 16.10 Yakkety Yak),所以我怀疑我的系统是否存在问题(除非我还没有安装我需要的东西)。

我也怀疑 OR-tools 是问题所在。除了:

sudo apt-get install python-setuptools
sudo apt-get install g++
下载的 Python—tar.gz,在 Downloads 中提取
进入下载后运行“make install”

我收到错误消息“您正在使用没有版本属性的 ortools 模块”。有谁知道这可能意味着什么?

我已经尝试了命令提示符建议的两个技巧:

运行/usr/bin/python setup.py install --user 工作,但错误“警告:install_lib:'build/lib.linux-x86_64-2.7'不存在 - 没有要安装的 Python 模块”弹出。

删除 init.pyc 文件告诉我删除 init.py 文件,然后它说 or-tools 没有找到。

非常感谢任何帮助,仍在学习 Linux,所以我确定我在做一些愚蠢的事情......

make install 的完整输出:

python setup.py install --user
running install
running bdist_egg
running egg_info
writing requirements to ortools_examples.egg-info/requires.txt
writing ortools_examples.egg-info/PKG-INFO
writing top-level names to ortools_examples.egg-info/top_level.txt
writing dependency_links to ortools_examples.egg-info/dependency_links.txt
reading manifest file 'ortools_examples.egg-info/SOURCES.txt'
writing manifest file 'ortools_examples.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
warning: install_lib: 'build/lib.linux-x86_64-2.7' does not exist -- no            Python modules to install
creating build/bdist.linux-x86_64/egg
creating build/bdist.linux-x86_64/egg/EGG-INFO
copying ortools_examples.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying ortools_examples.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying ortools_examples.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying ortools_examples.egg-info/requires.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying ortools_examples.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
zip_safe flag not set; analyzing archive contents...
creating 'dist/ortools_examples-6.0.4217-py2.7.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing ortools_examples-6.0.4217-py2.7.egg
Removing /home/osboxes/.local/lib/python2.7/site-packages/ortools_examples-6.0.4217-py2.7.egg
Copying ortools_examples-6.0.4217-py2.7.egg to /home/osboxes/.local/lib/python2.7/site-packages
ortools-examples 6.0.4217 is already the active version in easy-install.pth
Installed /home/osboxes/.local/lib/python2.7/site-packages/ortools_examples-6.0.4217-py2.7.egg
Processing dependencies for ortools-examples==6.0.4217
Searching for ortools==6.0.4217
Best match: ortools 6.0.4217
Processing ortools-6.0.4217-py2.7-linux-x86_64.egg
ortools 6.0.4217 is already the active version in easy-install.pth
Using /home/osboxes/.local/lib/python2.7/site-packages/ortools-6.0.4217-py2.7-linux-x86_64.egg
Searching for protobuf==3.2.0
Best match: protobuf 3.2.0
Processing protobuf-3.2.0-py2.7.egg
protobuf 3.2.0 is already the active version in easy-install.pth
Using /home/osboxes/.local/lib/python2.7/site-packages/protobuf-3.2.0-py2.7.egg
Searching for setuptools==26.1.1
Best match: setuptools 26.1.1
Adding setuptools 26.1.1 to easy-install.pth file
Installing easy_install script to /home/osboxes/.local/bin
Using /usr/lib/python2.7/dist-packages
Searching for six==1.10.0
Best match: six 1.10.0
Processing six-1.10.0-py2.7.egg
six 1.10.0 is already the active version in easy-install.pth
Using /home/osboxes/.local/lib/python2.7/site-packages/six-1.10.0-py2.7.egg
Finished processing dependencies for ortools-examples==6.0.4217
python check_python_deps.py --log=ERROR
[ERROR] You are using a ortools module that doesn't have a version attribute : /home/osboxes/.local/lib/python2.7/site-packages/ortools-6.0.4217-py2.7-linux-x86_64.egg/ortools/init.pyc"
Run "/usr/bin/python setup.py install --user" to upgrade.
If the problem persists, remove the site-package that contains "/home/osboxes/.local/lib/python2.7/site-packages/ortools-6.0.4217-py2.7-linux-x86_64.egg/ortools/init.pyc". You can do so either manually or by using pip.

最佳答案

troubleshooting page of the Google or-tools project ,详细说明此错误:

This occurs when you try to install a binary distribution, but the installer is unable to build the ortools package for your operating system. In this case, you can still install and run OR-Tools from source files, and even build the python package yourself. You can do so, by following these steps:

  • Install and compile OR-Tools as described in Linux/Mac OS X source installation or Windows source installation.
  • Don't forget to make sure that everything is working fine by running make test.
  • Run make pypi_archive. You will find the package under a directory called temp.


就我个人而言,从我的 Ubuntu 16.04 VM 上的源文件构建也不起作用(可能是由于虚拟化引起的一些错误)。

但是,我发现 this Python .egg file on PyPi用于 Ubuntu 16.04 上的 or-tools,使用 easy_install <filename>.egg 安装相当容易(确保首先使用 pip install setuptools 下载 Python setuptools)。

他们有these easy to install versions available for other versions of Ubuntu比你的,比如 16.04 和 17.04。如果您即将升级,您可能想尝试其中之一。否则,您可以尝试easy_install一个与操作系统无关的版本 .egg 文件。

关于python - 安装 OR-tools 时没有版本属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44108204/

相关文章:

python - ORtools 安排学生上课时间冲突

optimization - CP-Sat 中 NumConflicts 的确切含义是什么?

java - 使用 OR-Tools 表达多变量约束

python -/etc/init.d sh 脚本

python - xlsxwriter-将列表写入列

python - 使用和不使用 GPU 编程的语法差异?

python - 为什么这些列表相同?

macos - nodejs 密码 ubuntu 没有按预期工作

ubuntu - Ubuntu 中的 Android Studio 透明度错误

mysql - mysql用户密码错误