Error: No module named 'fcntl'

Viewed 129513

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
4 Answers

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

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.

Related