Python Forum
Error in compiling cython extension on Python 3.6.4 on Windows 8
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error in compiling cython extension on Python 3.6.4 on Windows 8
#1
I am learning to use Cython from here

I have a setup.py file as below:

#from distutils.core import setup
from setuptools import setup, find_packages, Extension, Command
from Cython.Build import cythonize

setup(
    ext_modules = cythonize("cyt_hello_world.pyx")
)
And a simple print as below in file cyt_hello_world.pyx
print("Cython Hello World!")
I compile this cython extension on a Windows host using below command

python setup.py build_ext --inplace

Whether I use distutils or setuptools in the setup.py file above, both give errors as below.

Error seen, If I use distutils

Quote:F:\PythonCode>python setup.py build_ext --inplace running build_ext building 'cyt_hello_world' extension

error: Unable to find vcvarsall.bat

If I use setuptools, below is the error

Quote:F:\PythonCode>python setup.py build_ext --inplace running build_ext building 'cyt_hello_world' extension

error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/

I have Microsoft Visual Studio installed at path : C:\Program Files (x86)\Microsoft Visual Studio 12.0

I can see file vcvarsall.bat in MSVisual Studio 12.0 installation folder C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC

How can i point to this *.bat and resolve these errors if i use distutils OR
How can i fix the errors: "Microsoft Visual C++ 14.0 is required", if any different installation needed?

Can someone please give inputs?

NOTE: I have tried setting set VS90COMNTOOLS=%VS120COMNTOOLS% but no success, same error of vcvarsall.bat . I have also added C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC to my windows PATH variable, but no success.
Reply
#2
You're missing a C++ compiler. The error specifying that you need MS C++ looks like a typical Microsoft OS error, where they are trying to get you to buy their product.
Although I don't know this as a fact, I suspect that any C++ compiler will work including mingw-gcc which is free see: https://github.com/cython/cython/wiki/Cy...sOnWindows.
Reply
#3
@Larz60 - Thanks.
I have visual studio 2013 installed on this Windows host. I mentioned that but it was formatted as block quote, along with the error messages.
That installation folder also has vcvarsall.bat file which is mentioned in one error message.

Could not get the cython compilation to pick that file though? Not sure how to use existing Visual Studio installation to compile Python.
Reply
#4
I don't use windows, Linux only, and haven't used visual studio in more than 18 years.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python C Extension Module loading issue on Cygwin mesibo 0 597 Sep-22-2023, 05:41 AM
Last Post: mesibo
  Python-for-Android:p4a: syntax error in main.py while compiling apk jttolleson 2 1,777 Sep-17-2022, 04:09 AM
Last Post: jttolleson
  I need to add data types to cython conversion python to c Good_AI_User 1 973 Aug-19-2022, 07:52 AM
Last Post: Gribouillis
  "SSL: CERTIFICATE_VERIFY_FAILED” error on Python 3.9.6 (Windows 10) rcmv 4 3,581 May-10-2022, 01:18 PM
Last Post: rcmv
  unable to load an image with C (Cython) HLD202 0 1,280 Jan-13-2022, 09:16 PM
Last Post: HLD202
  Cython np.where slows down the code Johanoosterwaal 1 1,695 Sep-01-2021, 07:33 AM
Last Post: Johanoosterwaal
  Compiling (PyInstaller issues) TheHolyPyGrenade 1 1,881 Apr-11-2021, 08:30 PM
Last Post: snippsat
  How can I use Cython to protect my Python Code? TurboC 2 4,080 Dec-03-2020, 10:37 AM
Last Post: padma121
  error while installing any library using pip in windows AkashKansal 1 4,335 Sep-24-2020, 07:51 AM
Last Post: buran
  Compiling SlicerCAT flaviu2 1 1,805 Sep-21-2020, 08:38 AM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020