AttributeError: 'module' object has no attribute 'flock'

If you try installing Plone on an IBM Thinkpad or PC, its Python install conflicts with the Plone one.

On new IBM factory PCs, you will often find an installation of an "IBM Tools" suite. This suite is installed with its own version of Python (python22 in our case). As a result, Python22 is referenced in the System Path.

The solution to this particular problem is to remove all references to the previous Python installation (including Path, PYTHONCASEOK, PYTHONPATH Environment variables, %SystemRoot%\system32 pythonXX.dll's). Only when all references are removed (and you uninstall/reinstall) will the Plone installation be successful.

Note: Simply removing references and attempting to run an already installed instance of Plone will fail.

For reference, we are attaching the error string received when we would run runzope.bat before the problem was fixed:

  C:\Program Files\Plone 2\Data\bin>runzope

  C:\Program Files\Plone 2\Data\bin>"C:\Program Files\Plone
  2\Python\python.exe" "<br>
  C:\Program Files\Plone 2\Zope\lib\python\Zope\Startup\run.py" -C
  "C:\Program Files\Plone 2\Data\etc\zope.conf"<br>
  C:\Program Files\Plone 2\Python\lib\fcntl.py:7: DeprecationWarning: the
  FCNTL module is deprecated; please use fcntl DeprecationWarning)

  Traceback (most recent call last):
   File "C:\Program Files\Plone 2\Zope\lib\python\Zope\Startup\run.py",line 49, 
   in run()
  File "C:\Program Files\Plone 2\Zope\lib\python\Zope\Startup\run.py",
   line 19,in run start_zope(opts.configroot)<br>File "C:\Program Files\Plone
  2\Zope\lib\python\Zope\Startup\__init__.py", line
   49, in start_zope<br>starter.makeLockFile()
  File "C:\Program Files\Plone 2\Zope\lib\python\Zope\Startup\__init__.py",
   line 251, in makeLockFile<br>lock_file(self.lockfile)
  File "C:\Program Files\Plone 2\Zope\lib\python\Zope\Startup\misc\lock_file.py",
   line 40, in lock_file<br>fcntl.flock(file, fcntl.LOCK_EX | fcntl.LOCK_NB)

  AttributeError: 'module' object has no attribute 'flock'

Also...

Posted by J. Cameron Cooper at Jun 17, 2005 04:53 PM
I've also found that I can remove the C:\Program Files\Plone 2\Python\lib\FCNTL.pyc file, which will allow startup. However, this will reappear each time.

See also:

http://mail.zope.org/[…]/005130.html

esp. comment 5. I don't recall if only fixing PYTHONCASEOK works.

more on fcntl.pyc

Posted by modfather at Jun 18, 2005 03:40 AM
After 3 hours of wrestling with this very problem and deleting all the Windows Environment Variables that pointed to the Python2.2 instance, I actually removed the fcntl.pyc from the C:\IBMTOOLS\Python22\lib (or maybe bin) directory, not from the Plone path. This finally got me past the "connection refused by localhost" error message...but strangely, all I got when loading http://localhost was a "Welcome to Zope" page, not the usual default Plone site page. So then I went to the ZMI (http://localhost:8080/manage), only to discover I didn't have a Plone instance at all. Very weird, since I'd used the packaged installer. At this point, I had to create a Plone Site using the ZMI drop-down Add menu.

So it seems you really should check your C: drive for the IBMTOOLS directory if attempting to install Plone on an IBM ThinkPad or ThinkCentre tower (among other models). You'll save yourself a lot of frustration by removing all the Python-related Environment Variables first, then moving or deleting the existing fnctl.pyc file. Caveat: doing this may corrupt the pre-installed IBM toolset...much of which you may never need.

Another error message

Posted by Hanno Schlichting at Apr 07, 2006 08:04 AM
Somebody reported to get the following error while trying to install Plone, which was also caused by the IBM Tools:

Executing the command 'setupSite.py' failed SchemaError?: could not load package ZServer: <exceptions.ImportError? instance at 0x00B42990>