Skip to content

Commit

Permalink
fix auto set env
Browse files Browse the repository at this point in the history
  • Loading branch information
yanghaoqi committed Aug 24, 2023
1 parent b2d00af commit 008a359
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
10 changes: 6 additions & 4 deletions examples/user_guide/k230_simulate-EN.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,17 @@
"\n",
"result = subprocess.run([\"pip\", \"show\", \"nncase\"], capture_output=True)\n",
"\n",
"split_flag = \"\\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",
" split_flag = \"\\r\\n\"\n",
"\n",
"location_s = [i for i in result.stdout.decode().split(split_flag) if i.startswith(\"Location:\")]\n",
"location = location_s[0].split(\": \")[1]\n",
"\n",
"if \"PATH\" in os.environ:\n",
" os.environ[\"PATH\"] += os.pathsep + location\n",
"else:\n",
" os.environ[\"PATH\"] = location"
" os.environ[\"PATH\"] = location\n"
]
},
{
Expand Down
8 changes: 5 additions & 3 deletions examples/user_guide/k230_simulate-ZH.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,12 @@
"\n",
"result = subprocess.run([\"pip\", \"show\", \"nncase\"], capture_output=True)\n",
"\n",
"split_flag = \"\\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",
" split_flag = \"\\r\\n\"\n",
" \n",
"location_s = [i for i in result.stdout.decode().split(split_flag) if i.startswith(\"Location:\")]\n",
"location = location_s[0].split(\": \")[1]\n",
"\n",
"if \"PATH\" in os.environ:\n",
" os.environ[\"PATH\"] += os.pathsep + location\n",
Expand Down

0 comments on commit 008a359

Please sign in to comment.