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

查看:373
本文介绍了使用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中使用相同的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?

当前,我收到此错误:Unable to find 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:\MinGW\bin添加到您的PATH
  • PYTHONPATH\Lib\distutils中,创建文件distutils.cfg并添加以下行:
    • install MinGW with C++ Compiler option checked
    • add C:\MinGW\bin to your PATH
    • in PYTHONPATH\Lib\distutils, create a file distutils.cfg and add these lines:
    • [build]
      compiler=mingw32
      

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

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