64

I get the following error:

Traceback (most recent call last):
  File "C:/Users/aaaa/Desktop/ttttttt.py", line 5, in <module>
   import reload
  File "C:\Users\aaa\AppData\Local\Programs\Python\Python36\lib\site-
packages\reload.py", line 3, in <module>
    import sys, time, re, os, signal, fcntl
ModuleNotFoundError: No module named 'fcntl'

So I did a pip install, which also gets an error.

    C:\Users\aaaa>pip install fcntl
    Collecting fcntl
      Could not find a version that satisfies the requirement fcntl (from versions: )
No matching distribution found for fcntl

Search results cPython, hacking, routing and many other words are coming out.

It's a tough answer for beginners, so I want to get a more detailed solution.

How should I solve it?

#py3
import time
from selenium import webdriver
import codecs
import sys
import reload
import re
import fcntl
import os
import signal
yome
  • 953
  • 2
  • 7
  • 11

4 Answers4

56

The fcntl module is not available on Windows. The functionality it exposes does not exist on that platform.

If you're trying to lock a file, there are some other Python modules available which provide that functionality. One I've seen referenced in other answers is portalocker.

30

I got the same error when trying to run my flask app using gunicorn.

gunicorn --bind 127.0.0.1:5000 predict:app

The issue is that 'fcntl' is not available on windows. The alternative that can be used, as suggested by Alexey Grigorov in Ml bookcamp, is the 'waitress' package.

pip install waitress

Then write in the command prompt the following command.

waitress-serve --listen=127.0.0.1:5000 predict:app

For those still looking for the answer.

Iftikhar Ud Din
  • 341
  • 3
  • 5
1

I got some info from this website https://pypi.org/project/micropython-fcntl/#files and installed as follows which solved the problem:

pip install micropython-fcntl
  • 9
    `ERROR: File "setup.py" or "setup.cfg" not found for legacy project micropython-fcntl from https://files.pythonhosted.org/packages/c9/65/f233834bc23621c1a8da644bd1d70cbe5c344bd2dd2b9d424f1f116363ec/micropython-fcntl-0.0.4.tar.gz#sha256=6ce976b79c16084485894e4284c54263c0cc775cf6b4a6fd3bf1d83f29ddf6a1.` :( – cactuschibre Jun 02 '21 at 12:53
  • 3
    this is not working as @cactuschibre said :( – Tony Feb 10 '22 at 23:47
  • `ERROR: micropython-fcntl from https://files.pythonhosted.org/packages/c9/65/f233834bc23621c1a8da644bd1d70cbe5c344bd2dd2b9d424f1f116363ec/micropython-fcntl-0.0.4.tar.gz does not appear to be a Python project: neither 'setup.py' nor 'pyproject.toml' found.` –  Apr 13 '23 at 04:50
  • I am getting the same error as above :( – Sameer Mahajan Jun 07 '23 at 11:12
-2

What you can do is install importlib with the usual:

pip install importlib

From there use the following:

from importlib import reload

Note that you will need to load your imports as 'modules':

from petshop import parrot as parrot
  • 8
    I'm not following how this answer relates to the question. `importlib.reload()` can be used to reload a module. The user's question is related to "`fcntl` doesn't exist on windows". How do you reload a module that isn't even isntalled because it doesn't exist? – bobpaul Sep 25 '21 at 18:45
  • Besides answering the wrong question, `importlib` needs no pip install in anything released in the last decade (this answer was already obsolete when posted). – Andras Deak -- Слава Україні Feb 13 '23 at 15:03