Replace pip install mcpi with %pip which always installs in the right environment

main
Aurélien Geron 2021-10-07 18:10:34 +13:00
parent b3081ceab6
commit fdb5d1695e
5 changed files with 16 additions and 9 deletions

View File

@ -2374,7 +2374,14 @@
"source": [
"# if running this notebook on Colab or Kaggle, we just pip install urlextract\n",
"if IS_COLAB or IS_KAGGLE:\n",
" !pip install -q -U urlextract"
" %pip install -q -U urlextract"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Note:** inside a Jupyter notebook, always use `%pip` instead of `!pip`, as `!pip` may install the library inside the wrong environment, while `%pip` makes sure it's installed inside the currently running environment."
]
},
{

View File

@ -52,7 +52,7 @@
"IS_KAGGLE = \"kaggle_secrets\" in sys.modules\n",
"\n",
"if IS_COLAB or IS_KAGGLE:\n",
" !pip install -q -U tfx==0.21.2\n",
" %pip install -q -U tfx==0.21.2\n",
" print(\"You can safely ignore the package incompatibility errors.\")\n",
"\n",
"# Scikit-Learn ≥0.20 is required\n",

View File

@ -57,8 +57,8 @@
"IS_KAGGLE = \"kaggle_secrets\" in sys.modules\n",
"\n",
"if IS_COLAB:\n",
" !pip install -q -U tensorflow-addons\n",
" !pip install -q -U transformers\n",
" %pip install -q -U tensorflow-addons\n",
" %pip install -q -U transformers\n",
"\n",
"# Scikit-Learn ≥0.20 is required\n",
"import sklearn\n",

View File

@ -52,8 +52,8 @@
"\n",
"if IS_COLAB or IS_KAGGLE:\n",
" !apt update && apt install -y libpq-dev libsdl2-dev swig xorg-dev xvfb\n",
" !pip install -q -U tf-agents pyvirtualdisplay gym[box2d]\n",
" !pip install -q -U atari_py==0.2.5\n",
" %pip install -q -U tf-agents pyvirtualdisplay gym[box2d]\n",
" %pip install -q -U atari_py==0.2.5\n",
"\n",
"# Scikit-Learn ≥0.20 is required\n",
"import sklearn\n",
@ -220,7 +220,7 @@
"Alternatively, you can install the [pyvirtualdisplay](https://github.com/ponty/pyvirtualdisplay) Python library which wraps Xvfb:\n",
"\n",
"```bash\n",
"python3 -m pip install -U pyvirtualdisplay\n",
"%pip install -U pyvirtualdisplay\n",
"```\n",
"\n",
"And run the following code:"
@ -2812,7 +2812,7 @@
"metadata": {},
"source": [
"## 8.\n",
"_Exercise: Use policy gradients to solve OpenAI Gym's LunarLander-v2 environment. You will need to install the Box2D dependencies (`python3 -m pip install -U gym[box2d]`)._"
"_Exercise: Use policy gradients to solve OpenAI Gym's LunarLander-v2 environment. You will need to install the Box2D dependencies (`%pip install -U gym[box2d]`)._"
]
},
{

View File

@ -54,7 +54,7 @@
" !echo \"deb http://storage.googleapis.com/tensorflow-serving-apt stable tensorflow-model-server tensorflow-model-server-universal\" > /etc/apt/sources.list.d/tensorflow-serving.list\n",
" !curl https://storage.googleapis.com/tensorflow-serving-apt/tensorflow-serving.release.pub.gpg | apt-key add -\n",
" !apt update && apt-get install -y tensorflow-model-server\n",
" !pip install -q -U tensorflow-serving-api\n",
" %pip install -q -U tensorflow-serving-api\n",
"\n",
"# Scikit-Learn ≥0.20 is required\n",
"import sklearn\n",