{"id":544,"date":"2021-03-09T00:20:03","date_gmt":"2021-03-08T16:20:03","guid":{"rendered":"https:\/\/rayray.moe\/?p=544"},"modified":"2026-02-21T19:12:20","modified_gmt":"2026-02-21T11:12:20","slug":"%e9%85%8d%e7%bd%aeraspa%e7%8e%af%e5%a2%83%ef%bc%8c%e5%92%8c%e9%85%8d%e7%bd%aeraspa-python%e5%ba%93","status":"publish","type":"post","link":"https:\/\/rayray.moe\/?p=544","title":{"rendered":"\u914d\u7f6eraspa\u73af\u5883\uff0c\u548c\u914d\u7f6eraspa-python\u5e93"},"content":{"rendered":"<p>2021.04.02 \u66f4\u65b0<\/p>\n<p>\u6298\u817e\u4e86\u53ef\u80fd\u4e00\u4e2a\u534a\u6708\uff0c\u6700\u540e\u624d\u53d1\u73b0 PIP\u624d\u662f\u6b63\u9014\u3002\u9996\u5148\u914d\u7f6epython2.7\u7684\u865a\u62df\u73af\u5883\uff0c\u901a\u8fc7conda\u5b89\u88c5openbabel\uff0c\u7136\u540e\u4f7f\u7528<\/p>\n<p><code class=\"language-bash\">pip install raspa2<\/code><\/p>\n<p>\u5b89\u88c5raspa2\u540e\uff0c\u4f7f\u7528python 2.7 \u5185\u6838\u7684jupyter notebook\u5c31\u53ef\u4ee5\u8fd0\u884c\u4e86\u3002<\/p>\n<p>\u90e8\u5206openbabel\u7684\u66f4\u65b0\u5bfc\u81f4\u6709\u4e9b\u8c03\u7528\u65b9\u6cd5\u9700\u8981\u4fee\u6539\u3002\u6309\u7167\u62a5\u9519\u81ea\u5df1\u6162\u6162\u627e\u5427\uff5e<\/p>\n<p>\u679c\u7136\u8fd8\u662fmac\u4e0b\u7684pip\u574f\u6389\u5f71\u54cd\u4e86\u6211\u7684\u9009\u62e9\uff0c\u6700\u521d\u7684\u9009\u62e9\u5c31\u662f\u6700\u6b63\u786e\u7684orz\u3002\u6298\u817e\u4e86\u8fd9\u4e48\u4e45\uff0c\u7ec8\u4e8e\u6709\u4e86\u80fd\u7528\u7684raspa2\uff0c\u4e0b\u4e00\u6b65\u5c31\u662f\u6784\u5efa\u6570\u636e\u96c6\uff0c\u4f7f\u7528sklearn\u4e86\uff5e\uff01\uff01<\/p>\n<p>\u5411\u65b0\u65b9\u5411\u8fdb\u53d1\u5427\uff01<\/p>\n<p>&nbsp;<\/p>\n<p>&#8212;&#8212;<\/p>\n<p>\u5f88\u4e45\u6ca1\u4ec0\u4e48\u8bb0\u5f55\u4e00\u4e9b\u6709\u7528\u7684\u4e1c\u897f\u3002\u6bd5\u7adf\u5b9e\u9a8c\u5fd9\u4e86\u5f88\u591a\u5e74\u7ec8\u4e8e\u71ac\u51fa\u4e86\u5934\uff0c\u73b0\u5728\u53ef\u4ee5\u770b\u770b\u81ea\u5df1\u611f\u5174\u8da3\u7684\u5185\u5bb9\u3002\u8d81\u7740\u8ba1\u7b97\u8fd8\u5728\u7b97\uff0c\u7a7a\u4f59\u65f6\u95f4\u5728\u7814\u7a76\u4e00\u4e9b\u5173\u4e8e\u9884\u6d4b\u5b9e\u9a8c\u6027\u8d28\u7684\u8d44\u6599\uff0c\u4e5f\u5c31\u6d89\u53ca\u5230\u4e86\u4e00\u4e9b\u5206\u5b50\u52a8\u529b\u5b66\u6a21\u62df\u7684\u5185\u5bb9\u3002<\/p>\n<p>raspa2\u662f\u5e38\u7528\u7684\u6765\u4f5c\u5438\u9644\u6a21\u62df\u7684\u5e94\u7528\u3002\u76ee\u524dMOFs\u901a\u8fc7raspa2\u8fdb\u884c\u7684\u5438\u9644\u6a21\u62df\u62a5\u9053\u5df2\u7ecf\u6709\u5f88\u591a\u7bc7\u4e86\u3002<\/p>\n<p>raspa2\u672c\u4f53\u5b89\u88c5\u6709\u51e0\u79cd\u65b9\u6cd5\uff1apip\uff0cconda\uff0c\u4ece\u5934\u7f16\u8bd1\u3002pip\u548c\u4ece\u5934\u7f16\u8bd1\u6211\u5c1d\u8bd5\u4e86\u6570\u6b21\uff0c\u6362\u4e86\u51e0\u4e2a\u7cfb\u7edf\uff0c\u8865\u5145\u4e86\u4e00\u5806\u7f3a\u7684\u5934\u6587\u4ef6\u8fd8\u662f\u5931\u8d25\u4e86\uff0c\u8fd8\u597dconda\u7684\u53ef\u4ee5\u76f4\u63a5\u7528\u3002<\/p>\n<p>\u4f46\u662f\u95ee\u9898\u6765\u4e86\uff0craspa2\u7684\u8c03\u7528\u6bd4\u8f83\u590d\u6742\uff0c\u6240\u4ee5\u9700\u8981\u4e00\u4e2a\u811a\u672c\u8fdb\u884c\u524d\u540e\u5904\u7406\uff1a\u4f5c\u8005\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217perl\u81ea\u52a8\u5316\u811a\u672c\uff0c\u548cpython\u5e93\u6765\u8fdb\u884c\u8c03\u7528\uff0c\u56e0\u4e3a\u6ca1\u6709\u5b66\u8fc7perl\uff0c\u6240\u4ee5\u6211\u5c31\u5148\u53bb\u7814\u7a76\u4e86python\u7684\u90e8\u5206\u3002<br \/>\n\u7136\u800c\uff0craspa2-python\u914d\u7f6e\u8d77\u6765\u6bd4\u60f3\u8c61\u4e2d\u7684\u590d\u6742\u7684\u591a\u3002\u56e0\u4e3araspa2-python\u53ea\u9488\u5bf9pip\u548c\u81ea\u5df1\u7f16\u8bd1\u8fdb\u884c\u4e86\u8bbe\u8ba1\uff0c\u6240\u4ee5\u5176\u4e2d\u7684\u4e00\u4e9b\u53d8\u91cf\u9700\u8981\u8fdb\u884c\u4fee\u6539\u3002\u800c\u4e14\uff0craspa2-python\u53ea\u652f\u6301linux\u8fd0\u884c\uff0c<br \/>\n\u6240\u4ee5\u4ee5\u4e0b\u7684\u5185\u5bb9\u5747\u5728linux\u4e0b\u8fdb\u884c\u3002\u7cfb\u7edf\u662f Ubuntu 20.10\u3002<\/p>\n<p>\u524d\u524d\u540e\u540e\u6298\u817e\u4e86\u4e94\u5929\uff0c\u7ec8\u4e8e\u628a\u8fd9\u4e2a\u641e\u5b9a\u4e86\u3002<\/p>\n<p>\u4ee5\u4e0b\u662f\u8fc7\u7a0b\uff0c\u7528\u6237\u540d\u9700\u8981\u81ea\u884c\u66ff\u6362\u3002<\/p>\n<ol>\n<li>\u5b89\u88c5\u672c\u4f53\u548c\u914d\u7f6e\u73af\u5883<\/li>\n<\/ol>\n<pre><code class=\"language-bash\"># \u521b\u5efa\u865a\u62df\u73af\u5883\r\nconda create -n raspa\r\nconda activate raspa\r\nconda install -c conda-forge raspa2\r\n<\/code><\/pre>\n<p>\u6bcf\u6b21\u4f7f\u7528\u524d\u8981\u5148\u6267\u884c\u4e00\u6b21 conda activate raspa<\/p>\n<pre><code class=\"language-bash\"># \u5728 ~\/.bashrc \u4e2d\u6dfb\u52a0\u8fd9\u884c\uff0c\u867d\u7136\u5728\u6700\u540e\u5e76\u6ca1\u6709\u7528\u4e0a\u2026\u5982\u679cpip\u548c\u81ea\u884c\u7f16\u8bd1\u4f1a\u7528\u5230\r\nexport RASPA_DIR=\/home\/tkaray\/anaconda3\/envs\/raspa\r\n<\/code><\/pre>\n<ol>\n<li>\u4fee\u6539\u6587\u4ef6\u548c\u6587\u4ef6\u5939<\/li>\n<\/ol>\n<p>\u67e5\u770braspa\u5728conda\u5e93\u4e2d\u7684\u5206\u5e03\uff0c\u5305\u62ec\u4ee5\u4e0b\u4f4d\u7f6e\uff1a<\/p>\n<pre><code class=\"language-bash\">\/home\/tkaray\/anaconda3\/envs\/raspa # \u4e3b\u76ee\u5f55\r\n\/home\/tkaray\/anaconda3\/envs\/raspa\/RASPA2 # python\u90e8\u5206\r\n\/home\/tkaray\/anaconda3\/envs\/raspa\/share\/raspa # \u5e93\u90e8\u5206\r\n<\/code><\/pre>\n<p>\u6839\u636eraspa2.py\u7684\u5185\u5bb9\uff0c\u9700\u8981\u5c06 \/home\/tkaray\/anaconda3\/envs\/raspa\/share\/raspa \u4e2d\u65b0\u5efa libraspa \u6587\u4ef6\u5939\uff0c\u5e76\u5c06\u56db\u4e2a\u6587\u4ef6\u5939 (forcefield, framework, molecules, structures)<br \/>\n\u90fd\u653e\u8fdb\u53bb\u3002<\/p>\n<p>\u63a5\u4e0b\u6765\u4fee\u6539 \/home\/tkaray\/anaconda3\/envs\/raspa\/RASPA2\/raspa2.py \u4e2d\u7684\u5185\u5bb9\uff1a<\/p>\n<pre><code class=\"language-python\"># raspa2.py\r\nraspa_dir = os.path.dirname(os.path.realpath(__file__))\r\nlibraspa_dir = os.path.join(os.path.dirname(raspa_dir), \"share\/raspa\")\r\nlibraspa_file = next(f for f in os.listdir(libraspa_dir) if \"libraspa\" in f)\r\n<\/code><\/pre>\n<p>\u8fd9\u91cc\u9700\u8981\u4f7f\u7528\u76f8\u5bf9\u8def\u5f84\uff0c\u5982\u679c\u4e0d\u4f7f\u7528\u76f8\u5bf9\u8def\u5f84\u5c31\u4f1a\u8ba9ctypes.cdll \u62a5 OSError \u9519\u8bef\uff1acdll loadlibrary is a directory\u3002<\/p>\n<ol>\n<li>\u4f7f\u7528<\/li>\n<\/ol>\n<p>\u56e0\u4e3a\u6587\u4ef6\u5939\u7684\u9650\u5236\uff0craspa2-python\u7684\u90e8\u5206\u653e\u5728\u4e86\u4e3b\u76ee\u5f55 \/home\/tkaray\/anaconda3\/envs\/raspa\/RASPA2 \u4e0b\uff0c\u8fd9\u4e2a\u4f4d\u7f6e\u5e76\u4e0d\u662f\u6b63\u5e38\u7684\u5305\u4f4d\u7f6e\uff0c\u56e0\u6b64\u9700\u8981\u5bf9\u641c\u7d22\u5305\u4f4d\u7f6e\u8fdb\u884c\u4fee\u6539\u3002<br \/>\n\u8981\u5728\u6bcf\u6b21\u4f7f\u7528\u524d\u8fdb\u884c\u58f0\u660e\u3002\u800c\u4e14\u4f4d\u7f6e\u4e0d\u80fd\u8fdb\u884c\u79fb\u52a8\uff08\u4e0d\u7136cdll\u51fd\u6570\u5c31\u4f1a\u62a5\u9519\uff09\u3002\u4e5f\u53ef\u4ee5\u91c7\u7528\u5168\u5c40\u58f0\u660e\u7684\u529e\u6cd5\uff0c\u4f46\u662f\u4e3a\u4e86\u907f\u514d\u4e0d\u5fc5\u8981\u7684\u95ee\u9898\u6240\u4ee5\u8fd9\u91cc\u91c7\u7528\u4e86\u4e34\u65f6\u7684\u58f0\u660e\uff08\u6bcf\u6b21\u8c03\u7528\u524d\u90fd\u8981\u5e26\u4e0a\u8fd9\u6bb5\uff09\u3002<\/p>\n<pre><code class=\"language-python\">import sys\r\nsys.path.append('\/home\/tkaray\/anaconda3\/envs\/raspa')\r\n\r\nimport RASPA2 as raspa\r\n<\/code><\/pre>\n<p>\u800c\u6240\u6709\u7684\u5e93\u6587\u4ef6\uff08\u5982cif\uff0c\u5206\u5b50\u5b9a\u4e49\uff0c\u529b\u573a\u7b49\uff09\u5219\u8981\u653e\u5728 \/home\/tkaray\/anaconda3\/envs\/raspa\/share\/raspa\/libraspa \u4e2d\u3002<\/p>\n<ol>\n<li>\u4e0b\u4e00\u6b65<\/li>\n<\/ol>\n<p>\u867d\u7136\u6298\u817e\u4e86\u8fd9\u4e48\u591a\uff0c\u4f46\u662f\u56e0\u4e3a\u673a\u65f6\u95ee\u9898\uff0c\u8fd8\u6ca1\u6709\u5bf9\u8fd9\u4e2a\u8f6f\u4ef6\u8fdb\u884c\u5927\u91cf\u7684\u4f7f\u7528\uff0c\u800c\u4e14\u53ef\u80fd\u4e5f\u9700\u8981\u518d\u7528\u4e00\u4e0bperl\u811a\u672c\uff0c\u6240\u4ee5\u8fd9\u7bc7\u8bb0\u5f55\u53ef\u80fd\u8fd8\u9700\u8981\u7ee7\u7eed\u66f4\u65b0\u3002\uff08\u5f53\u7136\u5e0c\u671b\u4e0d\u8981\u6709\u8fd9\u4e48\u591a\u5751\uff09<\/p>\n<p>\u53e6\u5916\u5373\u4f7f\u4f7f\u7528conda\u8fdb\u884c\u5b89\u88c5\uff0c\u4e5f\u5e94\u8be5\u5728Github\u4e0a\u9762\u4e0b\u8f7d\u4e0b\u6765\u6e90\u6587\u4ef6\uff0c\u56e0\u4e3a\u5176\u4e2d\u5305\u542b\u4e86\u4e00\u4e9b\u6709\u7528\u7684\u793a\u4f8b\uff0c\u53ef\u4ee5\u5e2e\u52a9\u5b66\u4e60\u7a0b\u5e8f\u7684\u4f7f\u7528\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>2021.04.02 \u66f4\u65b0 \u6298\u817e\u4e86\u53ef\u80fd\u4e00\u4e2a\u534a\u6708\uff0c\u6700\u540e\u624d\u53d1\u73b0 PIP\u624d\u662f &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[30],"tags":[34],"class_list":["post-544","post","type-post","status-publish","format-standard","hentry","category-notes","tag-raspa-"],"_links":{"self":[{"href":"https:\/\/rayray.moe\/index.php?rest_route=\/wp\/v2\/posts\/544","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rayray.moe\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rayray.moe\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rayray.moe\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rayray.moe\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=544"}],"version-history":[{"count":3,"href":"https:\/\/rayray.moe\/index.php?rest_route=\/wp\/v2\/posts\/544\/revisions"}],"predecessor-version":[{"id":548,"href":"https:\/\/rayray.moe\/index.php?rest_route=\/wp\/v2\/posts\/544\/revisions\/548"}],"wp:attachment":[{"href":"https:\/\/rayray.moe\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=544"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rayray.moe\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=544"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rayray.moe\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=544"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}