Troubleshooting Python package installations Answered

Post author
Nicole Deflaux

Sometimes `pip install --upgrade <pkg>` does not work successfully and people need to troubleshoot.

Now that package installs are written to the Terra detachable persistent disk, one approach is to delete and recreate that disk to troubleshoot BUT it's easy to forget that you have some important files on that disk, then delete it during a troubleshooting session and regret the deletion.

An alternative is to troubleshoot by starting from an empty `packages/` directory. For example, open a terminal and then run the following commands to move all currently installed packages to another directory so that they are no longer visible to pip, Python, and Jupyter:

cd $HOME/notebooks

export PKG_STASH_DIR=packages-as-of-$(date +"%Y%m%d")

mkdir $PKG_STASH_DIR

# Move all the currently installed packages out of the existing destination directory for package installations.
mv packages/* $PKG_STASH_DIR



Now you can retry the `pip`  commands to install the packages again!

Comments

1 comment

  • Comment author
    Stephen Fleming

    Thanks for this post!  It was confusing to me that when I would "recreate" my runtime using a docker image, I would find that the same package installation problems had followed me to the new runtime.  I had expected the docker image to provide me with a clean slate.

    This post is exactly what I was missing.  Running

    rm -r ~/notebooks/packages/*

    gets me back to my "clean slate" docker image.  I suppose stashing the contents of "~/notebooks/packages/" is even better.

    0

Please sign in to leave a comment.