1

Info:

Python Version : 3.7.4

Platform : win 10 64 bit


I am trying to compile the file compileModule.py using command :

python compileModule.py build_ext --inplace 

compileModule.py:

from distutils.core import setup, Extension
from distutils.sysconfig import *
from distutils.util import *
from Cython.Distutils import build_ext
import numpy
import os
import os.path

try:
   from distutils.command.build_py import build_py_2to3 \
       as build_py
except ImportError:
   from distutils.command.build_py import build_py

try:
   from Cython.Distutils import build_ext
except ImportError:
   use_cython = False
else:
   use_cython = True


py_inc = [get_python_inc()]

np_lib = os.path.dirname(numpy.__file__)
np_inc = [os.path.join(np_lib, 'core/include')]
ext_inc = os

sourcefiles = ["utilFunctions.c", "cutilFunctions.pyx"]

setup(
    cmdclass = {'build_ext': build_ext},
    ext_modules = [Extension("utilFunctions_C",sourcefiles, libraries=['m'], include_dirs=py_inc + np_inc)]
  )

After executing the above command I got an error :

 Unable to find vcvarsall.bat

I downloaded and installed the Build Tools for Visual Studio 2017 by following the solution on this post.

Then i execute the below command again :

python compileModule.py build_ext --inplace 

which gives a new error:

LINK : fatal error LNK1181: cannot open input file 'm.lib'
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.22.27905\\bin\\HostX86\\x64\\link.exe' failed with exit status 1181

Now I am stuck with this error. Does anyone have any idea how to solve this error?

P.S. I opened all cmd inside Vs code but still same error :

enter image description here

9
  • Have you tried opening the command prompt from the entry MSBuild created when you installed it (somewhere in the start menu, but not the plain Command Prompt entry)? If not, please try that first. I believe it sets all kinds of environment variables and paths that may be required. Commented Sep 16, 2019 at 11:19
  • The linker cannot find your standard math library. This should be in the folder that your toolchain is installed, possibly in C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.22.27905\\lib(wild guess). Try to find the path where your standard libraries are and add it to your include_dirs. Commented Sep 16, 2019 at 11:23
  • @blubberdiblub : I see 4-5 command prompts(screenshot updated in the question). I opened all of them but no success Commented Sep 16, 2019 at 11:28
  • @th33lf: Please explain your comment. I found 3 folders in the path you mentioned: 'onecore', 'x64', 'x86' Commented Sep 16, 2019 at 11:33
  • 1
    @AnubhavJhalani Try buildling without the libraries=['m'] line then Commented Sep 16, 2019 at 12:42

1 Answer 1

1

I found following solution to my problem:

I deleted libraries=['m'] from the compileModule.py and then file got compiled without any error.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.