@@ -168,7 +168,13 @@ def jupyter_path(*subdirs):
168
168
# Next is environment or user, depending on the JUPYTER_PREFER_ENV_PATH flag
169
169
user = [jupyter_data_dir ()]
170
170
if site .ENABLE_USER_SITE :
171
- userdir = os .path .join (site .getuserbase (), 'share' , 'jupyter' )
171
+ # Check if site.getuserbase() exists to be compatible with virtualenv,
172
+ # which often does not have this method.
173
+ if hasattr (site , 'getuserbase' ):
174
+ userbase = site .getuserbase ()
175
+ else :
176
+ userbase = site .USER_BASE
177
+ userdir = os .path .join (userbase , 'share' , 'jupyter' )
172
178
if userdir not in user :
173
179
user .append (userdir )
174
180
@@ -231,7 +237,14 @@ def jupyter_config_path():
231
237
# Next is environment or user, depending on the JUPYTER_PREFER_ENV_PATH flag
232
238
user = [jupyter_config_dir ()]
233
239
if site .ENABLE_USER_SITE :
234
- userdir = os .path .join (site .getuserbase (), 'etc' , 'jupyter' )
240
+ # Check if site.getuserbase() exists to be compatible with virtualenv,
241
+ # which often does not have this method.
242
+ if hasattr (site , 'getuserbase' ):
243
+ userbase = site .getuserbase ()
244
+ else :
245
+ userbase = site .USER_BASE
246
+
247
+ userdir = os .path .join (userbase , 'etc' , 'jupyter' )
235
248
if userdir not in user :
236
249
user .append (userdir )
237
250
0 commit comments