0

我正在尝试在 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,在下载中解压
cd 到下载后运行“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.
4

1 回答 1

1

请参阅Google or-tools 项目的故障排除页面,其中详细说明了此错误:

当您尝试安装二进制发行版,但安装程序无法为您的操作系统构建 ortools 包时,会发生这种情况。在这种情况下,您仍然可以从源文件安装和运行 OR-Tools,甚至可以自己构建 python 包。您可以按照以下步骤执行此操作:

  • 按照 Linux/Mac OS X 源代码安装或 Windows 源代码安装中的说明安装和编译 OR-Tools。
  • 不要忘记通过运行 make test 来确保一切正常。
  • 运行 make pypi_archive。您将在名为 temp 的目录下找到该软件包。

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

但是,我在 PyPi 上找到了这个 Python .egg 文件,用于 Ubuntu 16.04 上的 or-tools,它很容易安装easy_install <filename>.egg(确保先用 下载 Python setuptools pip install setuptools)。

他们有这些易于安装的版本,可用于您的其他版本的 Ubuntu,例如 16.04 和 17.04。如果您即将升级,您可能想尝试其中之一。否则,您可以尝试使用easy_install与操作系统无关的版本 .egg 文件。

于 2017-09-01T22:46:05.963 回答