cython not working with python 3.4 in Anaconda3

0 views
Skip to first unread message

genadij

unread,
Feb 28, 2015, 8:51:55 AM2/28/15
to anac...@continuum.io
Dear all,

I am starting with cython, but could't reproduce any of the tutorials out there.
After installing python 3.3.5 and dependences in separate environment, cython is working as expected.

I am not sure if problem is Anaconda3 specific, or it is a python3.4 -- cython issue.

I am on windows 7 (64 bit).


Ilan Schnell

unread,
Feb 28, 2015, 9:20:44 AM2/28/15
to Anaconda
What are the errors you are seeing?  Do you use the MinGW which comes with Anaconda, or are you using Visual Studio?  I suspect that your problem might have to do with how your environment is set up.  What is the output from running "conda info --all"?

Thanks   Ilan

--
Anaconda Community Support Group Brought to you by Continuum Analytics
---
You received this message because you are subscribed to the Google Groups "Anaconda - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to anaconda+u...@continuum.io.
To post to this group, send email to anac...@continuum.io.
Visit this group at http://groups.google.com/a/continuum.io/group/anaconda/.

genadij

unread,
Feb 28, 2015, 9:40:13 AM2/28/15
to anac...@continuum.io
After creating python 3.3 environment I couldn't reproduce same error as before, but I have created python 3.4 environment and I am getting same error now.

I am building cython module using distutils and mingw installed in python 3.4 environment. Building and installing is OK, problem is in importing it in ipython:

UnicodeDecodeError: 'utf-8' codec can't decode byte 0x83 in position 1: invalid start byte


I have installed python 3.4 environment by:

conda create -n py34 python=3.4 libpython mingw cython ipython

conda info --all
Current conda install:

             platform : win-64
        conda version : 3.9.1
  conda-build version : 1.8.2
       python version : 3.4.1.final.0
     requests version : 2.5.3
     root environment : C:\Anaconda3  (writable)
  default environment : C:\Anaconda3\envs\py34
     envs directories : C:\Anaconda3\envs
        package cache : C:\Anaconda3\pkgs
         channel URLs : http://repo.continuum.io/pkgs/free/win-64/
                        http://repo.continuum.io/pkgs/free/noarch/
                        http://repo.continuum.io/pkgs/pro/win-64/
                        http://repo.continuum.io/pkgs/pro/noarch/
          config file : None
    is foreign system : False

# conda environments:
#
py335                    C:\Anaconda3\envs\py335
py34                  *  C:\Anaconda3\envs\py34
root                     C:\Anaconda3

sys.version: 3.4.1 |Anaconda 2.1.0 (64-bit)| (default...
sys.prefix: C:\Anaconda3
sys.executable: C:\Anaconda3\python.exe
conda location: C:\Anaconda3\lib\site-packages\conda
conda-build: C:\Anaconda3\Scripts\conda-build.exe
conda-convert: C:\Anaconda3\Scripts\conda-convert.exe
conda-develop: C:\Anaconda3\Scripts\conda-develop.exe
conda-env: C:\Anaconda3\Scripts\conda-env.exe
conda-index: C:\Anaconda3\Scripts\conda-index.exe
conda-metapackage: C:\Anaconda3\Scripts\conda-metapackage.exe
conda-pipbuild: C:\Anaconda3\Scripts\conda-pipbuild.exe
conda-skeleton: C:\Anaconda3\Scripts\conda-skeleton.exe
user site dirs: C:\Users\genadij\AppData\Roaming\Python\Python27
                C:\Users\genadij\AppData\Roaming\Python\Python33
                C:\Users\genadij\AppData\Roaming\Python\Python34

CIO_TEST: <not set>
CONDA_DEFAULT_ENV: py34
CONDA_ENVS_PATH: <not set>
PATH: C:\Anaconda3\envs\py34;C:\Anaconda3\envs\py34\Scripts;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;c:\Progra
m Files (x86)\Intel\iCLS Client\;c:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShe
ll\v1.0\;C:\Program Files (x86)\Hewlett-Packard\HP Performance Advisor;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (
x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\OpenCL SDK\3.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\3.0\bin\x64;C:\
Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files (x86)\MiKTeX 2.9\miktex\bin\;C:\Program Files\Intel\Intel(R)
Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Compon
ents\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\TortoiseSVN1.8.8\bin;C:\MassLynx\;C:\Program Files (x86)\Hewlet
t-Packard\HP ProtectTools Security Manager\Bin\;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files\TortoiseGit\bin;C:\Anaconda3;C:\Anaconda3\Scripts;C:
\Program Files\NCBI\blast-2.2.29+\bin;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files (x86)\Google\google_
appengine\;C:\Users\genadij\AppData\Local\Pandoc\
PYTHONHOME: <not set>
PYTHONPATH: <not set>

WARNING: could not import _license.show_info
# try:
# $ conda install -n root _license


Genadij

Ryan Nelson

unread,
Feb 28, 2015, 5:44:36 PM2/28/15
to anac...@continuum.io
As another data point, I am also seeing some problems with Cython that I've not noticed before. Anaconda3. conda, ipython, ipython-notebook, cython, and mingw all updated.
If I fire up a new IPython notebook or qtconsole and do the following:

In : %load_ext cythonmagic
In : %%cython
def fib(n):
    """Print the Fibonacci series up to n."""
    a, b = 0, 1
    while b < n:
        print b,
        a, b = b, a + b

My memory usage blows up. Maybe by an extra ~4-5 GB. In the next cell, if I try to call the "fib" function. The ipython kernel dies. Unfortunately, I'm not seeing any error messages printed to the terminal. I do not have Visual Studio, so the only available build option is Anaconda's MinGW. I tried the same thing on a Linux box, non-Anaconda install, and the above code works fine.

Big Stone

unread,
Mar 1, 2015, 8:49:43 AM3/1/15
to anac...@continuum.io
maybe should you try the new standard

%load_ext Cython

instead of previous standard

%load_ext cythonmagic

Ryan Nelson

unread,
Mar 1, 2015, 9:05:34 AM3/1/15
to anac...@continuum.io
I tried this and got the same result.

However, it is good to know that there is a new standard. Thanks. I'm surprised that the old invocation doesn't throw a deprecation warning if it is not correct anymore.

Big Stone

unread,
Mar 1, 2015, 12:34:20 PM3/1/15
to anac...@continuum.io
It does send a deprecation warning, starting IPython3.0

You may test with something simpler and not wired-bug-infinite-loop able :

%%cython
print ("Hello, World")


Otherwise, there was a bug in some version of Ipython which forget to re-compile the cython automati code, but I forgot where it was.
==> you may try clean your "cython magic" cach, which may be on a directory like  "settings\.ipython\cython"

Ryan Nelson

unread,
Mar 1, 2015, 1:13:43 PM3/1/15
to anac...@continuum.io
I forgot to mention that I did delete the cython directory C:\Users\me\.ipython\cython. I see it get regenerated when I try to use the Cython magic in a notebook.
I also tried the print example you provided, and I see the same behavior.
I made a new conda environment, same as genadij, but with ipython-notebook also in the install directive. I still have the same problems. 

Big Stone

unread,
Mar 1, 2015, 4:06:18 PM3/1/15
to anac...@continuum.io
You may explain your strange issue on the cython google group:   https://groups.google.com/forum/#!forum/cython-users

The best cython expert are there.

Carlos Córdoba

unread,
Mar 1, 2015, 10:03:37 PM3/1/15
to anac...@continuum.io
Hi,

Please use Visual Studio instead of MinGW to compile Cython extensions, especially if you're working on Windows 64. As an example of the problems you can get, see:

https://github.com/ContinuumIO/anaconda-issues/issues/271

Another option is to use TDM-GCC (but i haven't tried it myself):

http://tdm-gcc.tdragon.net/

Cheers,
Carlos

El 28/02/15 a las 17:44, Ryan Nelson escribió:
Reply all
Reply to author
Forward
0 new messages