Library on USB stick

Is it possible to put a library like Sympy on a USB stick. Then use it later on PC which in not connected to the internet?

There are several interpretations and answers to this question, but depending on various factors they mostly boil down to a “yes”. With more specific questions, we can provide more specific answers :slight_smile:

If the library and all its dependencies are Pure Python (like Github’s auto code recognition seems to think Sympy is GitHub - sympy/sympy: A computer algebra system written in pure Python) with universal wheels (there’s only one wheel for sympy on PyPi sympy · PyPI) it should be straightforward. Even with sdists instead of wheels.

For Python libraries written in C or Rust etc., you need the right wheel/ version for the PC or platform it will later be used on (e.g. Arm / x64) or they must be first compiled locally on that PC from their sdists (which cann be shipped via USB stick just as easily as via PyPi).

I have a robotics exam in two weeks. We’re allowed to bring Python code on a USB stick and use it on a computer with Spyder during the exam. The computer won’t have internet access, and although NumPy and Matplotlib will be available, our professor can’t guarantee any other libraries. I used SymPy a lot this semester, but I’m not sure if it will be available.

Yes, just like you can run pip install sympy to install SymPy from PyPI, you could also run pip install sympy-1.14.0.tar.gz to install the downloaded package that is on your local filesystem (just cd to the folder you have the package file on.)

Definitely test doing this before the exam though. Ask if you can check out the test computers before the test. To install packages for Spyder, you’ll should open the command prompt from Spyder itself by following the instructions here: https://stackoverflow.com/questions/63109860/how-to-install-python-packages-for-spyder

2 Likes

Then check with your prof, since this is a question that has a technical aspect but also a non-technical aspect. Make sure you’re allowed to use other libraries.

2 Likes