Skip to content

Commit

Permalink
add auto set env
Browse files Browse the repository at this point in the history
  • Loading branch information
yanghaoqi committed Aug 24, 2023
1 parent 06a5015 commit b2d00af
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 23 deletions.
35 changes: 23 additions & 12 deletions examples/user_guide/k230_simulate-EN.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,36 @@
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8b32a0b5-90b0-4bc7-8448-2a544b7d06e9",
"attachments": {},
"cell_type": "markdown",
"id": "a17fa3cf",
"metadata": {},
"outputs": [],
"source": [
"# ubuntu\n",
"%env PATH=$PATH:/usr/local/lib/python3.7/site-packages"
"## auto set enviroment"
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "960b50d1-1990-4b1c-b8be-0a9f04fb6907",
"cell_type": "code",
"execution_count": null,
"id": "7cdadfc6",
"metadata": {},
"outputs": [],
"source": [
"* In Windows OS\n",
"> You need to add the path where nncase packages were installed into `PATH` environment variable.\n",
"After it, you need to restart your `CMD`. "
"import os\n",
"import sys\n",
"import subprocess\n",
"\n",
"result = subprocess.run([\"pip\", \"show\", \"nncase\"], capture_output=True)\n",
"\n",
"if sys.platform == \"win32\":\n",
" location = result.stdout.decode().split(\"\\r\\n\")[7].split(\": \")[1]\n",
"else:\n",
" location = result.stdout.decode().split(\"\\n\")[7].split(\": \")[1]\n",
"\n",
"if \"PATH\" in os.environ:\n",
" os.environ[\"PATH\"] += os.pathsep + location\n",
"else:\n",
" os.environ[\"PATH\"] = location"
]
},
{
Expand Down
34 changes: 23 additions & 11 deletions examples/user_guide/k230_simulate-ZH.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,36 @@
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8b32a0b5-90b0-4bc7-8448-2a544b7d06e9",
"attachments": {},
"cell_type": "markdown",
"id": "d8d2a6f0",
"metadata": {},
"outputs": [],
"source": [
"# ubuntu\n",
"%env PATH=$PATH:/usr/local/lib/python3.7/site-packages"
"## 自动设置环境变量"
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "960b50d1-1990-4b1c-b8be-0a9f04fb6907",
"cell_type": "code",
"execution_count": null,
"id": "8b32a0b5-90b0-4bc7-8448-2a544b7d06e9",
"metadata": {},
"outputs": [],
"source": [
"* Windows平台\n",
"> 需要将nncase的安装路径加入到`PATH`环境变量中,并且重启你的`CMD`。"
"import os\n",
"import sys\n",
"import subprocess\n",
"\n",
"result = subprocess.run([\"pip\", \"show\", \"nncase\"], capture_output=True)\n",
"\n",
"if sys.platform == \"win32\":\n",
" location = result.stdout.decode().split(\"\\r\\n\")[7].split(\": \")[1]\n",
"else:\n",
" location = result.stdout.decode().split(\"\\n\")[7].split(\": \")[1]\n",
"\n",
"if \"PATH\" in os.environ:\n",
" os.environ[\"PATH\"] += os.pathsep + location\n",
"else:\n",
" os.environ[\"PATH\"] = location\n"
]
},
{
Expand Down

0 comments on commit b2d00af

Please sign in to comment.