Creating a cython file: No such file or directory - python

I have recently switched to a windows OS but file is not being found with cython. The file seems correct.
I run:
CD C:\Users\Django\example-of-cython-pyinstaller-and-subzero\1 ACTUAL PROJECT
`python setup.py build_ext --inplace` and get `No such file or directory`
I get:
C:\Users\Django\ee\123>python setup.py build_ext --inplace
running build_ext
building 'myapp.cython_module' extension
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\Users\Django\AppData\Local\Continuum\miniconda3\include -IC:\Users\Django\AppData\Local\Continuum\miniconda3\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\include" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\winrt" /Tcmyapp/cython_module.c /Fobuild\temp.win-amd64-3.6\Release\myapp/cython_module.obj
cython_module.c
c1: fatal error C1083: Cannot open source file: 'myapp/cython_module.c': No such file or directory
C:\Users\Django\example-of-cython-pyinstaller-and-subzero\1 ACTUAL PROJECT\myapp
setup.py
from setuptools import find_packages, Extension
from distutils.core import setup
from distutils.core import setup
from setuptools import find_packages, Extension
from setuptools import setup, Extension
setup(
name='myapp',
ext_modules=[
Extension('myapp.cython_module', ['myapp/cython_module.pyx'])
],
)
enter image

Related

Unable to install python ldap module on windows

Tried installing python-ldap, but failed
"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -DHAVE_SASL -DHAVE_TLS -DHAVE_LIBLDAP_R -DHAVE_LIBLDAP_R -DLDAPMODULE_VERSION=3.4.0 "-DLDAPMODULE_AUTHOR=python-ldap project" "-DLDAPMODULE_LICENSE=Python style" -IModules -IC:\Users\rathod\AppData\Local\Programs\Python\Python39\include -IC:\Users\rathod\AppData\Local\Programs\Python\Python39\Include "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt" /TcModules/LDAPObject.c /Fobuild\temp.win-amd64-cpython-39\Release\Modules/LDAPObject.obj
LDAPObject.c
c:\users\rathod\appdata\local\temp\pip-install-dkw9jd4z\python-ldap_05f9ed21408d4097a9c6bd894511d8b7\modules\common.h(15): fatal error C1083: Cannot open include file: 'lber.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for python-ldap
Failed to build python-ldap
ERROR: Could not build wheels for python-ldap, which is required to install pyproject. toml-based projects
Tried using few of the .whl files from https://www.lfd.uci.edu/~gohlke/pythonlibs/#_python-ldap, but failed
PS C:\Users\rathod\source\repos\00 Dell-Gitlab staging\replication_status> pip install .\python_ldap-3.4.0-cp311-cp311-win32.whl
ERROR: python_ldap-3.4.0-cp311-cp311-win32.whl is not a supported wheel on this platform.
Has anyone faced same challenge, and if there is any way to install this old module on windows system?

anaconda cythonize C++ on windows 10

I have c++ code that compiles fine in MSVS 2015 which is installed on my PC. I've been tasked to make a python extension using cython to be able to call c++ function from our python application. I have installed anaconda 5.2 w/ cython installed already. The c++ has a bunch of header files that need to be included when compiling. I'm trying to build one function and am running into the same error.
My test.pyx looks like this for the one function:
cimport test
cimport cython
def pxd_PIXCIclose():
res = test.pxd_PIXCIclose()
return res
The test.pxd is as follows:
cdef extern from "D:\epix\inc\xcliball.h":
int pxd_PIXCIclose()
setup.py is:
from distutils.core import setup
from distutils.extension import Extension
from Cython.Build import cythonize
ext_modules = Extension(
name = "test",
sources=["test.pyx"],
include_dirs=["D:\epix\lib", "D:\epix\inc"],
library_dirs="D:\epix\inc\XCLIBW64.lib","D:\epix\lib\PXIPLW64.lib"]
)
setup(
name = "test.pyx",
ext_modules = cythonize([ext_modules])
)
The test.c is created but then I get a bunch of build errors on the headers in the C++ include folder:
python setup.py build_ext --inplace --compiler=msvc
Compiling test.pyx because it depends on .\test.pxd.
[1/1] Cythonizing test.pyx
running build_ext
building 'test' extension
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe
/c /nologo /Ox /W3 /GL /DNDEBUG /MD -ID:\epix\lib -ID:\epix\inc -
IC:\Anaconda3\include -IC:\Anaconda3\include "-IC:\Program Files
(x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files
(x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE" "-IC:\Program Files
(x86)\Windows Kits\10\include\10.0.10586.0\ucrt" "-IC:\Program Files
(x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files
(x86)\Windows Kits\10\include\10.0.10586.0\shared" "-IC:\Program Files
(x86)\Windows Kits\10\include\10.0.10586.0\um" "-IC:\Program Files
(x86)\Windows Kits\10\include\10.0.10586.0\winrt" /Tctest.c
/Fobuild\temp.win-amd64-3.6\Release\test.obj
test.c
d:\epix\inc\pxlibsv.h(312): error C2061: syntax error: identifier 'HANDLE'
d:\epix\inc\pxlibsv.h(317): error C2059: syntax error: '}'
d:\epix\inc\pxlibsv.h(827): error C2143: syntax error: missing ')' before
'*'
d:\epix\inc\pxlibsv.h(827): error C2081: 'HANDLE': name in formal parameter
list illegal
d:\epix\inc\pxlibsv.h(827): error C2143: syntax error: missing ';' before
'*'
d:\epix\inc\pxlibsv.h(827): error C2059: syntax error: '*'
.
.
.
d:\epix\inc\xclibsc.h(369): fatal error C1003: error count exceeds 100;
stopping compilation
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio
14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit status 2
I'm guessing my setup.py is not correct? Anyone have any pointers on what is happening?
Update to my original post, by adding #include windows.h, the original 'HANDLE' error is now gone but I received this link error now:
(base) d:\epix\cython>python setup.py build_ext --inplace --compiler=msvc
running build_ext
building 'test' extension
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe
/c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\Anaconda3\include -ID:\epix\lib -
ID:\epix\inc -IC:\Anaconda3\include -IC:\Anaconda3\include "-IC:\Program
Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files
(x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE" "-IC:\Program Files
(x86)\Windows Kits\10\include\10.0.10586.0\ucrt" "-IC:\Program Files
(x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files
(x86)\Windows Kits\10\include\10.0.10586.0\shared" "-IC:\Program Files
(x86)\Windows Kits\10\include\10.0.10586.0\um" "-IC:\Program Files
(x86)\Windows Kits\10\include\10.0.10586.0\winrt" /Tctest.c
/Fobuild\temp.win-amd64-3.6\Release\test.obj
test.c
C:\Program Files (x86)\Microsoft Visual Studio
14.0\VC\BIN\x86_amd64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL
/MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:C:\Anaconda3\Lib
/LIBPATH:D:\epix\inc\XCLIBW64.lib /LIBPATH:D:\epix\lib\PXIPLW64.lib
/LIBPATH:C:\Anaconda3\libs /LIBPATH:C:\Anaconda3\PCbuild\amd64
"/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\amd64"
"/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio
14.0\VC\ATLMFC\LIB\amd64" "/LIBPATH:C:\Program Files (x86)\Windows
Kits\10\lib\10.0.10586.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows
Kits\NETFXSDK\4.6.1\lib\um\x64" "/LIBPATH:C:\Program Files (x86)\Windows
Kits\10\lib\10.0.10586.0\um\x64" /EXPORT:PyInit_test build\temp.win-amd64-
3.6\Release\test.obj /OUT:d:\epix\cython\test.cp36-win_amd64.pyd
/IMPLIB:build\temp.win-amd64-3.6\Release\test.cp36-win_amd64.lib
test.obj : warning LNK4197: export 'PyInit_test' specified multiple times;
using first specification
Creating library build\temp.win-amd64-3.6\Release\test.cp36-win_amd64.lib
and object build\temp.win-amd64-3.6\Release\test.cp36-win_amd64.exp
test.obj : error LNK2001: unresolved external symbol pxd_PIXCIclose
d:\epix\cython\test.cp36-win_amd64.pyd : fatal error LNK1120: 1 unresolved
externals error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio
14.0\\VC\\BIN\\x86_amd64\\link.exe' failed with exit status 1120
Any suggestions on resolving this error? Thank you.
Based on compiler output, HANDLE is not defined. Did you know, that with VS2015 you need to add path to SDK ? It is not included, as I can see. Add C:\Program Files (x86)\Windows Kits\10 \ include\ platformtoolset\um to path. Platformtoolset will define subfolder in yours include path. Hope it helps.
By adding #include windows.h to my header and then changing my original setup.py to the following:
from distutils.core import setup
from distutils.extension import Extension
from Cython.Build import cythonize
ext_modules = Extension(
name = "test",
sources=["test.pyx"],
include_dirs=["D:\epix\lib", "D:\epix\inc"],
library_dirs=["D:\epix\inc"],
libraries=["XCLIBW64", "PXIPLW64"]
)
setup(
name = "test.pyx",
ext_modules = cythonize([ext_modules])
I was able to successfully cythonize one of the functions in my c project. Thank you to all who gave me suggestions that pointed me in the right direction.

Error Installing tesseract-ocr Python 3.5 win 10

I have some problems with python . I'm trying to install python using pip :
-m pip install tesseract-ocr
for python 3.5 and here is the error I get:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\Users\ANHVU\AppData\Local\Programs\Python\Python35\include -IC:\Users\ANHVU\AppData\Local\Programs\Python\Python35\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:\Program Files (x86)\Windows Kits\8.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt" /EHsc /Tptesseract_ocr.cpp /Fobuild\temp.win-amd64-3.5\Release\tesseract_ocr.obj
tesseract_ocr.cpp
tesseract_ocr.cpp(517): fatal error C1083: Cannot open include file: 'leptonica/allheaders.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit status 2
How can I fix this? Tks for your help !
You can download wrapper and install it, also this package. But you should have tesseract-ocr installed on your PC

cl : Command line error D8003 : missing source filename when i compile .py to .pyd with Cython

I get this error when compile hello.py with "python setup.py build_ext --inplace" . I have searched for the error but get nothing. Has anyone ever solved a similar problem? os=win7-64, python=3.6.2, cython=0.27.1, visual stdudio=2015.
# hello.py
def say_hello_to(name):
print("Hello %s!" % name)
# setup.py
from distutils.core import setup
from Cython.Build import cythonize
setup(
ext_modules = cythonize("hello.py")
)
E:\Crawler>python setup.py build_ext --inplace
running build_ext
building 'hello' extension
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\cl.exe /c /nologo /Ox
/W3 /GL /DNDEBUG /MD "-ID:\Program Files (x86)\Python36-32\include" "-ID:\Progr
am Files (x86)\Python36-32\include" "-IC:\Program Files (x86)\Microsoft Visual S
tudio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10
240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-
IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program F
iles (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\
Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files\Microsoft SDKs\Windo
ws\v7.0\Include\" /Tchello.c /Fobuild\temp.win32-3.6\Release\hello.obj
cl : Command line error D8003 : missing source filename
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\
cl.exe' failed with exit status 2

Compiling with Cython on Windows: missing source filename

I'm trying to compile a hello world example with Cython on Windows 10.
I have visual studio 2015 community.
Python 3.5.2
My setup.py looks like this:
from distutils.core import setup
from Cython.Build import cythonize
setup (
name='print hello world',
ext_modules=cythonize("print_h_w.pyx", compiler_directives=
{'language_level': 3}),
)
The file I'm trying to compile looks like this:
print('Hello World')
I build with this command:
python setup.py build_ext --inplace
I keep getting this error:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe
/c /nologo /Ox /W3 /GL /DNDEBUG /MD -
IC:\Users\Paul\AppData\Local\Programs\Python\Python35\include -
IC:\Users\Paul\AppData\Local\Programs\Python\Python35\include "-IC:\Program
Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files
(x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE" "-IC:\Program Files
(x86)\Windows Kits\10\include\10.0.14393.0\ucrt" "-IC:\Program Files
(x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files
(x86)\Windows Kits\10\include\10.0.14393.0\shared" "-IC:\Program Files
(x86)\Windows Kits\10\include\10.0.14393.0\um" "-IC:\Program Files
(x86)\Windows Kits\10\include\10.0.14393.0\winrt" "-IC:\Program Files
(x86)\Windows Kits\10\Include\10.0.14393.0\ucrt\" /Tcprint_h_w.c
/Fobuild\temp.win-amd64-3.5\Release\print_h_w.obj
cl : Command line error D8003 : missing source filename
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio
14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit status 2
I've been doing a lot of research but I've turned up a lot of nothing. How can I fix this?
I think you should have import cython in your print_h_w.pyx file :
import cython
print("hello world")

Categories

Resources