Skip to content

Commit 4665592

Browse files
committed
adding support for virtualenvs, which don't support site.getsitepackages
1 parent b7b0237 commit 4665592

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/cs50/cs50.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
import re
55
import sys
66

7+
from distutils.sysconfig import get_python_lib
78
from os.path import abspath, join
8-
from site import getsitepackages, getusersitepackages
9+
from site import getusersitepackages
910
from termcolor import cprint
1011
from traceback import extract_tb, format_list, format_exception_only
1112

@@ -16,8 +17,9 @@ def excepthook(type, value, tb):
1617
and user-specific site-packages directory.
1718
1819
https://stackoverflow.com/a/33042323/5156190
20+
https://stackoverflow.com/a/122340/5156190
1921
"""
20-
packages = tuple(join(abspath(p), "") for p in getsitepackages() + [getusersitepackages()])
22+
packages = tuple(join(abspath(p), "") for p in [get_python_lib(), getusersitepackages()])
2123
for entry in extract_tb(tb):
2224
fmt = format_list((entry,))
2325
if (entry[0].startswith(packages)):

0 commit comments

Comments
 (0)