{"id":408,"date":"2020-04-23T14:33:57","date_gmt":"2020-04-23T06:33:57","guid":{"rendered":"https:\/\/blog.humh.cn\/?p=408"},"modified":"2020-04-23T14:36:16","modified_gmt":"2020-04-23T06:36:16","slug":"%e8%a7%a3%e5%86%b3modulenotfounderror-no-module-named-fcntl","status":"publish","type":"post","link":"https:\/\/blog.humh.cn\/?p=408","title":{"rendered":"\u89e3\u51b3ModuleNotFoundError: No module named 'fcntl'"},"content":{"rendered":"\n<h4>\u95ee\u9898<\/h4>\n\n\n\n<p>py\u4e2d\u5f15\u5165\u4e86fcntl\uff0c<code>import fcntl<\/code>\u3002\u5f53\u5728windows\u7cfb\u7edf\u4e0b\u8fd0\u884c\u8be5py\u65f6\uff0c\u62a5\u9519\u201c<strong>ModuleNotFoundError: No module named &#8216;fcntl&#8217;<\/strong>\u201d\u3002<\/p>\n\n\n\n<h4>\u539f\u56e0<\/h4>\n\n\n\n<p><strong>fcntl<\/strong>\u4e3apython\u6807\u51c6\u5e93\u4e2d\u7684\u4e00\u4e2a\u6a21\u5757\uff0c\u5c5e\u4e8eUnix Specific\uff0c\u8d1f\u8d23\u64cd\u4f5c\u6587\u4ef6\u9501\uff08<a href=\"https:\/\/docs.python.org\/3\/library\/fcntl.html\">https:\/\/docs.python.org\/3\/library\/fcntl.html<\/a>\uff09\u3002\u5f53\u4f7f\u7528python\u8fdb\u884c\u5199\u6587\u4ef6\u65f6\uff0c\u5982\u679c\u591a\u4e2a\u8fdb\u7a0b\u540c\u65f6\u5199\u540c\u4e00\u4e2a\u6587\u4ef6\uff0c\u90a3\u4e48\u53ef\u80fd\u4f1a\u5b58\u5728\u95ee\u9898\uff0cfcntl\u5c31\u662f\u7528\u6765\u907f\u514d\u8fd9\u4e2a\u95ee\u9898\uff0c\u4f7f\u7528\u7cfb\u7edf\u9501\u7684\u673a\u5236\u6765\u4fdd\u8bc1\u540c\u65f6\u53ea\u6709\u4e00\u4e2a\u8fdb\u7a0b\u5199\u6587\u4ef6\u3002\u5f88\u663e\u7136\uff0c<strong>\u8fd9\u4e2a\u6a21\u5757\u662f\u4e3alinux\u7cfb\u7edf\u51c6\u5907\uff0cwindows python\u4e2d\u662f\u4e0d\u81ea\u5e26\u7684<\/strong>\uff0c\u6240\u4ee5\u5f53\u6211\u4eec\u5728windows\u4e2d\u8fd0\u884c\u4f7f\u7528\u4e86fcntl\u6a21\u5757\u7684py\u65f6\uff0c\u5c31\u4f1a\u62a5\u9519\uff0c\u6a21\u5757\u65e0\u6cd5\u627e\u5230\u3002<\/p>\n\n\n\n<h4>\u89e3\u51b3\u529e\u6cd5<\/h4>\n\n\n\n<p>\u7531\u4e8e\u4e00\u822c\u6211\u4eec\u7684\u9879\u76ee\u90fd\u662f\u76f4\u63a5\u653e\u5230linux\u73af\u5883\u4e0b\u53bb\u8dd1\u7684\uff0c\u6240\u4ee5\u4e0d\u7275\u626f\u95ee\u9898\u3002\u4f46\u6211\u4eec\u65e5\u5e38\u5f00\u53d1\u90fd\u4f1a\u5728windows ide\u4e2d\u53bb\u8dd1\u3002\u6211\u4eec\u53ef\u80fd\u5e76\u4e0d\u9700\u8981\u5728windows\u4e0b\u5b9e\u73b0\u6587\u4ef6\u9501\uff0c\u6240\u4ee5\u8fd9\u91cc\u6211\u4eec\u53ea\u9700\u8981\u4fdd\u8bc1\u80fd\u591f\u6b63\u5e38\u52a0\u8f7d<strong>fcntl<\/strong>\u6a21\u5757\u5373\u53ef\u3002\u8fd9\u91cc\u901a\u8fc7<strong>mock<\/strong>\u4e00\u4e2a\u5047\u7684<strong>fcntl.py<\/strong>\u653e\u5230python\u5e93\u4e2d\u5373\u53ef\u3002<\/p>\n\n\n\n<p><strong>1\u3001\u521b\u5efafcntl.py<\/strong><br>fcntl.py\u4ee3\u7801\u5982\u4e0b<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">def fcntl(fd, op, arg=0):\n    return 0\n\ndef ioctl(fd, op, arg=0, mutable_flag=True):\n    if mutable_flag:\n        return 0\n    else:\n        return \"\"\n\ndef flock(fd, op):\n    return\n\ndef lockf(fd, operation, length=0, start=0, whence=0):\n    return<\/pre>\n\n\n\n<p><strong>2\u3001\u5c06fcntl.py \u653e\u5165Python Lib\u4e2d<\/strong><\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"https:\/\/file.blog.humh.cn\/2020\/04\/\u56fe\u7247-29.png\"><img width=\"660\" height=\"383\" class=\"wp-image-409 lazyload\" title=\"\u89e3\u51b3ModuleNotFoundError: No module named 'fcntl'\" src=\"data:image\/gif;base64,R0lGODlhAgABAIAAALGxsQAAACH5BAAAAAAALAAAAAACAAEAAAICBAoAOw==\" data-src=\"https:\/\/file.blog.humh.cn\/2020\/04\/\u56fe\u7247-29.png\" alt=\"https:\/\/file.blog.humh.cn\/2020\/04\/\u56fe\u7247-29.png\" data-srcset=\"https:\/\/file.blog.humh.cn\/wp-content\/uploads\/2020\/04\/\u56fe\u7247-29.png 660w, https:\/\/file.blog.humh.cn\/wp-content\/uploads\/2020\/04\/\u56fe\u7247-29-300x174.png 300w\" sizes=\"(max-width: 660px) 100vw, 660px\"><\/a><\/figure><\/div>\n\n\n\n<p>\u5982\u4e0a\u56fe\uff0c\u201cC:\\Program Files\\Python\\Python36\u201d \u4e3a\u6211 python3.6.9\u7684\u5b89\u88c5\u8def\u5f84\uff0c\u5c06fcntl.py\u653e\u5165\u5176\u4e2d<strong>Lib<\/strong>\u76ee\u5f55\u4e0b\u5373\u53ef\u3002\u518d\u6b21\u8fd0\u884cpy\u65e0\u8bef\u3002<br>\u8bf4\u660e\uff1a<strong>Lib<\/strong>\u4e3apython\u7684\u9ed8\u8ba4\u6807\u51c6\u5e93\uff0c\u5728\u8fd0\u884cpy\u65f6\u4f1a\u88ab\u52a0\u8f7d\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"https:\/\/file.blog.humh.cn\/2020\/04\/\u56fe\u7247-30.png\"><img width=\"545\" height=\"273\" class=\"wp-image-410 lazyload\" title=\"\u89e3\u51b3ModuleNotFoundError: No module named 'fcntl'\" src=\"data:image\/gif;base64,R0lGODlhAgABAIAAALGxsQAAACH5BAAAAAAALAAAAAACAAEAAAICBAoAOw==\" data-src=\"https:\/\/file.blog.humh.cn\/2020\/04\/\u56fe\u7247-30.png\" alt=\"https:\/\/file.blog.humh.cn\/2020\/04\/\u56fe\u7247-30.png\" data-srcset=\"https:\/\/file.blog.humh.cn\/wp-content\/uploads\/2020\/04\/\u56fe\u7247-30.png 545w, https:\/\/file.blog.humh.cn\/wp-content\/uploads\/2020\/04\/\u56fe\u7247-30-300x150.png 300w\" sizes=\"(max-width: 545px) 100vw, 545px\"><\/a><\/figure><\/div>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u95ee\u9898 py\u4e2d\u5f15\u5165\u4e86fcntl\uff0cimport fcntl\u3002\u5f53\u5728windows\u7cfb\u7edf\u4e0b\u8fd0\u884c\u8be5py\u65f6\uff0c\u62a5\u9519\u201cModul [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[66],"tags":[65],"_links":{"self":[{"href":"https:\/\/blog.humh.cn\/index.php?rest_route=\/wp\/v2\/posts\/408"}],"collection":[{"href":"https:\/\/blog.humh.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.humh.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.humh.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.humh.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=408"}],"version-history":[{"count":2,"href":"https:\/\/blog.humh.cn\/index.php?rest_route=\/wp\/v2\/posts\/408\/revisions"}],"predecessor-version":[{"id":412,"href":"https:\/\/blog.humh.cn\/index.php?rest_route=\/wp\/v2\/posts\/408\/revisions\/412"}],"wp:attachment":[{"href":"https:\/\/blog.humh.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=408"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.humh.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=408"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.humh.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=408"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}