{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['/Users/satoc/miniforge3/envs/gradio/lib/python312.zip',\n", " '/Users/satoc/miniforge3/envs/gradio/lib/python3.12',\n", " '/Users/satoc/miniforge3/envs/gradio/lib/python3.12/lib-dynload',\n", " '',\n", " '/Users/satoc/.local/lib/python3.12/site-packages',\n", " '/Users/satoc/miniforge3/envs/gradio/lib/python3.12/site-packages',\n", " '/Users/satoc/Dropbox/programing/python/ClinicalTrialV3']" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import sys\n", "import os \n", "paths =sys.path\n", "paths" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'/Users/satoc/Dropbox/programing/python/ClinicalTrialV2'" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "paths[-1]" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'/Users/satoc/Dropbox/programing/python/ClinicalTrialV2/original_tools.pth'" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "fileName = paths[-1] + '/' +'original_tools.pth'\n", "#fileName = \"/Users/satoc/Dropbox/programing/python/ClinicalTrialV2\" + '/' +'original_tools.pth'\n", "fileName" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "name = ! pwd" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "name = os.getcwd()" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'/Users/satoc/Dropbox/programing/python/ClinicalTrialV3'" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "name" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "with open (fileName, mode='w') as f:\n", " f.write(name)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "['/Users/satoc/miniforge3/envs/gradio/lib/python312.zip', '/Users/satoc/miniforge3/envs/gradio/lib/python3.12', '/Users/satoc/miniforge3/envs/gradio/lib/python3.12/lib-dynload', '', '/Users/satoc/.local/lib/python3.12/site-packages', '/Users/satoc/miniforge3/envs/gradio/lib/python3.12/site-packages', '/Users/satoc/Dropbox/programing/python/ClinicalTrialV2']\n", "/Users/satoc/Dropbox/programing/python/ClinicalTrialV2/original_tools.pth\n", "/Users/satoc/Dropbox/programing/python/ClinicalTrialV3\n" ] } ], "source": [ "import sys\n", "import os \n", "paths =sys.path\n", "print(paths)\n", "fileName = paths[-1] + '/' +'original_tools.pth'\n", "print(fileName)\n", "cwd = os.getcwd()\n", "print(cwd)\n", "with open (fileName, mode='w') as f:\n", " f.write(cwd)" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "cwd = os.getcwd()" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "ename": "ModuleNotFoundError", "evalue": "No module named 'pytrials'", "output_type": "error", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)", "Cell \u001b[0;32mIn[9], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mpytrials\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mclient\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m ClinicalTrials \n", "\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'pytrials'" ] } ], "source": [ "from pytrials.client import ClinicalTrials " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ ".pthファイルを作成するパス: /Users/satoc/miniforge3/envs/gradio/lib/python3.12/site-packages/original_tools.pth\n", "現在の作業ディレクトリ: /Users/satoc/Dropbox/programing/python/ClinicalTrialV3\n", "モジュール検索パス:\n", "['/Users/satoc/miniforge3/envs/gradio/lib/python312.zip', '/Users/satoc/miniforge3/envs/gradio/lib/python3.12', '/Users/satoc/miniforge3/envs/gradio/lib/python3.12/lib-dynload', '', '/Users/satoc/.local/lib/python3.12/site-packages', '/Users/satoc/miniforge3/envs/gradio/lib/python3.12/site-packages', '/Users/satoc/Dropbox/programing/python/ClinicalTrialV2']\n" ] } ], "source": [ "import sys\n", "import os\n", "import site\n", "\n", "# site-packagesのディレクトリを取得\n", "site_packages_path = site.getsitepackages()[0] # 複数ある場合、通常は最初のものを使用\n", "\n", "# .pthファイルのパスをsite-packagesに設定\n", "fileName = os.path.join(site_packages_path, 'original_tools.pth')\n", "print(f\".pthファイルを作成するパス: {fileName}\")\n", "\n", "# 現在の作業ディレクトリを取得\n", "cwd = os.getcwd()\n", "print(f\"現在の作業ディレクトリ: {cwd}\")\n", "\n", "# .pthファイルを作成し、現在の作業ディレクトリのパスを書き込む\n", "with open(fileName, mode='w') as f:\n", " f.write(cwd)\n", "\n", "# 確認のためにsys.pathを再表示\n", "print(\"モジュール検索パス:\")\n", "print(sys.path)\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.3" } }, "nbformat": 4, "nbformat_minor": 4 }