3

是否可以使用免费的 Microsoft C++ Compiler for Python 2.7构建二进制 conda python 包?

我在我的 Windows 7 机器上安装了编译器,但是当我尝试 conda build(例如来自https://github.com/ioos/conda-recipes/tree/master/pyproj的 conda build pyproj )时,我得到:

C:\Anaconda64\conda-bld\work\pyproj-1.9.3>set USERPROFILE=C:\Users\rsignell

C:\Anaconda64\conda-bld\work\pyproj-1.9.3>REM ===== end generated header =====
C:\Anaconda64\conda-bld\work\pyproj-1.9.3>"C:\Anaconda64\envs\_build\python.exe"
 setup.py install
Traceback (most recent call last):
  File "setup.py", line 14, in <module>
    objects = cc.compile(['nad2bin.c', 'src/pj_malloc.c'])
  File "C:\Anaconda64\envs\_build\lib\distutils\msvc9compiler.py", line 473, in
compile
    self.initialize()
  File "C:\Anaconda64\envs\_build\lib\distutils\msvc9compiler.py", line 383, in
initialize
    vc_env = query_vcvarsall(VERSION, plat_spec)
  File "C:\Anaconda64\envs\_build\lib\distutils\msvc9compiler.py", line 271, in
query_vcvarsall
    raise DistutilsPlatformError("Unable to find vcvarsall.bat")
distutils.errors.DistutilsPlatformError: Unable to find vcvarsall.bat

C:\Anaconda64\conda-bld\work\pyproj-1.9.3>if errorlevel 1 exit 1
Command failed: C:\Windows\system32\cmd.exe /c bld.bat

我的康达信息是:

c:\Users\rsignell\Documents\GitHub\conda-recipes>conda info
Current conda install:

             platform : win-64
        conda version : 3.8.1
  conda-build version : 1.10.0
       python version : 2.7.8.final.0
     requests version : 2.5.1
     root environment : C:\Anaconda64  (writable)
  default environment : C:\Anaconda64
     envs directories : C:\Anaconda64\envs
        package cache : C:\Anaconda64\pkgs
         channel URLs : http://repo.continuum.io/pkgs/free/win-64/
                        http://repo.continuum.io/pkgs/pro/win-64/
          config file : None
    is foreign system : False
4

1 回答 1

3

我遇到了同样的问题并用这样的补丁解决了它:

  1. 设置一个环境变量(一定要使用你自己的名字):

    VS90COMNTOOLS=C:\Users\joost\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0

  2. 修补文件 C:\Users\joost\Anaconda\Lib\distutils\msvc9compiler.py

        if not os.path.isdir(productdir):
            log.debug("%s is not a valid directory" % productdir)
            return None
    

    进入:

    if not os.path.isdir(productdir):
        productdir = toolsdir
        if not os.path.isdir(productdir):
            log.debug("%s is not a valid directory" % productdir)
            return None  
    

完毕!错误是在 Microsoft Visual C++ Compiler for Python 27 中不存在的目录中vcvarsall.bat搜索了该文件。..\..\VC

于 2015-02-21T19:05:35.513 回答