Repository: IronLanguages/ironpython3

Issue #821: Cannot import os/no implementation of stat
Created: 2020-05-04T14:24:28Z
Prerequisites

 Are you running the latest version? (Latest Git master)
 Are you reporting to the correct repository?
 Did you perform a cursory search? (Searched for os and stat.)

Description
The os module throws an ImportError when imported.
Steps to Reproduce

Run ipy.
import os

Expected behavior:
os module is imported.
Actual behavior:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 539, in _check_name_wrapper
File "<string>", line 1614, in load_module
File "<string>", line 596, in _load_module_shim
File "<string>", line 1220, in load
File "<string>", line 1200, in _load_unlocked
File "<string>", line 1129, in _exec
File "<string>", line 1471, in exec_module
File "<string>", line 321, in _call_with_frames_removed
File "C:\path\to\ironpython3\bin\Release\netcoreapp3.1\Lib\os.py", line 27, in <module>
ImportError: No module named stat

Versions
> bin/Release/netcoreapp3.1/ipy -V
IronPython 3.4.0 3.4.0.0 on .NET 3.1.3
> git log
commit 7c687497c6ce3a0a3d5db9c0d9b39d62d128f85c (HEAD -> master, origin/master, origin/HEAD)
...

Duplicate issue #1606: Ironpython reports  "No module named 'stat'" when failing importing os module 
Created: 2022-12-08T12:23:41Z
The release mode of ironpython fails to import 'os' module. (It can import other modules like 'sys'. So I guess I have installed ironpython correctly. This may be buggy.) Besides, it is weird that Ironpython fails importing 'os' module but the error message is no module name "stat''.  By the way, under debug mode, ironpython can import os correctly.
Error message.
[.NETCoreApp,Version=v6.0 on .NET 6.0.11 (64-bit)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 540, in _check_name_wrapper
  File "<string>", line 1565, in load_module
  File "<string>", line 597, in _load_module_shim
  File "<string>", line 1208, in load
  File "<string>", line 1188, in _load_unlocked
  File "<string>", line 1117, in _exec
  File "<string>", line 1459, in exec_module
  File "<string>", line 322, in _call_with_frames_removed
  File "/home/xxm/Desktop/IFuzzer/experiment_on_different_interpreter/ironpython/ironpython3/bin/Release/net6.0/lib/os.py", line 27, in <module>
ImportError: No module named 'stat'

Expected behavior:

ironpython can import 'os' module correctly.
even if ironpython cannot import os module, the error message should be "ImportError: No module named 'os'".

I install ironpython master branch on Ubuntu 18.04 by the following step:

git clone https://github.com/IronLanguages/ironpython3.git
typing "./make.ps1"

Closing comment (2022-12-08T14:16:06Z): stat is part of the standard library and the build process does not copy the standard library to the output folder. As noted in the Building IronPython3 document, to run from the Release folder you should set the IRONPYTHONPATH environment variable to point to the folder containing the standard library <path to ironpython3 repo>/Src/StdLib/Lib.
Duplicate of #821.