50.005 Computer System Engineering
Information Systems Technology and Design
Singapore University of Technology and Design
Natalie Agus (Summer 2024)
Debug Notes
Pip Install Error
If you use Python >3.12, you might see the following error when trying to run pip install -m requirements.txt
:
AttributeError: module 'pkgutil' has no attribute 'ImpImporter'. Did you mean: 'zipimporter'?
Simply upgrade pip:
python -m ensurepip --upgrade
Invalid Syntax
Some of you might encounter the error when running python3 ServerWithoutSecurity.py
match convert_bytes_to_int(read_bytes(client_socket, 8)):
^
case 0:
SyntaxError: invalid syntax
That’s because your python3
is NOT aliased to python3.10
or that you don’t have python3.10
installed. Fix this on your own. You’re a CS major student. Not knowing how to install Python and manage its libraries is a really really bad thing; it’s like as if the entire 50.002 and the first 6 weeks of CSE doesn’t mean anything to you.
In this handout, we assume that python3
is always aliased to python3.10
.
That is, if you type python3
in the terminal, you’ll see at least version 3.10 printed out:
The autograder file also uses python3
instead of python3.10
. You can modify it to call python3.10
instead accordingly.
Module Not Found
Some of you might encouter the error ModuleNotFoundError: No module named ‘cryptography’
. You should know what you need to do by now as a CS student. If you have installed cryptography using pip install cryptography
, but still suffer from this error, it simply means that the pip
you used does not install to the path library of whatever python3
version you are using right now. That is, you may have mixed up Python
and pip
versions on your machine.
Assuming your python3
is aliased to python3.10
, then you can do:
python3 -m pip install cryptography
No Such File or Directory: recv_files/EXPECTED_FILE
Depending on your OS, when you run ServerWithSecurity[version].py
or the autograder, it might complain about files in the directories: recv_files/EXPECTED_FILE
, recv_files_enc/EXPECTED_FILE
, etc not found when you clearly have it in your project path or have run setup.sh
.
This is due to differences in what constitutes a line break:
\r\n
is a Windows Style\n
is a POSIX Style\r
is a old pre-OS X Macs Style, Modern Mac’s using POSIX Style
Therefore your directory name might be set as recv_files\r\n
when you run setup.sh
. You can’t tell whether the line break is there or not. Similarly, when you receive filename
from input
in ClientWithSecurity[version].py
, the line break might be there, creating filename like files.txt\r\n
. In order to tackle this, you can:
- Add
.strip()
at the end ofinput
, resulting ininput("Enter a filename....").strip()
- Create a new
setup.sh
with the exact same content and overwrites the old one so that the line break suits your system’s
When submitting, please use LF
as your end of line sequence because we are running your code on Linux-distro containers.
Command truncate Not Found
It is possible that you might not have truncate
system program installed by default. You have learned the File System in Week 6, so we suppose you know why we use it in our autograder.
To install, simply type sudo apt -y install coreutils
(Ubuntu), or brew install coreutils
(macOS).
Why not give Docker Image?
Docker?
We would’ve given you a Docker image but then if you can’t debug your own code given the autograder written in Python, then apologies, we don’t have enough faith yet that you can install Docker on your own and spawn a container properly. Maybe someday 🥹.