pythonipynb

UsageError: Line magic function '%rm' not found


I am getting this error on the following line in my .ipynb file

%rm -rf LLaMA-Factory

I am using Python 3.9 version

I am experimenting with all the possible ways to to fine-tune LLMs. The code that I have is working on colab. I want to replicate that locally.


Solution

  • That's not Python, it's shell, specifically the rm command.

    % is a common shell prefix and is not part of the command.

    In Python notebooks the way to run shell commands is usually the ! prefix, as in:

    ! rm -rf ...
    

    Note: Be extremely careful when using -rf as this can easily remove entire swaths of your drive with absolutely no confirmation needed.