1. python安装某些第三方包报错vcvarsall.bat

原因:python安装某些第三方包(这里主要针对Windows平台),主要是涉及系统底层和本地代码库时,需要C编译环境,Windows平台下,python本身是通过VC的编译环境编译的,不同的python版本对应不同的VC的动态库,同时,第三方库可能是采用其他编译器(比如GNU C、Cygwin、MinGW等)编译扩展的C代码。

官方说明:python3的安装包的构建主要是通过内置的Distutils工具来完成(https://docs.python.org/3.4/install/)

Whenever possible, the Distutils try to use the configuration information made available by the Python

interpreter used to run the setup.py script. For example, the same compiler and linker flags used to compile

Python will also be used for compiling extensions. Usually this will work well, but in complicated situations

this might be inappropriate. This section discusses how to override the usual Distutils behaviour.

解决方案:

安装python对应版本的VC编译器,可以直接安装整个visual studio;

如果不想整个安装VC,则可以选择安装MinGW(并将其安装后的bin等目录加入到系统path),然后配置python分发包的默认编译工具,

即在python安装目录的Lib\distutils目录下(比如安装的python3.4版本,那么即似C:\Python34\Lib\distutils),新建distutils.cfg文件(如果已有,则直接编辑之)。打开该文件,在前面添加如下内容(这里是32位的mingw,所以是mingw32,64位则为mingw64)。

[build]

compiler=mingw32

上述设置之后python distutils构建带C扩展的库或者安装C扩展的库之时,全部都切换至设置的编译器,如果只是想修改某一次的构建或者安装时使用的编译器,则可以在构建或者安装的时候加上参数,如:

python setup.py build --compiler=mingw32 install

如果也不想自己手动安装mingw,想更简便,有一种便捷的方式可以走。一般情况下,大家都会在自己的windows主机上安装Git(这里安装的是64位的git,如果安装32位的git,那么对应的是mingw32),下载的官方地址为windows git官方下载,安装之后,会自动安装mingw(windows版本Git依赖mingw,安装在git的安装目录下),如下图所示:

此时将mingw的bin目录也就是D:\Program Files\Git\mingw64\bin添加到系统path环境变量中。然后就和方法2中的后续步骤一致,即配置python分发包的默认编译工具,在python安装目录的Lib\distutils目录下(比如安装的python3.4版本,那么即似C:\Python34\Lib\distutils),新建distutils.cfg文件(如果已有,则直接编辑之)。打开该文件,在前面添加如下内容(这里是64位的mingw,所以是mingw64,32位则为mingw32)。

[build]

compiler=mingw64

采用上述方法配置好之后,再次安装即可成功。

2.安装某些包时报错,类似”collect2.exe: error: ld returned 1 exit status”,C:\Python27\libs/libpython27.a(dmmes01026.o):(.idata$7+0x0): undefined reference to `_head_C__build27_cpython_PCBuild_libpython27_a'

C:\Python27\libs/libpython27.a(dmmes00281.o):(.idata$7+0x0): undefined reference to `_head_C__build27_cpython_PCBuild_libpython27_a'

C:\Python27\libs/libpython27.a(dmmes00105.o):(.idata$7+0x0): undefined reference to `_head_C__build27_cpython_PCBuild_libpython27_a'

C:\Python27\libs/libpython27.a(dmmes00253.o):(.idata$7+0x0): undefined reference to `_head_C__build27_cpython_PCBuild_libpython27_a'

C:\Python27\libs/libpython27.a(dmmes00227.o):(.idata$7+0x0): undefined reference to `_head_C__build27_cpython_PCBuild_libpython27_a'

C:\Python27\libs/libpython27.a(dmmes00712.o):(.idata$7+0x0): more undefined references to `_head_C__build27_cpython_PCBuild_libpython27_a' follow

collect2.exe: error: ld returned 1 exit status

原因:和问题1本质一样,由于Windows平台下的python编译器本身由VC环境编译,其生成的pythonxx.dll(xx是版本号,比如27、34)和pythonxx.lib等可能与需要安装的第三方库(采用Cygwin、MinGW等编译器(环境)生成并发布)无法兼容.

解决方案:

To create Python extensions, you need to link against the Python library. Unfortunately, most Python distributions are provided with Pythonxx.lib, a library in Microsoft Visual C++ format. GCC expects a.a file (libpythonxx.a to be precise.). Here’s how to convert pythonxx.lib to libpythonxx.a:

b.Get pythonxx.dll (it should be somewhere on your harddrive).

c.Run : pexports pythonxx.dll > pythonxx.def This will extract all symbols from pythonxx.dll and write them into pythonxx.def.

d.Run : dlltool –dllname pythonxx.dll –def pythonxx.def –output-lib libpythonxx.a This will create libpythonxx.a (dlltool is part of MinGW utilities).

Copy libpythonxx.a to c:\pythonxx\libs\ (in the same directory as pythonxx.lib).

This trick should work for all Python versions, including future releases of Python. You can also use this trick to convert other libraries.

python典型安装_python安装某些第三方包报错解决办法相关推荐

  1. go module 导入本地嵌套包报错解决办法

    现在换了一份工作,虽然还是做IT,但是与原来的行业毕竟不一样,有很多新东西需要学习.现在,每一天都很充实,所以很久没有更新博客了(给自己的懒惰,找个借口) 好了,言归正传,聊聊今天的主题------g ...

  2. win10 安装驱动时 哈希值报错解决办法记录

    当win10专业版中 "设置"选项中没有找到"恢复"选项时,可以按住shift键进行电脑重启,这样可以使电脑高级启动. 常规方法: 解决方法: 1.找到WIN1 ...

  3. 《Python笔记》安装(pip)第三方包报错

    目录 Python版本 报错信息 pip 安装numpy报错 pip 安装 scipy报错 pip 安装 pywin32 报错 解决办法 网络方法1 网络方法2 请测解决方法 Python版本 $ p ...

  4. Python在指定环境下安装第三方库的报错解决办法

    Python在指定环境下安装第三方库的报错解决办法 在python安装第三方库时,如果直接打开cmd命令提示符,并输入下列安装命令,则会默认安装在base环境下 但base环境下的包新建的虚拟环境是无 ...

  5. 安装 python 虚拟环境 > pip install virtualenv -i https://pypi.tuna.tsinghua.edu.cn/simple/报错解决办法

    安装 python 虚拟环境 > pip install virtualenv -i https://pypi.tuna.tsinghua.edu.cn/simple/报错解决办法 [root@ ...

  6. pycharm安装pandas报错解决办法

    pycharm安装pandas报错解决办法 当使用pycharm自动安装pandas时,提示安装失败并要求在命令提示符界面进行安装.在使用命令提示符安装成功之后,发现pycharm仍然无法安装pand ...

  7. idea安装及项目导入过程中pom报错解决办法

    1.idea安装可用破解版或者在淘宝上买正版账号(20多块钱一年,挺便宜的) 2.pom报错解决办法: 在项目导入过程中pom报错: 原因:相关jar包未下载完.(下载速度慢,因为下载的链接是国外的节 ...

  8. Apache/php7.4/Mariadb安装和报错解决办法

    Apache和Mariadb安装基本都没有什么问题 PHP7.4安装过程中出现很多报错,网络大佬够已经给解决,下边安装步骤已经亲测: 需要安装apache的: 安装:yum -y install ht ...

  9. please reinstall the mysql distribution_php安装扩展mysqli的实现步骤及报错解决办法

    php安装扩展mysqli的实现步骤及报错解决办法 terminal#cd php-5.3.6/ext/mysqli #/usr/local/webserver/php/bin/phpize #./c ...

  10. php mysqli报错,php安装扩展mysqli的实现步骤及报错解决办法

    php安装扩展mysqli的实现步骤及报错解决办法 terminal #cd php-5.3.6/ext/mysqli #/usr/local/webserver/php/bin/phpize #./ ...

最新文章

  1. centos7下监控流量、数据包占用最大的进程
  2. Sun副总裁:绿色数据中心需分四步走
  3. Eclipse中启动tomcat报错:A child container failed during start
  4. redis 同步化操作
  5. 【转】 差分约束系统详解(转化为最短路) (概念)
  6. properties文件 , properties类, 的作用
  7. 敏捷开发系列学习总结(12)——给Scrum Master的十个建议,你值得拥有
  8. [转贴] 电脑族请关爱自己的身体--远离“电脑病”完全实用手册
  9. c# u盘使用记录_金属U盘定制加工 各种款式金属U盘加工
  10. Opmanager研究笔记
  11. java判断子串重复_判断字符串是否是由子串重复多次构成
  12. [转载]Wifi OKC 验证
  13. JVM垃圾收集器-Parallel Scavenge收集器
  14. FL Studio 20音乐制作教程
  15. IT研发人员的四种工作
  16. 自动驾驶定位技术之争:融合定位才是出路
  17. _Win7_Ultimate_x64_.gho
  18. 精妙绝伦的脑洞acm题
  19. 纯Go实现的Firebase的替代品 | Gopher Daily (2021.08.11) ʕ◔ϖ◔ʔ
  20. RTX 实时系统 IntervalZero 官方文档

热门文章

  1. C++_CopyConstructor(副本构造器 防止指针重复释放)
  2. 【一天一个C++小知识】006. 浮点数在计算机内部的表示与转换
  3. 关于图神经网络的相关学习资源的分享——网站 博客(一)
  4. 贝叶斯球(Bayes ball)
  5. 基于手机系统的实时目标检测
  6. Python多进程实现原理
  7. weblogic调整多个服务启动顺序方法
  8. 构建根文件系统之启动第一个程序(韦大仙)
  9. 【VR】Leap Motion 官网文档 FingerModel (手指模型)
  10. [转]ASP.NET Web API系列教程(目录)