File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed
Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -223,12 +223,19 @@ impl VirtualMachine {
223223 #[ cfg( feature = "encodings" ) ]
224224 fn import_encodings ( & mut self ) -> PyResult < ( ) > {
225225 self . import ( "encodings" , None , 0 ) . map_err ( |import_err| {
226- let err = self . new_runtime_error (
227- "Could not import encodings. Is your RUSTPYTHONPATH set? If you don't have \
226+ let msg = if ! self . state . settings . path_list . iter ( ) . any ( |s| s == "PYTHONPATH" || s == "RUSTPYTHONPATH" ) {
227+ "Could not import encodings. Is your RUSTPYTHONPATH or PYTHONPATH set? If you don't have \
228228 access to a consistent external environment (e.g. if you're embedding \
229229 rustpython in another application), try enabling the freeze-stdlib feature"
230- . to_owned ( ) ,
231- ) ;
230+ . to_owned ( )
231+ } else {
232+ "Could not import encodings. Try adding your path to Setting struct's path_list field. If you don't have \
233+ access to a consistent external environment (e.g. if you're embedding \
234+ rustpython in another application), try enabling the freeze-stdlib feature"
235+ . to_owned ( )
236+ } ;
237+
238+ let err = self . new_runtime_error ( msg) ;
232239 err. set_cause ( Some ( import_err) ) ;
233240 err
234241 } ) ?;
You can’t perform that action at this time.
0 commit comments