42

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
  • 723
  • 2
  • 6
  • 11

3 Answers3

41

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.

  • thank you for the reply. I have downloaded the above, but now I am having trouble figuring out how to use it. – yome Jul 22 '17 at 06:17
  • Do I understand it properly that I cannot do a non-blocking read from a pipe on Windows in this "language"? – Palo Nov 08 '20 at 15:34
4

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
  • 1
    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
0

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
  • 4
    `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
  • this is not working as @cactuschibre said :( – Tony Feb 10 '22 at 23:47