New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building example.pyx in virtual environment #2068

Open
jamespeterschinner opened this Issue Jan 11, 2018 · 0 comments

Comments

Projects
None yet
1 participant
@jamespeterschinner

jamespeterschinner commented Jan 11, 2018

I'm running:
image

And wrote my first cython code:

example.pyx

cdef class Test:
    cdef int x
    cdef str y

    def __init__(self, x, y):
        self.x = x
        self.y = y

setup.py

from setuptools import setup
from Cython.Build import cythonize

setup(
  name = 'test',
  ext_modules = cythonize(r"C:\Users\James\PycharmProjects\Explore\example.pyx"),
)

I have

image

I found that running python setup.py build_ext --inplace gave me:

(junk) C:\Users\James\PycharmProjects\Explore>python setup.py build_ext
running build_ext
building 'example' extension
cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD "-IC:\Program Files\Python36\include" "-IC:\Program Files\Python36\include" "-IC:\Program Files (x86)\Microsoft Visual
Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\8.1\include\shared" "-IC:\Prog
ram Files (x86)\Windows Kits\8.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt" /TcC:\Users\James\PycharmProjects\Explore\example.c /Fobuil
d\temp.win-amd64-3.6\Release\Users\James\PycharmProjects\Explore\example.obj
error: command 'cl.exe' failed: No such file or directory

I'm using Pycharm, (which activates virtual environments by default). Finally I realized that the virtual environment junk (my testing environment) was active.

I then ran (in PowerShell)

PS C:\Users\James> python C:\Users\James\PycharmProjects\Explore\setup.py build_ext --inplace
running build_ext
copying build\lib.win-amd64-3.6\example.cp36-win_amd64.pyd ->

OK

>>> import example
>>> example.Test
<class 'example.Test'>
>>> a = example.Test(1, 'a')
>>> a
<example.Test object at 0x000001DDDD3BA470>

I attempted to add C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin to my path in the virtual environment, though I got more errors.

I believe PyCharm now automatically creates a new virtual environment for each project. So i'm guessing that others will make the same mistake as me. Should a note be added to documentation on how to set up a virtual environment? Or have I overlooked something in the docs?

@jamespeterschinner jamespeterschinner changed the title from Building foo.pyx in virtual environment to Building example.pyx in virtual environment Jan 11, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment