2

My app needs to monitor a filesystem and respond when files are added or changed. I'm running Python 3.3 and reading through the package list, "watcher" looks like just what I need, except that all the install executables at https://pypi.python.org/pypi/watcher/0.2.1 are for Python 3.2 and below and for Win32 (I'm on Win64). I tried install with pip and easy_install but got an error "Unable to find vcvarsall.bat" which from looking at the archives is nontrivial to resolve. Any recommendations on installing watcher or perhaps another system monitoring package would be much appreciated.

Lev Levitsky
  • 63,701
  • 20
  • 147
  • 175
buttonsrtoys
  • 2,359
  • 3
  • 32
  • 52
  • It was last updated in 2011, so it may not be a really good choice. In this [answer](http://stackoverflow.com/questions/597903/monitoring-files-directories-with-python) [`watchdog`](https://github.com/gorakhargosh/watchdog/) is mentioned, which, at least, seems updated recently. – Bakuriu Jun 03 '13 at 18:01
  • @Bakuriu Thanks for the thought. Watchdog looks great but it's only compatible with Python 2.5 & before. I tried it before trying Watcher and posted my issue [here](http://stackoverflow.com/questions/16863075/how-to-do-notifications-with-python-3-3). – buttonsrtoys Jun 04 '13 at 13:19
  • Well, I just patched it to hopefully work on python3.3, I submitted a pull request, guess we'll see if it is still being maintained... – Perkins Jun 05 '13 at 06:40

1 Answers1

2

The mention of vcvarsall.bat means it is trying to compile some C or C++ code and needs a compiler. The default compiler for python on windows is MSVC, you can also use MinGW for most packages, but you'll need to install one of them and get them on the path in order to proceed.

It seems you can't use the pyd compiled with python3.2 with python3.3, you weren't missing anything, and it didn't work for me either.

I just went through getting it to work with mingw32, and it's pretty simple once you figure it all out. If you trust me, I've put a binary copy of the module here, if you download it, make sure to run a virus scan on it since it is coming out of an unpatched XP VM. Also note it might not work without some additional libraries, but I don't have a second machine to try it on. If it doesn't work, but you get a list of the libraries you're missing, I can help you find them.

To build it yourself, you can use msvc, (about which I know nothing), or mingw. You can get mingw here. When you go through the installer, make sure to install at least the C compiler and msys. You'll need a patched version of the watcher source, to give the compiler the correct arguments and to make it work with python3.3. You can get that here. You'll need to edit the setup file yourself to update the location of your mingw install, lines 19 and 20 are the important ones. Once it is all setup, you should be able to call \Path\To\Python3\python setup.py build -cmingw32 followed by \path\to\python3\python setup.py install. If it complains about not being able to find a header file (ends in .h), search for it on your computer and add its location to the list on line 19. If ld.exe fails to find a library, look for the library name, you want the file ending in .a, add it's location to the list on line 20, note you'll need -I and -L in each string. Once that is done, you should be able to launch watcher.

Note that it requires a callback function with exactly 2 arguments more than the argument list you provide and fails without explaining why if you get the number of arguments wrong.

Perkins
  • 2,409
  • 25
  • 23
  • If the second idea doesn't work, or you want help compilig it yourself on windows, let me know. – Perkins Jun 04 '13 at 04:53
  • Many thanks. I followed your second idea and manually extracted the archive. I then moved its contents to my Python33/Lib/site-packages folder. The package has its init file, so appears complete, but when I run its test_watcher.py script Python doesn't recognize the watcher module. Did I miss a step? (This is my first attempt at a manual install.) – buttonsrtoys Jun 04 '13 at 12:58
  • Okay, looks like there is some incompatible library between 3.2 and 3.3. I'll update my answer – Perkins Jun 05 '13 at 05:49
  • Wow! Many thanks for the efforts. I downloaded and installed your binary. The test program finds it, but the Python shell gives the following error: Traceback (most recent call last): File "C:\Program Files\Python33\Lib\site-packages\watcher\tests\test_watcher.py", line 11, in import watcher File "C:\Program Files\Python33\lib\site-packages\watcher\__init__.py", line 1, in from ._watcher import * ImportError: DLL load failed: %1 is not a valid Win32 application. – buttonsrtoys Jun 14 '13 at 13:00
  • Hm... I compiled it with 32 bit windows XP. I ran dependancy walker (from http://dependencywalker.com/ ) on it and I don't see anything that you are certain to be missing. I would recommend downloading depends.exe and running it on _watcher.pyd, it will tell you what `DLL`s it needs and which, if any, are missing. If it says msjava.dll or mpr.dll are missing, that's fine, but if anything else is missing, let me know which and we can figure out where to get it. If it says everything is good, you'll probably need to bite the bullet and compile it yourself since I don't know what else to try. – Perkins Jun 15 '13 at 05:08