Skip to content

Commit 12a98d6

Browse files
committed
Added troubleshooting
1 parent d103bc8 commit 12a98d6

2 files changed

Lines changed: 95 additions & 0 deletions

File tree

README.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,95 @@ To explain up-front:
5050
- When taking an exam for practice, we recommend having a copy of the DSC 10 reference sheet open in another tab, as well as a second copy of the exam, so you can access the data descriptions.
5151

5252

53+
### Troubleshooting tips
54+
#### yaml `ModuleNotFoundError`
55+
```
56+
python run.py
57+
Traceback (most recent call last):
58+
File "..../practice.dsc40a.com/run.py", line 1, in <module>
59+
import yaml
60+
ModuleNotFoundError: No module named 'yaml'
61+
```
62+
**Example Behavior:**
63+
```
64+
(base) practice.dsc40a.com % python run.py
65+
Traceback (most recent call last):
66+
File "practice.dsc40a.com/run.py", line 1, in <module>
67+
import yaml
68+
ModuleNotFoundError: No module named 'yaml'
69+
(base) practice.dsc40a.com % pip3 install PyYAML
70+
71+
[notice] A new release of pip is available: 24.2 -> 25.3
72+
[notice] To update, run: python3.12 -m pip install --upgrade pip
73+
error: externally-managed-environment
74+
75+
× This environment is externally managed
76+
╰─> To install Python packages system-wide, try brew install
77+
xyz, where xyz is the package you are trying to
78+
install.
79+
80+
If you wish to install a Python library that isn't in Homebrew,
81+
use a virtual environment:
82+
83+
python3 -m venv path/to/venv
84+
source path/to/venv/bin/activate
85+
python3 -m pip install xyz
86+
87+
If you wish to install a Python application that isn't in Homebrew,
88+
it may be easiest to use 'pipx install xyz', which will manage a
89+
virtual environment for you. You can install pipx with
90+
91+
brew install pipx
92+
93+
You may restore the old behavior of pip by passing
94+
the '--break-system-packages' flag to pip, or by adding
95+
'break-system-packages = true' to your pip.conf file. The latter
96+
will permanently disable this error.
97+
98+
If you disable this error, we STRONGLY recommend that you additionally
99+
pass the '--user' flag to pip, or set 'user = true' in your pip.conf
100+
file. Failure to do this can result in a broken Homebrew installation.
101+
102+
Read more about this behavior here: <https://peps.python.org/pep-0668/>
103+
104+
note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
105+
hint: See PEP 668 for the detailed specification.
106+
```
107+
**Solution:**
108+
- If you have already installed the above packages but still encounter this issue,
109+
- Taken DSC 80,
110+
Use DSC 80 environment either in terminal or in VS code.
111+
112+
#### Pathname issue
113+
```
114+
File "practice.dsc40a.com/run.py", line 549, in <module>
115+
write_all_pages()
116+
File "practice.dsc40a.com/run.py", line 508, in write_all_pages
117+
write_page(path, called_from_write_all_pages=True)
118+
File "practice.dsc40a.com/run.py", line 421, in write_page
119+
page, title = process_page(path, is_discussion=is_discussion)
120+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
121+
File "practice.dsc40a.com/run.py", line 389, in process_page
122+
out += stitch(params['problems'], params['show_solution'])
123+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
124+
File "practice.dsc40a.com/run.py", line 121, in stitch
125+
r = open(path, 'r', encoding='UTF-8').read()
126+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
127+
FileNotFoundError: [Errno 2] No such file or directory: 'problems/ss2-24-final\\ss2-24-final-q01.md'
128+
```
129+
**Cause**: Windows and mac have different ways of doing pathnames.
130+
**Solution**: In run.py, you can see the following line:
131+
132+
```python
133+
def stitch(files, show_solution, toc=False):
134+
...
135+
for i, path in enumerate(paths):
136+
137+
# Comment the line below out if you are using windows.
138+
path = path.replace('\\', '/')
139+
# Coment the line above out if you are using windows.
53140

141+
path = os.path.normpath(path)
142+
...
143+
```
144+
Follow the instruction of the comments. If you have issue with pathname, the cause is likely somewhere in this function.

run.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,11 @@ def stitch(files, show_solution, toc=False):
108108
pass
109109

110110
for i, path in enumerate(paths):
111+
112+
# Comment the line below out if you are using windows.
111113
path = path.replace('\\', '/')
114+
# Coment the line above out if you are using windows.
115+
112116
path = os.path.normpath(path)
113117
# This case only happens for discussion worksheets, when we provide a question along with a "data info" sheet just for that question
114118
if ', ' in path:

0 commit comments

Comments
 (0)