Skip to content

fcntl error on windows #509

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
stranac opened this issue Mar 15, 2015 · 11 comments
Closed

fcntl error on windows #509

stranac opened this issue Mar 15, 2015 · 11 comments

Comments

@stranac
Copy link

stranac commented Mar 15, 2015

Getting the following error when running bpython-curses:

Traceback (most recent call last):
  File "C:\Python27\lib\runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "C:\Python27\lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "C:\Python27\Scripts\bpython-curses.exe\__main__.py", line 5, in <module>
  File "C:\Python27\lib\site-packages\bpython\cli.py", line 84, in <module>
    from bpython import repl
  File "C:\Python27\lib\site-packages\bpython\repl.py", line 56, in <module>
    from bpython.history import History
  File "C:\Python27\lib\site-packages\bpython\history.py", line 34, in <module>
    from bpython.filelock import FileLock
  File "C:\Python27\lib\site-packages\bpython\filelock.py", line 33, in <module>
    class FileLock(object):
  File "C:\Python27\lib\site-packages\bpython\filelock.py", line 39, in FileLock
    def __init__(self, fd, mode=fcntl.LOCK_EX):
NameError: name 'fcntl' is not defined

This is due to fcntl not being defined on windows, and default arguments being evaluated on definition time.

@thomasballinger
Copy link
Member

Ha I just wrote the same code :)

sebastinas added a commit that referenced this issue Mar 15, 2015
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
(cherry picked from commit e83fb4a)
@den-run-ai
Copy link

even on bpython master still this error, but in blessings packages:

$ bpython
Traceback (most recent call last):
  File "c:\python\python27\envs\py34\lib\runpy.py", line 170, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\python\python27\envs\py34\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Python\Python27\envs\py34\Scripts\bpython.exe\__main__.py", line 5, in <module>
  File "c:\python\python27\envs\py34\lib\site-packages\bpython\curtsies.py", line 9, in <module>
    import curtsies
  File "c:\python\python27\envs\py34\lib\site-packages\curtsies\__init__.py", line 4, in <module>
    from .window import FullscreenWindow, CursorAwareWindow
  File "c:\python\python27\envs\py34\lib\site-packages\curtsies\window.py", line 30, in <module>
    import blessings
  File "c:\python\python27\envs\py34\lib\site-packages\blessings\__init__.py", line 7, in <module>
    from fcntl import ioctl
ImportError: No module named 'fcntl'

@den-run-ai
Copy link

this is a deeper issue with blessing/fcntrl:

erikrose/blessings#21

@den-run-ai
Copy link

ok, installed curses from this link below and bpython from master and now 'bpython-curses' works!

http://www.lfd.uci.edu/~gohlke/pythonlibs/#curses

http://docs.bpython-interpreter.org/windows.html

@carlosperate
Copy link

I'm using Python 3.5.2 32 bit on Windows 7 x64, have installed curses and pyreadline as indicated in the readme and I am encountering the same problem with fcntl:

Traceback (most recent call last):
  File "C:\Python35\Lib\runpy.py", line 184, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Python35\Lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\atencioc\Envs\py3bpy\Scripts\bpython.exe\__main__.py", line 5, in <module>
  File "c:\users\atencioc\envs\py3bpy\lib\site-packages\bpython\curtsies.py", line 9, in <module>
    import curtsies
  File "c:\users\atencioc\envs\py3bpy\lib\site-packages\curtsies\__init__.py", line 4, in <module>
    from .window import FullscreenWindow, CursorAwareWindow
  File "c:\users\atencioc\envs\py3bpy\lib\site-packages\curtsies\window.py", line 11, in <module>
    import blessings
  File "c:\users\atencioc\envs\py3bpy\lib\site-packages\blessings\__init__.py", line 7, in <module>
    from fcntl import ioctl
ImportError: No module named 'fcntl'

pip freeze:

blessings==1.6
bpython==0.16
curses==2.2
curtsies==0.2.11
greenlet==0.4.10
Pygments==2.1.3
pyreadline==2.1
requests==2.11.1
six==1.10.0
wcwidth==0.1.7
wheel==0.24.0

@thomasballinger
Copy link
Member

@carlosperate, because of the Blessings dependency problem described upthread erikrose/blessings#21, only bpython-curses works properly on Windows right now.

@carlosperate
Copy link

If that's a known problem and there is a known workaround why are the instructions for Windows still incorrect? I'm away for a few days, so I can't test it, but sounds like the only fix I need to do is to install a different package than the one listed on the README?

@thomasballinger
Copy link
Member

Nothing different to install, you'll want to run a different executable, bpython-curses instead of bpython. We should absolutely update the readme since it's been a while and erikrose/blessings#21 hasn't been fixed. Created #649 for this.

@carlosperate
Copy link

Oh, I see, thanks for the clarification and opeoenin the other issue
Thomas!

On 28 Oct 2016 21:11, "Thomas Ballinger" notifications@github.com wrote:

Nothing different to install, you'll want to run a different executable,
bpython-curses instead of bpython. We should absolutely update the readme
since it's been a while and erikrose/blessings#21
erikrose/blessings#21 hasn't been fixed.
Created #649 #649 for this.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#509 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AD_sTiLvBTsREVq9J1SXWniZRSGad6Ihks5q4lcOgaJpZM4Du-vU
.

@johnd0e
Copy link

johnd0e commented Jun 14, 2021

I don't think you can get fcntl on Windows.

But according https://stackoverflow.com/review/suggested-edits/18134290 you can put such stub to Libs directory:

# Variables with simple values

FASYNC = 64

FD_CLOEXEC = 1

F_DUPFD = 0
F_FULLFSYNC = 51
F_GETFD = 1
F_GETFL = 3
F_GETLK = 7
F_GETOWN = 5
F_RDLCK = 1
F_SETFD = 2
F_SETFL = 4
F_SETLK = 8
F_SETLKW = 9
F_SETOWN = 6
F_UNLCK = 2
F_WRLCK = 3

LOCK_EX = 2
LOCK_NB = 4
LOCK_SH = 1
LOCK_UN = 8

def fcntl(fd, op, arg=0):
    return 0
        
def ioctl(fd, op, arg=0, mutable_flag=True):
    if mutable_flag:
        return 0
    else:
        return ""
    
def flock(fd, op):
    return
        
def lockf(fd, operation, length=0, start=0, whence=0):
    return

Alternatively: use blessedinstead of blessings.

Alternatively: use pip install windows-curses (instead of curses from http://www.lfd.uci.edu/~gohlke/pythonlibs/#curses)

@abubelinha
Copy link

Nothing different to install, you'll want to run a different executable, bpython-curses instead of bpython. We should absolutely update the readme since it's been a while and erikrose/blessings#21 hasn't been fixed. Created #649 for this.

@thomasballinger I followed your instructions
But still getting errors when trying to run bpython-curses (same result if I try bpython).
I installed curses-2.2.1+utf8-cp38-cp38-win_amd64.whl.
I am on Windows 7 64bit, Python 3.8:

C:\Python38\scripts\pip install C:\soft\Python\wheels\curses-2.2.1+utf8-cp38-cp38-win_amd64.whl
Processing c:\soft\python\wheels\curses-2.2.1+utf8-cp38-cp38-win_amd64.whl
Installing collected packages: curses
Successfully installed curses-2.2.1+utf8

C:\Python38\scripts\pip install bpython
(...)
Successfully installed bpython-0.22.1

c:\Python38\scripts\bpython-curses
Traceback (most recent call last):
  File "c:\python38\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\python38\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:Python38\scripts\bpython-curses.exe\__main__.py", line 4, in <module>
  File "c:python38\lib\site-packages\bpython\cli.py", line 71, in <module>
    from .config import getpreferredencoding
  File "c:python38\lib\site-packages\bpython\config.py", line 38, in <module>
    from .curtsiesfrontend.parse import CNAMES
  File "c:\python38\lib\site-packages\bpython\curtsiesfrontend\parse.py", line 3, in <module>
    from curtsies.formatstring import fmtstr, FmtStr
  File "c:\python38\lib\site-packages\curtsies\__init__.py", line 4, in <module>
    from .window import FullscreenWindow, CursorAwareWindow
  File "c:\python38\lib\site-packages\curtsies\window.py", line 24, in <module>
    import blessings
  File "c:\python38\lib\site-packages\blessings\__init__.py", line 7, in <module>
    from fcntl import ioctl
ModuleNotFoundError: No module named 'fcntl'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants