TLDR:裤子获取 OS X 特定的轮子,因为我正在 Mac 上开发。我怎样才能避免这种情况,或者指定我将部署到 Ubuntu?
全文:
尝试使用 Pants 打包 Python 应用程序。到目前为止一切顺利,但遇到了一个我一直坚持一段时间的问题。我在 macbook 上开发,但部署到 EC2 Ubuntu。
这是我到目前为止所做的:
- 创建了虚拟环境。
- 向应用程序添加了 BUILD 文件,并为第三方包提供了建议的 3rd 方模式。
- Ran
./pants run.py backend:admin_server
运行良好并生成dist/admin_server.pex
- Scp 那个 .pex 到一个新的 EC2 Ubuntu 盒子上。
但是,当我在那里运行应用程序时,我得到:
Failed to execute PEX file, missing compatible dependencies for:
mysql-python
pycrypto
问题似乎是 Pants 为这些 2 采用了 OS X 特定的轮子:
pex:- MySQL_python-1.2.5-cp27-none-macosx_10_11_intel.whl pex:- pycrypto-2.6.1-cp27-none-macosx_10_11_intel.whl
我怎样才能避免这种情况,或者指定它们应该在哪个操作系统上运行?
这是完整的输出:
ubuntu@ip-***:~$ export PEX_VERBOSE=1
ubuntu@ip-***:~$ python admin_server.pex
pex: Found site-library: /usr/local/lib/python2.7/dist-packages
pex: Found site-library: /usr/lib/python2.7/dist-packages
pex: Tainted path element: /usr/local/lib/python2.7/dist-packages
pex: Tainted path element: /usr/lib/python2.7/dist-packages
pex: Scrubbing from site-packages: /usr/local/lib/python2.7/dist-packages
pex: Scrubbing from site-packages: /usr/lib/python2.7/dist-packages
pex: Scrubbing from user site: /home/ubuntu/.local/lib/python2.7/site-packages
pex: Failed to resolve a requirement: MySQL-python==1.2.5
pex: Failed to resolve a requirement: pycrypto==2.6.1
pex: Unresolved requirements:
pex: - mysql-python
pex: - pycrypto
pex: Distributions contained within this pex:
pex: - six-1.10.0-py2.py3-none-any.whl
pex: - protobuf-2.6.1-py2.7.egg
pex: - setuptools-19.5-py2.py3-none-any.whl
pex: - MySQL_python-1.2.5-cp27-none-macosx_10_11_intel.whl
pex: - pycrypto-2.6.1-cp27-none-macosx_10_11_intel.whl
pex: - futures-3.0.4-py2-none-any.whl
pex: - webapp2-2.5.2-py2-none-any.whl
pex: - requests-2.9.0-py2.py3-none-any.whl
pex: - jmespath-0.9.0-py2.py3-none-any.whl
pex: - beautifulsoup4-4.4.1-py2-none-any.whl
pex: - python_dateutil-2.4.2-py2.py3-none-any.whl
pex: - boto3-1.2.3-py2.py3-none-any.whl
pex: - WebOb-1.5.1-py2.py3-none-any.whl
pex: - cssutils-1.0.1-py2-none-any.whl
pex: - webapp2_static-0.1-py2-none-any.whl
pex: - Paste-2.0.2-py2-none-any.whl
pex: - docutils-0.12-py2-none-any.whl
pex: - botocore-1.3.22-py2.py3-none-any.whl
pex: - protobuf_to_dict-0.1.0-py2-none-any.whl
Failed to execute PEX file, missing compatible dependencies for:
mysql-python
pycrypto
PS:为了确保我没有包含我的 python 库版本,我 pip 卸载了 PyCrypto 和 MySQL-Python。