使用Pip安装Python包时如何使用MinGW的gcc编译器? [英] How to use MinGW's gcc compiler when installing Python package using Pip?

查看:65
本文介绍了使用Pip安装Python包时如何使用MinGW的gcc编译器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我配置了 MinGW 和 distutils,所以现在我可以使用这个命令编译扩展:

I configured MinGW and distutils so now I can compile extensions using this command:

setup.py install

将使用 MinGW 的 gcc 编译器并安装包.为此,我安装了 MinGW 并创建了 distutils.cfg 包含以下内容的文件:

MinGW's gcc compiler will be used and package will be installed. For that I installed MinGW and created distutils.cfg file with following content:

[build]
compiler = mingw32

这很酷,但现在我想使用所有 pip 好处.有没有办法在 pip 中使用相同的 MinGW 的 gcc 编译器?所以当我运行这个时:

It's cool but now I'd like to use all pip benefits. Is there a way to use the same MinGW's gcc compiler in pip? So that when I run this:

pip install <package name>

pip 将使用 MinGW 的 gcc 编译器并在需要时编译 C 代码?

pip will use MinGW's gcc compiler and compile C code if needed?

目前我收到此错误:无法找到 vcvarsall.bat.似乎 pip 不知道我有 gcc 编译器.如何配置 pip 以使用 gcc 编译器?

Currently I get this error: Unable to find vcvarsall.bat. Seems pip doesn't know that I have gcc compiler. How can I configure pip to use gcc compiler?

推荐答案

  • 在选中 C++ 编译器选项的情况下安装 MinGW
  • C:MinGWin 添加到您的路径
  • PYTHONPATHLibdistutils 中,创建一个文件 distutils.cfg 并添加以下几行:
    • install MinGW with C++ Compiler option checked
    • add C:MinGWin to your PATH
    • in PYTHONPATHLibdistutils, create a file distutils.cfg and add these lines:
    • [build]
      compiler=mingw32
      

      这篇关于使用Pip安装Python包时如何使用MinGW的gcc编译器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆