仅使用python软件包在OpenShift上安装lxml(pip,easy_安装)

仅使用python软件包在OpenShift上安装lxml(pip,easy_安装),pip,openshift,lxml,libxml2,easy-install,Pip,Openshift,Lxml,Libxml2,Easy Install,我在Django应用程序(python 2.7)中使用Beautifulsoup和lxml包。我的生产服务器是OpenShift,因此由于访问权限,我无法使用apt get进行安装。过去我可以使用easy\u install将lxml安装到OpenShift,但现在我很难做到这一点 很可能我缺少一些通过apt get like安装的依赖项? 我试图通过向setup.py文件添加lxml来安装lxml。不起作用。 所以我尝试了pip安装lxml==3: > pip install lxml=

我在Django应用程序(python 2.7)中使用Beautifulsoup和lxml包。我的生产服务器是OpenShift,因此由于访问权限,我无法使用
apt get
进行安装。过去我可以使用
easy\u install
将lxml安装到OpenShift,但现在我很难做到这一点 很可能我缺少一些通过apt get like安装的依赖项?
我试图通过向setup.py文件添加
lxml
来安装lxml。不起作用。
所以我尝试了
pip安装lxml==3

> pip install lxml==3
Downloading/unpacking lxml==3
  Downloading lxml-3.0.tar.gz (3.2MB): 3.2MB downloaded
  Running setup.py egg_info for package lxml
    Building lxml version 3.0.
    Building without Cython.
    Using build configuration of libxslt 1.1.26
    Building against libxml2/libxslt in the following directory: /usr/lib64

    warning: no previously-included files found matching '*.py'
    warning: no files found matching '*.txt' under directory 'src/lxml/tests'
Installing collected packages: lxml
  Running setup.py install for lxml
    Building lxml version 3.0.
    Building without Cython.
    Using build configuration of libxslt 1.1.26
    Building against libxml2/libxslt in the following directory: /usr/lib64
    building 'lxml.etree' extension
    gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/libxml2 -I/var/lib/openshift/569eccb30c1e661fc20000d5/app-root/runtime/dependencies/python/virtenv/build/lxml/src/lxml/includes -I/opt/rh/python27/root/usr/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.linux-x86_64-2.7/src/lxml/lxml.etree.o
    src/lxml/lxml.etree.c: In function ‘__pyx_pf_4lxml_5etree_4XSLT_18__call__’:
    src/lxml/lxml.etree.c:132418: warning: passing argument 1 of ‘__pyx_f_4lxml_5etree_12_XSLTContext__copy’ from incompatible pointer type
    src/lxml/lxml.etree.c:130379: note: expected ‘struct __pyx_obj_4lxml_5etree__XSLTContext *’ but argument is of type ‘struct __pyx_obj_4lxml_5etree__BaseContext *’
    src/lxml/lxml.etree.c: In function ‘__pyx_f_4lxml_5etree__copyXSLT’:
    src/lxml/lxml.etree.c:133807: warning: passing argument 1 of ‘__pyx_f_4lxml_5etree_12_XSLTContext__copy’ from incompatible pointer type
    src/lxml/lxml.etree.c:130379: note: expected ‘struct __pyx_obj_4lxml_5etree__XSLTContext *’ but argument is of type ‘struct __pyx_obj_4lxml_5etree__BaseContext *’
    src/lxml/lxml.etree.c: At top level:
    src/lxml/lxml.etree.c:11938: warning: ‘__pyx_f_4lxml_5etree_displayNode’ defined but not used
Connection to app-nick.rhcloud.com closed by remote host.
Connection to app-nick.rhcloud.com closed.
如果我用pip指定subversion(3.4而不是3),则会有一点不同的输出:

pip install lxml==3.4
Downloading/unpacking lxml==3.4
  Downloading lxml-3.4.0.tar.gz (3.5MB): 3.5MB downloaded
  Running setup.py egg_info for package lxml
    /opt/rh/python27/root/usr/lib64/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url'
      warnings.warn(msg)
    Building lxml version 3.4.0.
    Building without Cython.
    Using build configuration of libxslt 1.1.26
    Building against libxml2/libxslt in the following directory: /usr/lib64

    warning: no previously-included files found matching '*.py'
Installing collected packages: lxml
  Running setup.py install for lxml
    /opt/rh/python27/root/usr/lib64/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url'
      warnings.warn(msg)
    Building lxml version 3.4.0.
    Building without Cython.
    Using build configuration of libxslt 1.1.26
    Building against libxml2/libxslt in the following directory: /usr/lib64
    building 'lxml.etree' extension
    gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/libxml2 -I/var/lib/openshift/569eccb30c1e661fc20000d5/app-root/runtime/dependencies/python/virtenv/build/lxml/src/lxml/includes -I/opt/rh/python27/root/usr/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.linux-x86_64-2.7/src/lxml/lxml.etree.o -w
并且易于安装:

> easy_install lxml
Searching for lxml
Reading https://pypi.python.org/simple/lxml/
Best match: lxml 3.5.0
Downloading https://pypi.python.org/packages/source/l/lxml/lxml-3.5.0.tar.gz#md5=9f0c5f1eb43ff44d5455dab4b4efbe73
Processing lxml-3.5.0.tar.gz
Writing /tmp/easy_install-K7xT2d/lxml-3.5.0/setup.cfg
Running lxml-3.5.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-K7xT2d/lxml-3.5.0/egg-dist-tmp-BAe44x
Building lxml version 3.5.0.
Building without Cython.
Using build configuration of libxslt 1.1.26
Building against libxml2/libxslt in the following directory: /usr/lib64
Connection to app-nick.rhcloud.com closed by remote host.
Connection to app-nick.rhcloud.com closed.
如何通过pip或easy_安装来安装lxml?还是应该使用另一个xml解析器和BeautifulSoup(不确定是否有替代方案)


更新1

我试图安装lxml==3.2.5。我忘了提到我使用的是python 2.7 gear。如果我在我的
setup.py
文件中添加
,'lxml==3.2.5'
(我认为setup.py的工作原理与
requirements.txt
相同),这就是输出:

remote: Searching for lxml==3.2.5
remote: Reading http://mirror1.ops.rhcloud.com/mirror/python/web/simple/lxml/
remote: Best match: lxml 3.2.5
remote: Downloading http://mirror1.ops.rhcloud.com/mirror/python/web/packages/source/l/lxml/lxml-3.2.5.tar.gz#md5=6c4fb9b1840631cff09b8229a12a9ef7
remote: Processing lxml-3.2.5.tar.gz
remote: Writing /tmp/easy_install-jvJHz8/lxml-3.2.5/setup.cfg
remote: Running lxml-3.2.5/setup.py -q bdist_egg --dist-dir /tmp/easy_install-jvJHz8/lxml-3.2.5/egg-dist-tmp-KMpa_f
remote: /opt/rh/python27/root/usr/lib64/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url'
remote:   warnings.warn(msg)
remote: warning: no files found matching '*.txt' under directory 'src/lxml/tests'
remote: src/lxml/lxml.etree.c: In function '__pyx_pf_4lxml_5etree_11TreeBuilder_4data':
remote: src/lxml/lxml.etree.c:97814: warning: passing argument 1 of '__pyx_f_4lxml_5etree_11TreeBuilder__handleSaxData' from incompatible pointer type
remote: src/lxml/lxml.etree.c:97415: note: expected 'struct __pyx_obj_4lxml_5etree_TreeBuilder *' but argument is of type 'struct __pyx_obj_4lxml_5etree__SaxParserTarget *'
remote: src/lxml/lxml.etree.c: In function '__pyx_pf_4lxml_5etree_11TreeBuilder_6start':
remote: src/lxml/lxml.etree.c:97951: warning: passing argument 1 of '__pyx_f_4lxml_5etree_11TreeBuilder__handleSaxStart' from incompatible pointer type
remote: src/lxml/lxml.etree.c:97115: note: expected 'struct __pyx_obj_4lxml_5etree_TreeBuilder *' but argument is of type 'struct __pyx_obj_4lxml_5etree__SaxParserTarget *'
remote: src/lxml/lxml.etree.c: In function '__pyx_pf_4lxml_5etree_11TreeBuilder_8end':
remote: src/lxml/lxml.etree.c:98009: warning: passing argument 1 of '__pyx_f_4lxml_5etree_11TreeBuilder__handleSaxEnd' from incompatible pointer type
remote: src/lxml/lxml.etree.c:97339: note: expected 'struct __pyx_obj_4lxml_5etree_TreeBuilder *' but argument is of type 'struct __pyx_obj_4lxml_5etree__SaxParserTarget *'
remote: src/lxml/lxml.etree.c: In function '__pyx_pf_4lxml_5etree_11TreeBuilder_10pi':
remote: src/lxml/lxml.etree.c:98167: warning: passing argument 1 of '__pyx_f_4lxml_5etree_11TreeBuilder__handleSaxPi' from incompatible pointer type
remote: src/lxml/lxml.etree.c:97455: note: expected 'struct __pyx_obj_4lxml_5etree_TreeBuilder *' but argument is of type 'struct __pyx_obj_4lxml_5etree__SaxParserTarget *'
remote: src/lxml/lxml.etree.c: In function '__pyx_pf_4lxml_5etree_11TreeBuilder_12comment':
remote: src/lxml/lxml.etree.c:98220: warning: passing argument 1 of '__pyx_f_4lxml_5etree_11TreeBuilder__handleSaxComment' from incompatible pointer type
remote: src/lxml/lxml.etree.c:97581: note: expected 'struct __pyx_obj_4lxml_5etree_TreeBuilder *' but argument is of type 'struct __pyx_obj_4lxml_5etree__SaxParserTarget *'
remote: src/lxml/lxml.etree.c: In function '__pyx_f_4lxml_5etree__xslt_resolve_from_python':
remote: src/lxml/lxml.etree.c:136117: warning: enumeration value '__pyx_e_4lxml_5etree_PARSER_DATA_INVALID' not handled in switch
remote: src/lxml/lxml.etree.c: In function '__pyx_pf_4lxml_5etree_4XSLT_18__call__':
remote: src/lxml/lxml.etree.c:140191: warning: passing argument 1 of '__pyx_f_4lxml_5etree_12_XSLTContext__copy' from incompatible pointer type
remote: src/lxml/lxml.etree.c:138126: note: expected 'struct __pyx_obj_4lxml_5etree__XSLTContext *' but argument is of type 'struct __pyx_obj_4lxml_5etree__BaseContext *'
remote: src/lxml/lxml.etree.c: In function '__pyx_f_4lxml_5etree__copyXSLT':
remote: src/lxml/lxml.etree.c:141589: warning: passing argument 1 of '__pyx_f_4lxml_5etree_12_XSLTContext__copy' from incompatible pointer type
remote: src/lxml/lxml.etree.c:138126: note: expected 'struct __pyx_obj_4lxml_5etree__XSLTContext *' but argument is of type 'struct __pyx_obj_4lxml_5etree__BaseContext *'
Connection to app-host.rhcloud.com closed by remote host.
fatal: The remote end hung up unexpectedly
error: error in sideband demultiplexer

更新2 我试图安装Cython(
pip install Cython
),但也失败了->我与OpenShift断开了连接。

我在中创建了错误报告。

奇怪的错误,RedHat的Maciej建议我重新创建Openshift应用程序。它工作正常,我能够成功安装lxml。

对于更新1症状,除了在
requirements.txt
中没有给出版本号,因为它是我正在使用的另一个库的依赖项,这为我修复了它:

  • rhc ssh
    到应用程序
  • 运行
    pip安装lxml
  • 再次运行
    pip安装lxml
  • 在步骤2之后。(第一次
    pip
    run)输出为:

    Downloading/unpacking lxml
    
    pip can't proceed with requirement 'lxml' due to a pre-existing build directory.
     location: /var/lib/openshift/xxx/app-root/runtime/dependencies/python/virtenv/build/lxml
    This is likely due to a previous installation that failed.
    pip is being responsible and not assuming it can delete this.
    Please delete it and try again.
    
    Cleaning up...
    
    第二次
    pip
    运行成功完成,不需要删除建议的目录
    pip
    (也不存在)


    pip
    正在使用
    lxml
    3.6.0版-python2.7作为盒式磁带。

    您是否尝试在
    requirements.txt
    中添加
    lxml
    并按下?对于我来说,使用Python3.3盒带安装lxml 3.4.4似乎还不错。我在安装lxml时,在setup.py文件“lxml==3.2.5”中为我的Python3.3盒带设置了“requires”字段。大约一年前,Openshift a中出现了一个只适用于3.2.5版的bug。从前面的海报上看,他们似乎已经修复了它。嗯,我正在运行python 2.7。我将尝试安装您的版本。Thanks@fatfantasma我添加了尝试安装lxml版本3.2.5的输出。可能是python 2.7的问题。我在所有使用python 3.3的Openshift应用程序中使用lxml和beautifulsoup