Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Cloud foundry &引用;致命错误:sql.h";使用unixODBC和pyodbc作为供应商应用程序依赖项_Cloud Foundry - Fatal编程技术网

Cloud foundry &引用;致命错误:sql.h";使用unixODBC和pyodbc作为供应商应用程序依赖项

Cloud foundry &引用;致命错误:sql.h";使用unixODBC和pyodbc作为供应商应用程序依赖项,cloud-foundry,Cloud Foundry,我正试图将unixODBC添加为供应商应用程序依赖项,如下所述:,但仍然出现致命错误: h:没有这样的文件或目录 我在下面创建了一个最小的、可验证的完整脚本,以方便读者复制我的问题: mkdir new_app cd new_app cat <<EOF>requirements.txt pyodbc==4.0.17 EOF cat <<EOF>manifest.yml applications: - name: pyodbc-test memory

我正试图将unixODBC添加为供应商应用程序依赖项,如下所述:,但仍然出现致命错误:

h:没有这样的文件或目录

我在下面创建了一个最小的、可验证的完整脚本,以方便读者复制我的问题:

mkdir new_app
cd new_app

cat <<EOF>requirements.txt
pyodbc==4.0.17
EOF

cat <<EOF>manifest.yml
applications:
 - name: pyodbc-test
   memory: 128M
EOF

cat <<EOF>.profile
export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:/app/vendor/unixodbc/lib
EOF

sudo docker run -it --rm -v ${PWD}:/app cloudfoundry/cflinuxfs2 bash -c \
   "wget ftp://ftp.unixodbc.org/pub/unixODBC/unixODBC-2.3.4.tar.gz;  tar xzf unixODBC-2.3.4.tar.gz; cd unixODBC-2.3.4;  ./configure --prefix=/app/vendor/unixodbc; make; make install;"
cf推送输出:

...
-------> Buildpack version 1.5.15
 !     Warning: Your application is missing a Procfile. This file tells Cloud Foundry how to run your application.
 !     Learn more: https://docs.cloudfoundry.org/buildpacks/prod-server.html#procfile
-----> Installing python-2.7.13
Downloaded [file:///tmp/buildpack/dependencies/https___buildpacks.cloudfoundry.org_dependencies_python_python-2.7.13-linux-x64.tgz]
     $ pip install -r requirements.txt
       Collecting pyodbc==4.0.17 (from -r requirements.txt (line 1))
       Installing collected packages: pyodbc
         Running setup.py install for pyodbc: started
           Running setup.py install for pyodbc: finished with status 'error'
           Complete output from command /app/.heroku/python/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-sxxn23/pyodbc/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-lRnuMu-record/install-record.txt --single-version-externally-managed --compile:
           running build
           running build_ext
           building 'pyodbc' extension
           creating build/temp.linux-x86_64-2.7
           creating build/temp.linux-x86_64-2.7/src
           gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPYODBC_VERSION=4.0.17 -I/app/.heroku/python/include/python2.7 -c src/errors.cpp -o build/temp.linux-x86_64-2.7/src/errors.o -Wno-write-strings
           cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]
           In file included from src/errors.cpp:2:0:
           src/pyodbc.h:56:17: fatal error: sql.h: No such file or directory
            #include <sql.h>
                            ^
           compilation terminated.

           ----------------------------------------
           running install
           creating build
           error: command 'gcc' failed with exit status 1
Command "/app/.heroku/python/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-sxxn23/pyodbc/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-lRnuMu-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-sxxn23/pyodbc/
Failed to compile droplet
Exit status 223
Staging failed: Exited with status 223
Destroying container
Successfully destroyed container
。。。
------->Buildpack版本1.5.15
!     警告:您的应用程序缺少PROC文件。该文件告诉CloudFoundry如何运行您的应用程序。
!     了解更多信息:https://docs.cloudfoundry.org/buildpacks/prod-server.html#procfile
----->安装python-2.7.13
下载[file:///tmp/buildpack/dependencies/https___buildpacks.cloudfoundry.org_dependencies_python_python-2.7.13-linux-x64.tgz]
$pip安装-r requirements.txt
收集pyodbc==4.0.17(来自-r requirements.txt(第1行))
安装收集的软件包:pyodbc
为pyodbc运行setup.py安装:已启动
正在运行pyodbc的setup.py安装:已完成,状态为“错误”
从命令/app/.heroku/python/bin/python-u-c“import setuptools,tokenize;uuu file,uuu=”/tmp/pip-build-sxxn23/pyodbc/setup.py';f=getattr(tokenize,'open',open)(uu文件uu);code=f.read().replace('\r\n','\n');f.close();exec(compile,'code,'uuu文件,'exec'))install--record/tmp/pip-lRnuMu-record/install-record.txt--外部管理的单一版本--编译:
运行构建
运行build_ext
构建“pyodbc”扩展
创建build/temp.linux-x86_64-2.7
创建build/temp.linux-x86_64-2.7/src
gcc-pthread-fno严格别名-g-O2-DNDEBUG-g-fwrapv-O3-Wall-Wstrict原型-fPIC-DPYODBC_VERSION=4.0.17-I/app/.heroku/python/include/python2.7-csrc/errors.cpp-o build/temp.linux-x86_64-2.7/src/errors.o-Wno写字符串
Cc1Puls:警告:命令行选项'WraseTrimeType '对于C/Objc有效,但不适用于C++(默认启用)
在src/errors.cpp:2:0中包含的文件中:
src/pyodbc.h:56:17:致命错误:sql.h:没有这样的文件或目录
#包括
^
编译终止。
----------------------------------------
正在运行的安装
创建构建
错误:命令“gcc”失败,退出状态为1
命令“/app/.heroku/python/bin/python-u-c”导入setuptools,标记化__文件\ \='/tmp/pip-build-sxxn23/pyodbc/setup.py';f=getattr(标记化“打开”,打开)(_文件);code=f.read().replace('\r\n','\n');f、 close();exec(compile(code,_ufile,_u,'exec'))“安装--record/tmp/pip lRnuMu record/install-record.txt--外部管理的单一版本--compile”失败,错误代码为/tmp/pip-build-sxxn23/pyodbc中的1/
未能编译水滴
退出状态223
转移失败:已退出,状态为223
销毁容器
成功销毁货柜
这里有一个类似的问题:,但是这个问题与这个问题不同,因为它是非常通用的,而这个问题是关于同一主题的,但是与一组非常具体的构建步骤有关


更新:以下是基于已接受答案的更新脚本:

mkdir new_app
cd new_app

cat <<EOF>environment.yml
name: pyodbc-test
dependencies:
- pyodbc
EOF

cat <<EOF>manifest.yml
applications:
 - name: pyodbc-test
   memory: 128M
EOF

cf push 
mkdir新应用程序
cd新应用程序
猫
src/pyodbc.h:56:17:致命错误:sql.h:没有这样的文件或目录#include

您的设置通常看起来是正常的,但是在暂存期间运行
pip
时,构建工具仍然无法找到库头。标题在那里,因为您将它们包含在
vendor/
目录中,但它不知道它们在那里,因为python模块的构建脚本不会在该位置查找它们

我不知道有什么方法可以让它在不修改构建包的情况下在非标准位置查找头,因为to
pip

一些人建议设置
CPATH
和/或
C_INCLUDE_PATH
环境变量,因为这些变量应该由
gcc
获取,但在我的测试中,这些变量被忽略了

最后,我认为最好的选择是使用Conda安装pyodbc。这是你应该怎么做的

  • environment.yml
    添加到项目的根目录中
  • 在其中添加以下内容:
  • name:pyodbc测试
    依赖项:
    -pyodbc
    
  • 运行
    cf push
  • 构建包应该在转移期间运行,安装miniconda,然后使用conda安装依赖项,特别是pyodbc


    希望有帮助

    根据@Daniel Mikusa的回答

    您需要向pip发送其他参数

    Pip支持
    --global options
    来传递此类内容。不幸的是,从这里选项被传递到setup.py

    setup.py有自己的全局选项,即
    build\u ext

    Options for 'build_ext' command:
      --build-lib (-b)     directory for compiled extension modules
      --build-temp (-t)    directory for temporary files (build by-products)
      --plat-name (-p)     platform name to cross-compile for, if supported
                           (default: linux-x86_64)
      --inplace (-i)       ignore build-lib and put compiled extensions into the
                           source directory alongside your pure Python modules
      --include-dirs (-I)  list of directories to search for header files
      ... 
    
    Setup.py需要
    build\u ext--包括目录

    据我所知,要将这些参数赋给setup.py,每个参数必须由
    --global option=
    单独加上前缀

    我只是经历了同样的头痛,下面这些对我来说很有效

    pip install pyodbc --global-option="build_ext" --global-option="--include-dirs" --global-option="<path to unixodbc/include>"
    
    pip install pyodbc--global option=“build_ext”--global option=“--include dirs”--global option=“”
    
    pip install pyodbc --global-option="build_ext" --global-option="--include-dirs" --global-option="<path to unixodbc/include>"