How to install cython an Anaconda 64 bits with Windows 10?

2024/9/23 18:25:01

It's all in the title, does someone have a step by step method to install cython and run it on Anaconda 64 bits on Windows 10? I search for hours and there are a lot of tutorials... For things that I wasn't able to get or do on windows 10. I try to follow all those methods and more but in vain for now: https://www.ibm.com/developerworks/community/blogs/jfp/entry/Installing_Cython_On_Anaconda_On_Windows?lang=en

https://github.com/cython/cython/wiki/CythonExtensionsOnWindows

Conda install is done but the problem is to link the compiler to python, all the method using windows SDK and espescially the SDK command prompt are outdated, this prompt doesn't exist on Visual studio 2015 and the setenv function doesn't exist anymore either so impossible to execute 'setenv \x64 \release' and without this step the code doesn't work.

The other methode with MinGW return an error:

C:\MinGW\bin\gcc.exe -shared -s build\temp.win-amd64-3.6\Release\hello.o build\temp.win-amd64-3.6\Release\hello.cp36-win_amd64.def -LC:\Users\Utilisateur\Anaconda3\libs -LC:\Users\Utilisateur\Anaconda3\PCbuild\amd64 -lpython36 -lmsvcr140 -o C:\Users\Utilisateur\Documents\hello.cp36-win_amd64.pyd
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: cannot find -lmsvcr140
collect2.exe: erreur : ld a retourné 1 code d'état d'exécution
error: command 'C:\\MinGW\\bin\\gcc.exe' failed with exit status 1

so I don't know what to do next.

Help please.

A desperate student

Answer

Ok I solved the problem on Windows 10 with Anaconda using python 3.6.5 and MSC v.1900 64 bit (informations given by running :

import sys
sys.version

so here is the method:

1: install cython by running conda install -c anaconda cython in Anaconda prompt

2: go in C:\Users\Utilisateur\Anaconda3\Lib\distutils or wherever your distutils library is the create a distutils.cfg file (by using the notepad) and put

[build]           
compiler=mingw32 

in it

3: get the latest version of Mingw-w64 (not just Mingw which support just 32 bits) at https://sourceforge.net/projects/mingw-w64/files/ and install it

4: add C:\Program Files (x86)\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\bin to your Path here is a link on how to do that on windows 10: https://www.architectryan.com/2018/03/17/add-to-the-path-on-windows-10/

5: install libpython and m2w64-toolchain in your anaconda envirement by running conda install -c anaconda libpython and conda install -c msys2 m2w64-toolchain It come from these webpage https://python-at-risoe.pages.windenergy.dtu.dk/compiling-on-windows/common_errors.html and should correct the corresponding errors

6: try the first or second test on this page http://docs.cython.org/en/latest/src/quickstart/build.html both were working for me after step 5

Hope it will help!

https://en.xdnf.cn/q/71794.html

Related Q&A

Using DictWriter to write a CSV when the fields are not known beforehand

I am parsing a large piece of text into dictionaries, with the end objective of creating a CSV file with the keys as column headers. csv.DictWriter(csvfile, fieldnames, restval=, extrasaction=raise, di…

How to Save io.BytesIO pdfrw PDF into Django FileField

What I am trying to do is basically:Get PDF from URL Modify it via pdfrw Store it in memory as a BytesIO obj Upload it into a Django FileField via Model.objects.create(form=pdf_file, name="Some n…

Which python static checker can catch forgotten await problems?

Code: from typing import AsyncIterableimport asyncioasync def agen() -> AsyncIterable[str]:print(agen start)yield 1yield 2async def agenmaker() -> AsyncIterable[str]:print(agenmaker start)return …

Tkinter : Syntax highlighting for Text widget

Can anyone explain how to add syntax highlighting to a Tkinter Text widget ?Every time the program finds a matching word, it would color that word to how I want. Such as : Color the word tkinter in pi…

how to use pkgutils.get_data with csv.reader in python?

I have a python module that has a variety of data files, (a set of csv files representing curves) that need to be loaded at runtime. The csv module works very well # curvefile = "ntc.10k.csv"…

How to make celery retry using the same worker?

Im just starting out with celery in a Django project, and am kinda stuck at this particular problem: Basically, I need to distribute a long-running task to different workers. The task is actually broke…

Make an AJAX call to pass drop down value to the python script

I want to pass the selected value from dropdown which contains names of databases and pass it to the python script in the background which connects to the passed database name. Following is the ajax co…

PyLint 1.0.0 with PyDev + Eclipse: include-ids option no longer allowed, breaks Eclipse integration

As noted in this question: How do I get Pylint message IDs to show up after pylint-1.0.0?pylint 1.0.0 no longer accepts "include-ids" option. (It returns "lint.py: error: no such optio…

Shifting all rows in dask dataframe

In Pandas, there is a method DataFrame.shift(n) which shifts the contents of an array by n rows, relative to the index, similarly to np.roll(a, n). I cant seem to find a way to get a similar behaviour …

Pandas dataframe: omit weekends and days near holidays

I have a Pandas dataframe with a DataTimeIndex and some other columns, similar to this:import pandas as pd import numpy as nprange = pd.date_range(2017-12-01, 2018-01-05, freq=6H) df = pd.DataFrame(ind…