﻿{"id":1444,"date":"2023-04-28T14:15:43","date_gmt":"2023-04-28T06:15:43","guid":{"rendered":"https:\/\/www.tansoo.cn\/?p=1444"},"modified":"2023-04-28T14:15:43","modified_gmt":"2023-04-28T06:15:43","slug":"phpbb-71","status":"publish","type":"post","link":"https:\/\/www.tansoo.cn\/?p=1444","title":{"rendered":"Delphi P4D Error 87: Could not open Dll &#8220;python33.dll&#8221;"},"content":{"rendered":"<p><a href=\"https:\/\/github.com\/pyscripter\/python4delphi\/wiki\/FindingPython\" class=\"postlink\">https:\/\/github.com\/pyscripter\/python4de &#8230; dingPython<\/a><\/p>\n<p>Python for Delphi \u5982\u4f55\u5728 Windows \u4e2d\u627e\u5230\u60a8\u7684 Python \u53d1\u884c\u7248<br \/>\n\u8981\u4f7f\u7528Python for Delphi\uff0c\u60a8\u9700\u8981\u4e0b\u8f7d\u5e76\u5b89\u88c5python\u3002\u6709\u8bb8\u591a\u4e0d\u540c\u7684python\u53d1\u884c\u7248\uff0c\u6700\u5e38\u89c1\u7684\u662f\u6765\u81ea <a href=\"http:\/\/www.python.org\" class=\"postlink\">www.python.org<\/a> \u6216\u7528\u4e8e\u6570\u636e\u5206\u6790\u7684Anaconda\u53d1\u884c\u7248\u3002<\/p>\n<p>\u5df2\u6ce8\u518c\u4e0e\u672a\u6ce8\u518c<br \/>\n\u5728 Windows \u4e2d\u5b89\u88c5 Python \u65f6\uff0c\u53ef\u4ee5\u9009\u62e9\u4e3a\u6240\u6709\u7528\u6237\u6216\u5f53\u524d\u7528\u6237\u6ce8\u518c\u5b83\u3002\u6ce8\u518c\u6d89\u53ca\u5411\u6ce8\u518c\u8868\u5199\u5165\u6709\u5173\u5b89\u88c5\u4f4d\u7f6e\u3001\u5e2e\u52a9\u6587\u4ef6\u7684\u540d\u79f0\u548c\u4f4d\u7f6e\u7b49\u4fe1\u606f\u3002<\/p>\n<p>\u8bbe\u7f6e PythonEngine \u7684\u5c5e\u6027<br \/>\n\u5982\u679c\u8981\u4f7f\u7528\u5df2\u5b89\u88c5\u7684\u6700\u65b0\u6ce8\u518c\u7684 Python \u7248\u672c<br \/>\n\u5c06\u201c\u4f7f\u7528\u4e0a\u6b21\u5df2\u77e5\u7248\u672c\u201d\u5c5e\u6027\u8bbe\u7f6e\u4e3a True<br \/>\n\u5982\u679c\u9700\u8981\u7279\u5b9a\u7684\u6ce8\u518c\u7248\u672c\uff0c\u5219\u9700\u8981\u8bbe\u7f6e\u4ee5\u4e0b\u5c5e\u6027\uff1a<br \/>\nDLLName \u4f8b\u5982 python38.dll<br \/>\n\u6ce8\u518c\u8868\u7248\u672c\uff0c\u4f8b\u5982 3.8<br \/>\n\u5c06\u201c\u4f7f\u7528\u4e0a\u4e00\u4e2a\u5df2\u77e5\u7248\u672c\u201d\u5c5e\u6027\u8bbe\u7f6e\u4e3a False<br \/>\n\u5982\u679c\u8981\u4f7f\u7528\u7279\u5b9a\u7684\u672a\u6ce8\u518c\u7248\u672c\uff0c\u8bf7\u8bbe\u7f6e\u4ee5\u4e0b\u5c5e\u6027<br \/>\nDLLName \u4f8b\u5982 python38.dll<br \/>\n\u6ce8\u518c\u8868\u7248\u672c\uff0c\u4f8b\u5982 3.8<br \/>\n\u5c06\u201c\u4f7f\u7528\u4e0a\u4e00\u4e2a\u5df2\u77e5\u7248\u672c\u201d\u5c5e\u6027\u8bbe\u7f6e\u4e3a False<br \/>\n\u5c06 DLLPath \u8bbe\u7f6e\u4e3a DLL \u6240\u5728\u7684\u8def\u5f84<br \/>\n\u5c06\u81ea\u52a8\u52a0\u8f7d\u5c5e\u6027\u8bbe\u7f6e\u4e3a False<br \/>\n\u5c06\u4ee5\u4e0b\u8bed\u53e5\u6dfb\u52a0\u5230 PythonEngine OnBeforeLoad \u4e8b\u4ef6\u5904\u7406\u7a0b\u5e8f\u4e2d\uff0c\u5047\u8bbe PythonEngine \u662f\u7ec4\u4ef6\u7684\u540d\u79f0<br \/>\n  PythonEngine.SetPythonHome(&#8216;your python installation directory&#8217;)<br \/>\n\u5c06\u4ee5\u4e0b\u8bed\u53e5\u6dfb\u52a0\u5230 FormCreate \u5904\u7406\u7a0b\u5e8f\uff1a<br \/>\n  PythonEngine.LoadDll;<\/p>\n<p>\u7b14\u8bb0\uff1a<\/p>\n<p><strong class=\"text-strong\"><span style=\"color:#FF0000\">32 \u4f4d Delphi \u5e94\u7528\u7a0b\u5e8f\u4ec5\u9002\u7528\u4e8e 32 \u4f4d\u7248\u672c\u7684 Python\uff0c64 \u4f4d Delphi \u5e94\u7528\u7a0b\u5e8f\u4ec5\u9002\u7528\u4e8e 64 \u4f4d\u7248\u672c\u7684 Python\u3002<\/span><\/strong><br \/>\nAnaconda \u53d1\u884c\u7248\u8981\u6c42\u4f60\u8c03\u7528 SetPythonHome\uff0c\u5373\u4f7f\u5b83\u4eec\u5df2\u6ce8\u518c\u3002<br \/>\n\u4f7f\u7528 PythonVersions \u5355\u5143<br \/>\nPythonVersion \u5355\u5143\u53ef\u4ee5\u5e2e\u52a9\u6b63\u786e\u67e5\u627e\u548c\u52a0\u8f7d\u60a8\u60f3\u8981\u7684 python \u7248\u672c\u3002\u5b83\u5904\u7406\u5404\u79cd\u590d\u6742\u6027\uff0c\u4f8b\u5982\u6ce8\u518c\/\u672a\u6ce8\u518c\u7248\u672c\uff0cAnaconda\u53d1\u884c\u7248\u548c\u865a\u62df\u73af\u5883\u3002\u8981\u4f7f\u7528\u5b83\uff0c\u8bf7\u5c06 PythonEngine \u7684 Autoload \u5c5e\u6027\u8bbe\u7f6e\u4e3a False\uff0c\u7136\u540e\u5728 FormCreate load python \u4e2d\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<div class=\"codebox_plus_wrap\">\n<div class=\"codebox_plus_header\"><strong>Code: <\/strong><a href=\"#\" onclick=\"codebox_plus_select(this, 1); return false;\">[\u5168\u9009]<\/a>&nbsp;<a href=\"#\" onclick=\"codebox_plus_toggle(this, 1); return false;\">[Expand\/Collapse]<\/a><\/div>\n<div>\n<div style=\"display: inline;\">\n<div class=\"delphi\" style=\"font-family:monospace;\">\n<ol>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\">&nbsp; <span style=\"color: #000000; font-weight: bold;\">var<\/span> PythonVersion<span style=\"color: #000066;\">:<\/span> TPythonVersion<\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\">&nbsp;<\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\">&nbsp; <span style=\"color: #000000; font-weight: bold;\">if<\/span> GetRegisteredPythonVersion<span style=\"color: #000066;\">&#40;<\/span>SysVersion<span style=\"color: #000066;\">,<\/span> PythonVersion<span style=\"color: #000066;\">&#41;<\/span> <span style=\"color: #000000; font-weight: bold;\">then<\/span><\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\">&nbsp; <span style=\"color: #000000; font-weight: bold;\">or<\/span><\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\">&nbsp; <span style=\"color: #000000; font-weight: bold;\">if<\/span> PythonVersionFromPath<span style=\"color: #000066;\">&#40;<\/span>Path<span style=\"color: #000066;\">,<\/span> PythonVersion<span style=\"color: #000066;\">&#41;<\/span> <span style=\"color: #000000; font-weight: bold;\">then<\/span><\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\">&nbsp; <span style=\"color: #000000; font-weight: bold;\">begin<\/span><\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\">&nbsp; &nbsp; PythonVersion<span style=\"color: #000066;\">.<\/span><span style=\"color: #006600;\">AssignTo<\/span><span style=\"color: #000066;\">&#40;<\/span>PythonEngine<span style=\"color: #000066;\">&#41;<\/span><\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\">&nbsp; &nbsp; PythonEngine<span style=\"color: #000066;\">.<\/span><span style=\"color: #006600;\">LoadDLL<\/span><\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\">&nbsp; <span style=\"color: #000000; font-weight: bold;\">end<\/span><\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\">&nbsp;<\/div>\n<\/li>\n<\/ol>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"codebox_plus_footer\">GeSHi &copy; Codebox Plus Extension<\/div>\n<\/div>\n<p>\u4ee5\u4e0b\u662f TPythonVersion.AssignTo \u8fc7\u7a0b\uff1a<\/p>\n<div class=\"codebox_plus_wrap\">\n<div class=\"codebox_plus_header\"><strong>Code: <\/strong><a href=\"#\" onclick=\"codebox_plus_select(this, 1); return false;\">[\u5168\u9009]<\/a>&nbsp;<a href=\"#\" onclick=\"codebox_plus_toggle(this, 1); return false;\">[Expand\/Collapse]<\/a><\/div>\n<div>\n<div style=\"display: inline;\">\n<div class=\"delphi\" style=\"font-family:monospace;\">\n<ol>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\"><span style=\"color: #000000; font-weight: bold;\">procedure<\/span> TPythonVersion<span style=\"color: #000066;\">.<\/span><span style=\"color: #006600;\">AssignTo<\/span><span style=\"color: #000066;\">&#40;<\/span>PythonEngine<span style=\"color: #000066;\">:<\/span> TPersistent<span style=\"color: #000066;\">&#41;<\/span><span style=\"color: #000066;\">;<\/span><\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\"><span style=\"color: #000000; font-weight: bold;\">begin<\/span><\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\">&nbsp; <span style=\"color: #000000; font-weight: bold;\">if<\/span> PythonEngine <span style=\"color: #000000; font-weight: bold;\">is<\/span> TPythonEngine <span style=\"color: #000000; font-weight: bold;\">then<\/span><\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\">&nbsp; <span style=\"color: #000000; font-weight: bold;\">begin<\/span><\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\">&nbsp; &nbsp; TPythonEngine<span style=\"color: #000066;\">&#40;<\/span>PythonEngine<span style=\"color: #000066;\">&#41;<\/span><span style=\"color: #000066;\">.<\/span><span style=\"color: #006600;\">UseLastKnownVersion<\/span> <span style=\"color: #000066;\">:<\/span><span style=\"color: #000066;\">=<\/span> <span style=\"color: #000000; font-weight: bold;\">False<\/span><span style=\"color: #000066;\">;<\/span><\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\">&nbsp; &nbsp; TPythonEngine<span style=\"color: #000066;\">&#40;<\/span>PythonEngine<span style=\"color: #000066;\">&#41;<\/span><span style=\"color: #000066;\">.<\/span><span style=\"color: #006600;\">RegVersion<\/span> <span style=\"color: #000066;\">:<\/span><span style=\"color: #000066;\">=<\/span> SysVersion<span style=\"color: #000066;\">;<\/span><\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\">&nbsp; &nbsp; TPythonEngine<span style=\"color: #000066;\">&#40;<\/span>PythonEngine<span style=\"color: #000066;\">&#41;<\/span><span style=\"color: #000066;\">.<\/span><span style=\"color: #006600;\">DllName<\/span> <span style=\"color: #000066;\">:<\/span><span style=\"color: #000066;\">=<\/span> DLLName<span style=\"color: #000066;\">;<\/span><\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\">&nbsp; &nbsp; TPythonEngine<span style=\"color: #000066;\">&#40;<\/span>PythonEngine<span style=\"color: #000066;\">&#41;<\/span><span style=\"color: #000066;\">.<\/span><span style=\"color: #006600;\">DllPath<\/span> <span style=\"color: #000066;\">:<\/span><span style=\"color: #000066;\">=<\/span> DLLPath<span style=\"color: #000066;\">;<\/span><\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\">&nbsp; &nbsp; TPythonEngine<span style=\"color: #000066;\">&#40;<\/span>PythonEngine<span style=\"color: #000066;\">&#41;<\/span><span style=\"color: #000066;\">.<\/span><span style=\"color: #006600;\">APIVersion<\/span> <span style=\"color: #000066;\">:<\/span><span style=\"color: #000066;\">=<\/span> ApiVersion<span style=\"color: #000066;\">;<\/span><\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\">&nbsp; &nbsp; <span style=\"color: #000000; font-weight: bold;\">if<\/span> Is_venv <span style=\"color: #000000; font-weight: bold;\">then<\/span> <span style=\"color: #000000; font-weight: bold;\">begin<\/span><\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\">&nbsp; &nbsp; &nbsp; TPythonEngine<span style=\"color: #000066;\">&#40;<\/span>PythonEngine<span style=\"color: #000066;\">&#41;<\/span><span style=\"color: #000066;\">.<\/span><span style=\"color: #006600;\">VenvPythonExe<\/span> <span style=\"color: #000066;\">:<\/span><span style=\"color: #000066;\">=<\/span> PythonExecutable<span style=\"color: #000066;\">;<\/span><\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\">&nbsp; &nbsp; &nbsp; TPythonEngine<span style=\"color: #000066;\">&#40;<\/span>PythonEngine<span style=\"color: #000066;\">&#41;<\/span><span style=\"color: #000066;\">.<\/span><span style=\"color: #006600;\">SetPythonHome<\/span><span style=\"color: #000066;\">&#40;<\/span>DLLPath<span style=\"color: #000066;\">&#41;<\/span><span style=\"color: #000066;\">;<\/span><\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\">&nbsp; &nbsp; <span style=\"color: #000000; font-weight: bold;\">end<\/span> <span style=\"color: #000000; font-weight: bold;\">else<\/span> <span style=\"color: #000000; font-weight: bold;\">if<\/span> <span style=\"color: #000000; font-weight: bold;\">not<\/span> IsRegistered <span style=\"color: #000000; font-weight: bold;\">or<\/span> Is_conda <span style=\"color: #000000; font-weight: bold;\">then<\/span><\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\">&nbsp; &nbsp; &nbsp; <span style=\"color: #808080; font-style: italic;\">{ <\/span><\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\"><span style=\"color: #808080; font-style: italic;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Not sure why but PythonHome needs to be set even for<\/span><\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\"><span style=\"color: #808080; font-style: italic;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;registered conda distributions<\/span><\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\"><span style=\"color: #808080; font-style: italic;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Note also that for conda distributions to work properly,<\/span><\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\"><span style=\"color: #808080; font-style: italic;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;you need to add Format(&#8216;%s;%0:s\\Library\\bin;&#8217;, [Version.InstallPath]<\/span><\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\"><span style=\"color: #808080; font-style: italic;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;to your Windows path if it is not there already.<\/span><\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\"><span style=\"color: #808080; font-style: italic;\">&nbsp; &nbsp; &nbsp; }<\/span><\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\">&nbsp; &nbsp; &nbsp; TPythonEngine<span style=\"color: #000066;\">&#40;<\/span>PythonEngine<span style=\"color: #000066;\">&#41;<\/span><span style=\"color: #000066;\">.<\/span><span style=\"color: #006600;\">SetPythonHome<\/span><span style=\"color: #000066;\">&#40;<\/span>InstallPath<span style=\"color: #000066;\">&#41;<\/span><span style=\"color: #000066;\">;<\/span><\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\">&nbsp; <span style=\"color: #000000; font-weight: bold;\">end<\/span><span style=\"color: #000066;\">;<\/span><\/div>\n<\/li>\n<li style=\"margin-left:20px;\">\n<div style=\"border-bottom: dotted 1px #cccccc;\"><span style=\"color: #000000; font-weight: bold;\">end<\/span><span style=\"color: #000066;\">;<\/span><\/div>\n<\/li>\n<\/ol>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"codebox_plus_footer\">GeSHi &copy; Codebox Plus Extension<\/div>\n<\/div>\n<p><small>\u539f\u6587\u4f5c\u8005: BG6RSH | <a href=\"https:\/\/bbs.tansoo.cn\/viewtopic.php?t=71\" target=\"_blank\" rel=\"noopener\">\u67e5\u770b\u539f\u5e16<\/a><\/small><\/p>\n","protected":false},"excerpt":{"rendered":"<p>https:\/\/github.com\/pyscripter\/python4de  &hellip; <a href=\"https:\/\/www.tansoo.cn\/?p=1444\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[105],"tags":[],"class_list":["post-1444","post","type-post","status-publish","format-standard","hentry","category-105"],"_links":{"self":[{"href":"https:\/\/www.tansoo.cn\/index.php?rest_route=\/wp\/v2\/posts\/1444","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tansoo.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tansoo.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tansoo.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tansoo.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1444"}],"version-history":[{"count":0,"href":"https:\/\/www.tansoo.cn\/index.php?rest_route=\/wp\/v2\/posts\/1444\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tansoo.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1444"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tansoo.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1444"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tansoo.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1444"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}