pyfly2 icon indicating copy to clipboard operation
pyfly2 copied to clipboard

error: unable to find vcvarsall.bat

Open fonty422 opened this issue 8 years ago • 18 comments

After working around the stupid issues with python and Anaconda with respect to path issues, i managed to get somewhere with the install. But it now fails with the error message:

error: unable to find vcvarsall.bat

Any suggestions?

fonty422 avatar Apr 03 '16 11:04 fonty422

vcvarsall.bat is the script that Microsoft placed in the root of your Visual C++ compiler toolset.

What version of Microsoft Visual Studio are you using?

kbrafford avatar Apr 03 '16 18:04 kbrafford

Ah, I didn't realise I needed to have that installed. I'll try that and will get back to you if it still fails. I will note, however, that I did find the vcvarsall.bat file in ...\Microsoft\Visual C++ for Python\9.0.

fonty422 avatar Apr 03 '16 20:04 fonty422

I just ran into this as well. I have MSVS 12 and found vcvarsall.bat. I'm assuming I need to add that to the path?

Edit: Adding the VC directory of MSVS12 did nothing, just as copying the file to my pyfly2 directory did nothing. I'm working with Win 7 x64, python 2.7 x64 and FlyCapture_2.9.3.11_x64

qenops avatar Apr 03 '16 20:04 qenops

I think maybe Cython tries to find the MSVC in all the places it thinks it might be installed.

What if you executed vcvarsall.bat yourself from the same CMD prompt you are trying to build pyfly from? Perhaps that would make it easier for Cython to do whatever it is trying to do.

kbrafford avatar Apr 03 '16 21:04 kbrafford

I did that - it runs just fine. I keep getting the error though. So this is a Cython problem?

qenops avatar Apr 03 '16 21:04 qenops

It's either a Cython problem or a "kbrafford doesn't know how to set up Cython properly" problem :-/

Normally I'd do a deeper dive right now, but I am pushed for time until mid week. I'll try to look at it closer by then.

kbrafford avatar Apr 03 '16 22:04 kbrafford

Cool thanks. I'll update with anything I find.

qenops avatar Apr 03 '16 22:04 qenops

Yep, just installed all free versions of MSVS and still the same error. I'll happily wait until you have the time to look into it.

Thanks!

fonty422 avatar Apr 04 '16 10:04 fonty422

Ok I got it all working (except registering pyfly2 for import anywhere in python...do I need to copy something to site-packages???). To start I already had MSVS 8, 10,11, and 12 installed, but Cython wasn't happy, so I followed the instructions pointed to in Becky's comment here: Windows: Unable to find vcvarsall.bat (cython, other c extensions)

In recap, it ended up making me install MSVS 9.0, and then I had to copy vcvarsall.bat into the VC directory of 9.0 since it didn't have it (and modify it to set the correct version number) from one of the other versions. I then had to make sure the bat file which vcvarsall wanted was in the place it was looking and named properly. After that it compiles great.

So now how do I get it to import from anywhere?

qenops avatar Apr 04 '16 11:04 qenops

So now how do I get it to import from anywhere?

I am pretty sure I add the path of the development directory to a file called default.pth placed in the root of my python installation. I'll double check that once I get to my development machine in a couple of hours.

kbrafford avatar Apr 04 '16 11:04 kbrafford

Here's how I set it up. In my C:\Python27 directory I have a file called default.pth with these lines in it:

C:\Users\kbrafford\Documents\GitHub\pyfly2 C:\Users\kbrafford\Documents\GitHub\pyfly1\src

Those are the paths on my development machine where I have the repos for pyfly1 and pyfly2 checked out. I'm not sure why pyfly1 is different than pyfly2, but that's how I use it.

kbrafford avatar Apr 04 '16 15:04 kbrafford

This just solved it for me!

  1. Install latest x86 FlyCapture2 SDK from Point Grey
  2. Install Microsoft Visual C++ Compiler for Python 2.7 ( [http://aka.ms/vcpython27] )
  3. In your START menu you now have: Microsoft Visual C++ Compiler Package for Python 2.7 3a) Under this menu launch the "Visual C++ 2008 32-bit Command Prompt"
  4. Set these environment variables:
SET DISTUTILS_USE_SDK=1
SET MSSdk=1
  1. Now run: python setup.py build_ext --inplace

nortonsm avatar Apr 21 '16 22:04 nortonsm

Thanks, nortonsm! Is it ok if I add your approach to the docs?

kbrafford avatar Apr 21 '16 23:04 kbrafford

I've tried the above solution from nortonsm, which didn't do anything for me, as I already had the package installed (although I did overwrite, just in case), and I set the environment variables and still the same issue. I modified it for the 32-bit version first, which didn't help, then the 64-bit, which also didn't work. Any suggestions? I'm mega keen to have python control with a USB3 camera.

fonty422 avatar Jun 01 '16 11:06 fonty422

@fonty422 : So if you launch a CMD window from the Start program menu: Microsoft Visual C++ Compiler for Python 2.7 -> Visual C++ 2008 32-bit Command Prompt Then change to the pyfly2-master directory, I get this:

C:\Users\user\Downloads\pyfly2-master-original>cd pyfly2-master

C:\Users\user\Downloads\pyfly2-master-original\pyfly2-master>python setup.py build_ext --inplace
running build_ext
cythoning pyfly2.pyx to pyfly2.c
building 'pyfly2' extension
error: Unable to find vcvarsall.bat

C:\Users\user\Downloads\pyfly2-master-original\pyfly2-master>set distutils_use_sdk=1

C:\Users\user\Downloads\pyfly2-master-original\pyfly2-master>set MSSdk=1

C:\Users\user\Downloads\pyfly2-master-original\pyfly2-master>python setup.py build_ext --inplace
running build_ext
skipping 'pyfly2.c' Cython extension (up-to-date)
building 'pyfly2' extension
creating build
creating build\temp.win32-2.7
creating build\temp.win32-2.7\Release
C:\Users\user\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe /c /nologo /Ox /MD /W3 /GS-
 /DNDEBUG -I. "-IC:/Program Files (x86)/Point Grey Research/FlyCapture2\include" -IC:\Python27\include -IC:\Python27\PC /
Tcpyfly2.c /Fobuild\temp.win32-2.7\Release\pyfly2.obj
pyfly2.c
C:\Users\user\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\link.exe /DLL /nologo /INCREMENTAL
:NO "/LIBPATH:C:/Program Files (x86)/Point Grey Research/FlyCapture2\lib/C" /LIBPATH:C:\Python27\libs /LIBPATH:C:\Python2
7\PCbuild FlyCapture2_Cd_v90.lib /EXPORT:initpyfly2 build\temp.win32-2.7\Release\pyfly2.obj /OUT:C:\Users\user\Downloads\
pyfly2-master-original\pyfly2-master\pyfly2.pyd /IMPLIB:build\temp.win32-2.7\Release\pyfly2.lib /MANIFESTFILE:build\temp.
win32-2.7\Release\pyfly2.pyd.manifest
   Creating library build\temp.win32-2.7\Release\pyfly2.lib and object build\temp.win32-2.7\Release\pyfly2.exp

C:\Users\user\Downloads\pyfly2-master-original\pyfly2-master>

So it fails until I issue the two SET commands above. Can you provide a similar output of your error? Maybe there's some subtlelty that's different... -Scott

nortonsm avatar Jun 01 '16 15:06 nortonsm

Sure. I hadn't realised I needed to set those specifically while in the correct folder. That has cleared the inability to find varsall.bat but has left me with a new error:

C:\Users\debooyj\AppData\Local\Continuum\Anaconda\Lib\site-packages\pyfly2-maste
r>python setup.py build_ext --inplace
running build_ext
skipping 'pyfly2.c' Cython extension (up-to-date)
building 'pyfly2' extension
creating build
creating build\temp.win-amd64-2.7
creating build\temp.win-amd64-2.7\Release
C:\Users\debooyj\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9
.0\VC\Bin\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -I. "-IC:/Program Files/Po
int Grey Research/FlyCapture2\include" -IC:\Users\debooyj\AppData\Local\Continuu
m\Anaconda\include -IC:\Users\debooyj\AppData\Local\Continuum\Anaconda\PC /Tcpyf
ly2.c /Fobuild\temp.win-amd64-2.7\Release\pyfly2.obj
pyfly2.c
C:\Users\debooyj\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9
.0\VC\Bin\link.exe /DLL /nologo /INCREMENTAL:NO "/LIBPATH:C:/Program Files/Point
 Grey Research/FlyCapture2\lib64/C" /LIBPATH:C:\Users\debooyj\AppData\Local\Cont
inuum\Anaconda\libs /LIBPATH:C:\Users\debooyj\AppData\Local\Continuum\Anaconda\P
Cbuild\amd64 /LIBPATH:C:\Users\debooyj\AppData\Local\Continuum\Anaconda\PC\VS9.0
\amd64 FlyCapture2_Cd_v90.lib /EXPORT:initpyfly2 build\temp.win-amd64-2.7\Releas
e\pyfly2.obj /OUT:C:\Users\debooyj\AppData\Local\Continuum\Anaconda\Lib\site-pac
kages\pyfly2-master\pyfly2.pyd /IMPLIB:build\temp.win-amd64-2.7\Release\pyfly2.l
ib /MANIFESTFILE:build\temp.win-amd64-2.7\Release\pyfly2.pyd.manifest
python27.lib(python27.dll) : fatal error LNK1112: module machine type 'x64' conf
licts with target machine type 'X86'
error: command 'C:\\Users\\debooyj\\AppData\\Local\\Programs\\Common\\Microsoft\
\Visual C++ for Python\\9.0\\VC\\Bin\\link.exe' failed with exit status 1112

C:\Users\debooyj\AppData\Local\Continuum\Anaconda\Lib\site-packages\pyfly2-maste
r>

fonty422 avatar Jun 01 '16 16:06 fonty422

It looks like you are trying to build a 64-bit version, but pyfly2 is a 32-bit library.

kbrafford avatar Jun 03 '16 16:06 kbrafford

Ah, that makes sense. Following this, I tried another package and had success with pyflycapture2 and it works well. I just had to make a few changes to the wrapper to account for full color images.

fonty422 avatar Jun 08 '16 22:06 fonty422