modularml / mojo

The Mojo Programming Language
https://docs.modular.com/mojo/manual/
Other
22.85k stars 2.58k forks source link

[BUG]: cannot install on Ubuntu 22.04.3 LTS #1302

Open JasonMendoza2008 opened 10 months ago

JasonMendoza2008 commented 10 months ago

Bug description

I did:

curl https://get.modular.com | sh - && \
modular auth mut_44bf4fe1d8974f11b88a6f9350fd6c3a

Then, I did:

sudo apt install python3.10-venv
modular install mojo

And I have the following error:

lhott@lhott:~$ modular install mojo
# Found release for https://packages.modular.com/mojo @ 0.5.0
# Installing to /home/lhott/.modular/pkg/packages.modular.com_mojo
# Downloading artifacts. Please wait...
# Downloads complete, setting configs...
# Configs complete, running post-install hooks...
Collecting find_libpython==0.3.0
  Downloading find_libpython-0.3.0-py3-none-any.whl (8.5 kB)
Collecting papermill==2.4.0
  Downloading papermill-2.4.0-py3-none-any.whl (38 kB)
Collecting jupyter_client>=8.3.0
  Downloading jupyter_client-8.6.0-py3-none-any.whl (105 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 105.9/105.9 KB 4.3 MB/s eta 0:00:00
Collecting ipykernel>=6.25.0
  Downloading ipykernel-6.26.0-py3-none-any.whl (114 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 114.3/114.3 KB 23.3 MB/s eta 0:00:00
Collecting nbclient>=0.2.0
  Downloading nbclient-0.9.0-py3-none-any.whl (24 kB)
Collecting click
  Downloading click-8.1.7-py3-none-any.whl (97 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 97.9/97.9 KB 11.4 MB/s eta 0:00:00
Collecting tqdm>=4.32.2
  Downloading tqdm-4.66.1-py3-none-any.whl (78 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 78.3/78.3 KB 13.9 MB/s eta 0:00:00
Collecting entrypoints
  Downloading entrypoints-0.4-py3-none-any.whl (5.3 kB)
Collecting pyyaml
  Downloading PyYAML-6.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (705 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 705.5/705.5 KB 8.4 MB/s eta 0:00:00
Collecting nbformat>=5.1.2
  Downloading nbformat-5.9.2-py3-none-any.whl (77 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 77.6/77.6 KB 7.8 MB/s eta 0:00:00
Collecting requests
  Downloading requests-2.31.0-py3-none-any.whl (62 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 62.6/62.6 KB 6.1 MB/s eta 0:00:00
Collecting tenacity
  Downloading tenacity-8.2.3-py3-none-any.whl (24 kB)
Collecting ansiwrap
  Downloading ansiwrap-0.8.4-py2.py3-none-any.whl (8.5 kB)
Collecting jupyter-core!=5.0.*,>=4.12
  Downloading jupyter_core-5.5.0-py3-none-any.whl (28 kB)
Collecting pyzmq>=23.0
  Downloading pyzmq-25.1.1-cp310-cp310-manylinux_2_28_x86_64.whl (1.1 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.1/1.1 MB 10.0 MB/s eta 0:00:00
Collecting tornado>=6.2
  Downloading tornado-6.3.3-cp38-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (427 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 427.7/427.7 KB 12.3 MB/s eta 0:00:00
Collecting traitlets>=5.3
  Downloading traitlets-5.13.0-py3-none-any.whl (84 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 85.0/85.0 KB 5.6 MB/s eta 0:00:00
Collecting python-dateutil>=2.8.2
  Downloading python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 247.7/247.7 KB 15.2 MB/s eta 0:00:00
Collecting nest-asyncio
  Downloading nest_asyncio-1.5.8-py3-none-any.whl (5.3 kB)
Collecting packaging
  Downloading packaging-23.2-py3-none-any.whl (53 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 53.0/53.0 KB 6.9 MB/s eta 0:00:00
Collecting psutil
  Downloading psutil-5.9.6-cp36-abi3-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (283 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 283.6/283.6 KB 8.4 MB/s eta 0:00:00
Collecting matplotlib-inline>=0.1
  Downloading matplotlib_inline-0.1.6-py3-none-any.whl (9.4 kB)
Collecting comm>=0.1.1
  Downloading comm-0.2.0-py3-none-any.whl (7.0 kB)
Collecting ipython>=7.23.1
  Downloading ipython-8.17.2-py3-none-any.whl (808 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 808.4/808.4 KB 15.2 MB/s eta 0:00:00
Collecting debugpy>=1.6.5
  Downloading debugpy-1.8.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.3 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.3/3.3 MB 6.3 MB/s eta 0:00:00
Collecting prompt-toolkit!=3.0.37,<3.1.0,>=3.0.30
  Downloading prompt_toolkit-3.0.41-py3-none-any.whl (385 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 385.5/385.5 KB 14.5 MB/s eta 0:00:00
Collecting pygments>=2.4.0
  Downloading Pygments-2.16.1-py3-none-any.whl (1.2 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.2/1.2 MB 13.1 MB/s eta 0:00:00
Collecting decorator
  Downloading decorator-5.1.1-py3-none-any.whl (9.1 kB)
Collecting stack-data
  Downloading stack_data-0.6.3-py3-none-any.whl (24 kB)
Collecting exceptiongroup
  Downloading exceptiongroup-1.1.3-py3-none-any.whl (14 kB)
Collecting jedi>=0.16
  Downloading jedi-0.19.1-py2.py3-none-any.whl (1.6 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.6/1.6 MB 3.0 MB/s eta 0:00:00
Collecting pexpect>4.3
  Downloading pexpect-4.8.0-py2.py3-none-any.whl (59 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 59.0/59.0 KB 7.7 MB/s eta 0:00:00
Collecting platformdirs>=2.5
  Downloading platformdirs-4.0.0-py3-none-any.whl (17 kB)
Collecting jsonschema>=2.6
  Downloading jsonschema-4.20.0-py3-none-any.whl (84 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 84.7/84.7 KB 9.2 MB/s eta 0:00:00
Collecting fastjsonschema
  Downloading fastjsonschema-2.19.0-py3-none-any.whl (23 kB)
Collecting six>=1.5
  Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting textwrap3>=0.9.2
  Downloading textwrap3-0.9.2-py2.py3-none-any.whl (12 kB)
Collecting urllib3<3,>=1.21.1
  Downloading urllib3-2.1.0-py3-none-any.whl (104 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 104.6/104.6 KB 11.1 MB/s eta 0:00:00
Collecting certifi>=2017.4.17
  Downloading certifi-2023.7.22-py3-none-any.whl (158 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 158.3/158.3 KB 31.4 MB/s eta 0:00:00
Collecting charset-normalizer<4,>=2
  Downloading charset_normalizer-3.3.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (142 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 142.1/142.1 KB 9.2 MB/s eta 0:00:00
Collecting idna<4,>=2.5
  Downloading idna-3.4-py3-none-any.whl (61 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.5/61.5 KB 3.9 MB/s eta 0:00:00
Collecting parso<0.9.0,>=0.8.3
  Downloading parso-0.8.3-py2.py3-none-any.whl (100 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100.8/100.8 KB 12.8 MB/s eta 0:00:00
Collecting rpds-py>=0.7.1
  Downloading rpds_py-0.13.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.2/1.2 MB 9.3 MB/s eta 0:00:00
Collecting attrs>=22.2.0
  Using cached attrs-23.1.0-py3-none-any.whl (61 kB)
Collecting referencing>=0.28.4
  Downloading referencing-0.31.0-py3-none-any.whl (25 kB)
Collecting jsonschema-specifications>=2023.03.6
  Downloading jsonschema_specifications-2023.11.1-py3-none-any.whl (17 kB)
Collecting ptyprocess>=0.5
  Downloading ptyprocess-0.7.0-py2.py3-none-any.whl (13 kB)
Collecting wcwidth
  Downloading wcwidth-0.2.10-py2.py3-none-any.whl (105 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 105.2/105.2 KB 9.4 MB/s eta 0:00:00
Collecting executing>=1.2.0
  Downloading executing-2.0.1-py2.py3-none-any.whl (24 kB)
Collecting asttokens>=2.1.0
  Downloading asttokens-2.4.1-py2.py3-none-any.whl (27 kB)
Collecting pure-eval
  Downloading pure_eval-0.2.2-py3-none-any.whl (11 kB)
Installing collected packages: wcwidth, textwrap3, pure-eval, ptyprocess, find_libpython, fastjsonschema, urllib3, traitlets, tqdm, tornado, tenacity, six, rpds-py, pyzmq, pyyaml, pygments, psutil, prompt-toolkit, platformdirs, pexpect, parso, packaging, nest-asyncio, idna, executing, exceptiongroup, entrypoints, decorator, debugpy, click, charset-normalizer, certifi, attrs, ansiwrap, requests, referencing, python-dateutil, matplotlib-inline, jupyter-core, jedi, comm, asttokens, stack-data, jupyter_client, jsonschema-specifications, jsonschema, ipython, nbformat, ipykernel, nbclient, papermill
Successfully installed ansiwrap-0.8.4 asttokens-2.4.1 attrs-23.1.0 certifi-2023.7.22 charset-normalizer-3.3.2 click-8.1.7 comm-0.2.0 debugpy-1.8.0 decorator-5.1.1 entrypoints-0.4 exceptiongroup-1.1.3 executing-2.0.1 fastjsonschema-2.19.0 find_libpython-0.3.0 idna-3.4 ipykernel-6.26.0 ipython-8.17.2 jedi-0.19.1 jsonschema-4.20.0 jsonschema-specifications-2023.11.1 jupyter-core-5.5.0 jupyter_client-8.6.0 matplotlib-inline-0.1.6 nbclient-0.9.0 nbformat-5.9.2 nest-asyncio-1.5.8 packaging-23.2 papermill-2.4.0 parso-0.8.3 pexpect-4.8.0 platformdirs-4.0.0 prompt-toolkit-3.0.41 psutil-5.9.6 ptyprocess-0.7.0 pure-eval-0.2.2 pygments-2.16.1 python-dateutil-2.8.2 pyyaml-6.0.1 pyzmq-25.1.1 referencing-0.31.0 requests-2.31.0 rpds-py-0.13.0 six-1.16.0 stack-data-0.6.3 tenacity-8.2.3 textwrap3-0.9.2 tornado-6.3.3 tqdm-4.66.1 traitlets-5.13.0 urllib3-2.1.0 wcwidth-0.2.10
[mojo] Testing: `mojo --help` [FAIL]
[mojo] Testing: `mojo run --help` [FAIL]
[mojo] Testing: `mojo build test_mandelbrot.mojo` [FAIL]
[mojo] Testing: `mojo build test_python.mojo` [FAIL]
[mojo] Testing: `mojo demangle` [FAIL]
[mojo] Testing: `mojo format` [FAIL]
[mojo] Testing: `mojo package` [FAIL]
[mojo] Testing: `mojo test_mandelbrot.mojo` [FAIL]
[mojo] Testing: `mojo test_python.mojo` [FAIL]
[mojo] Testing: `mojo repl` [FAIL]
[mojo] Some components may have been installed successfully, but others may not work as expected. Please submit an issue to https://github.com/modularml/mojo and include the full output of the command you just ran.
modular: error: failed to run python: 

Python is installed (I have Python 3.10.12 and Python 3.12.0).

However I have to do python3.10 or python3.12 to enter Python from the bash. python doesn't work. Maybe that's the problem?

JasonMendoza2008 commented 10 months ago

I did sudo ln -s /usr/bin/python3 /usr/bin/python and it still doesn't work (but obviously running python in bash now works).

andraxin commented 9 months ago

@JasonMendoza2008 Apparently, the mojo binary is located at ./.modular/pkg/packages.modular.com_mojo/bin/mojo:

> find -name mojo
./.modular/.mojo_cache/mojo
./.modular/pkg/packages.modular.com_mojo/lib/mojo
./.modular/pkg/packages.modular.com_mojo/bin/mojo

and trying to execute it directly reveals that the root cause has nothing to do with Python:

> ./.modular/pkg/packages.modular.com_mojo/bin/mojo
/root/.modular/pkg/packages.modular.com_mojo/bin/lldb: error while loading shared libraries: libedit.so.2: cannot open shared object file: No such file or directory

This can be resolved by apt install -y libedit2, and voilà:

> ./.modular/pkg/packages.modular.com_mojo/bin/mojo
Welcome to Mojo! 🔥

Expressions are delimited by a blank line.
Type `:quit` to exit the REPL and `:mojo help` for further assistance.

  1> print('hello clueless') 
  2.  
hello clueless
  2>  

BTW, please don't take offense at the word "clueless"! That's just a tip of the hat to the Modular folks who plan to take over the AI world, but cannot even write a decent installer for the only Linux distro they claim to support.

JasonMendoza2008 commented 9 months ago

@andraxin thanks for the answer!

I have:

lhott@lhott:~$ find -name mojo
./.modular/pkg/packages.modular.com_mojo/lib/mojo
./.modular/pkg/packages.modular.com_mojo/bin/mojo

But when I do

lhott@lhott:~$ ./.modular/pkg/packages.modular.com_mojo/bin/mojo

I get:

Illegal instruction (core dumped)

I still did the install as you suggested but this didn't change anything:

lhott@lhott:~$ sudo apt install -y libedit2
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
libedit2 is already the newest version (3.1-20210910-1build1).
libedit2 set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
lhott@lhott:~$ ./.modular/pkg/packages.modular.com_mojo/bin/mojo
Illegal instruction (core dumped)
andraxin commented 9 months ago

@JasonMendoza2008

Illegal instruction (core dumped)

That usually means that the binary includes an instruction your CPU doesn't support. https://duckduckgo.com/?t=ffab&q=Illegal+instruction+(core+dumped)

Chances are Mojo was compiled with optimizations that your hardware cannot cope with. What processor are you running on? (Check: grep -m1 model\ name /proc/cpuinfo)

Sometimes, these can be silly issues, like using a bit-shift instruction like SHLX from BMI2 https://en.wikipedia.org/wiki/X86_Bit_manipulation_instruction_set#BMI2_(Bit_Manipulation_Instruction_Set_2) instead of pure unadulterated SHL https://en.wikibooks.org/wiki/X86_Assembly/Shift_and_Rotate

https://stackoverflow.com/questions/47899971/c-getting-error-illegal-instruction-core-dumped-upon-bitwise-or-operatio#47901355

JasonMendoza2008 commented 9 months ago

@andraxin I am running on: AMD Ryzen 7 5800H with Radeon Graphics

How could I fix these binaries?

andraxin commented 9 months ago

@JasonMendoza2008

How could I fix these binaries?

Given that the source code doesn't appear to be available, recompiling is not an option. You could reach out to Modular and ask what optimizations are turned on, and whether they would consider creating a more accessible executable.

Taking matters into your own hands, I'm not aware of any simple tools for re-mapping unsupported instructions in a binary. There's always the hard way using a disassembler to locate the offending instructions and a hexeditor to replace them. (If I recall correctly biew [AKA beye] does both). Of course, you'd need to be careful to match both the size and the functionality of any replacement.

A quick search also turns up SaBRe as potentially interesting, but I have exactly ZERO experience with that.

I guess, running in an emulator is also an option, but you might experience performance degradation when doing so.

JasonMendoza2008 commented 9 months ago

@andraxin

I guess, running in an emulator is also an option, but you might experience performance degradation when doing so.

If you mean a Virtual Machine, this was already what I was doing as I thought it had higher chances of working.

andraxin commented 9 months ago

@JasonMendoza2008

If you mean a Virtual Machine, this was already what I was doing as I thought it had higher chances of working.

Running in a VM may or may not help. That would depend on what CPU architecture the VM exposes. I guess when you said you were running on AMD Ryzen 7 5800H that was referring to your host machine not the VM. Or, perhaps, your VM is set up to expose the host CPU more or less directly... If the VM emulates a legacy CPU that might actually be causing the error you reported...

JasonMendoza2008 commented 9 months ago

@JasonMendoza2008

If you mean a Virtual Machine, this was already what I was doing as I thought it had higher chances of working.

Running in a VM may or may not help. That would depend on what CPU architecture the VM exposes. I guess when you said you were running on AMD Ryzen 7 5800H that was referring to your host machine not the VM. Or, perhaps, your VM is set up to expose the host CPU more or less directly... If the VM emulates a legacy CPU that might actually be causing the error you reported...

That's indeed my host machine but that's also what grep -m1 model\ name /proc/cpuinfo returns :/

andraxin commented 9 months ago

@JasonMendoza2008

That's indeed my host machine but that's also what grep -m1 model\ name /proc/cpuinfo returns :/

I cannot really accuse you of being clear... :smirk: Did you mean that on your host or inside the VM, or both? :rofl:

BTW, what host OS and VM tech are you using (if you don't mind disclosing)? I could try to replicate. Note that after the libedit2 fix, Mojo runs fine on my box (Intel Core i9-11900H) inside a Docker container.

JasonMendoza2008 commented 9 months ago

Sorry, I was not very clear. My host machine is running Windows 11. I'm using Oracle VM VirtualBox to install and run Ubuntu 22.04.3 LTS. I have been using it to run some other projects without any problem. So I thought I could give mojo a go within that Virtual Machine. When I run grep -m1 model\ name /proc/cpuinfo in my Linux environment, I get AMD Ryzen 7 5800H with Radeon Graphics.

I could definitely try to set up another Virtual Machine with another environment than Ubuntu 22.04.3 LTS but I would not know which one would be the most appropriate.

andraxin commented 9 months ago

@JasonMendoza2008 I could reproduce your issue in a VirtualBox VM. I had even tried every possible paravirtualization interface option for the processor to no avail. https://superuser.com/questions/945910/how-to-select-paravirtualization-interface-in-virtualbox

Note, however, that I can run Mojo in a container on the same box (under Windows 11) just fine. I used Docker Desktop, but Rancher Desktop, or possibly even running Docker inside WSL2, could/should also work.

For a quick test, you could try the image I built: https://hub.docker.com/r/andraxin/mojo

JasonMendoza2008 commented 7 months ago

@JasonMendoza2008 I could reproduce your issue in a VirtualBox VM. I had even tried every possible paravirtualization interface option for the processor to no avail. https://superuser.com/questions/945910/how-to-select-paravirtualization-interface-in-virtualbox

Note, however, that I can run Mojo in a container on the same box (under Windows 11) just fine. I used Docker Desktop, but Rancher Desktop, or possibly even running Docker inside WSL2, could/should also work.

For a quick test, you could try the image I built: https://hub.docker.com/r/andraxin/mojo

This went a bit over my head so I couldn't give it a go and I tried again today hoping it was fixed with the updates, but it still isn't (same errors)

andraxin commented 7 months ago

@JasonMendoza2008 Hmm... that's odd. I mean that you keep having the same issue with the newer version.

In the meantime, I had also tried running my original Docker image (built from 0.4.0) on an Intel-based Mac and experienced the invalid instruction issue; BUT, rebuilding the image using 0.7.0 fixed that. I could run the new image no problem...

On the other hand, I have not tried running in a VM on Windows since last time. I would've expected the new version to work, but I don't have hands-on experience with that combination.

Sharktheone commented 7 months ago

I have read somewhere that VirtualBox doesn't support AVX(2) with Hyper-V. Mojo needs AVX2 instructions (I somehow can't find it anymore was mentioned)

I think, VMs are (still) unsupported, but luckily Docker or WSL is. Since you are on Windows, it's probably way easier to just install Mojo in WSL.

jackos commented 3 months ago

Resolved in nightly release by https://github.com/modularml/mojo/commit/b6776222dbd1e2e72a5e6f772d01b35fee7ea0d9. Mojo now finds libpython using the python executable on the top of PATH

You can test before the official release with modular install nightly/mojo. For environments like vscode codespaces that have a python on the top of PATH without a dynamic libpython.so you can activate a virtual environment to use a different version before installation e.g. the system Python is able to link to a dynamic libpython:

/usr/bin/python3 -m venv ~/venv
source ~/venv/bin/activate

Or alternatively create and activate an environment that comes with libpython like pyenv or conda

Please reopen if you have any further issues.

JasonMendoza2008 commented 3 months ago

@jackos it still doesn't work. I did:

curl -s https://get.modular.com | sh -

Then

python3 -m venv mojo-venv && source mojo-venv/bin/activate

Then

modular install nightly/mojo

And I get errors, "check 42 in output failed, please submit a bug".

JasonMendoza2008 commented 3 months ago

Also, it seems I cannot reopen the issue?

andraxin commented 3 months ago

@jackos it still doesn't work. I did:

curl -s https://get.modular.com | sh -

Then

python3 -m venv mojo-venv && source mojo-venv/bin/activate

Then

modular install nightly/mojo

And I get errors, "check 42 in output failed, please submit a bug".

@JasonMendoza2008: I think you may be missing a crucial point in @jackos 's post. and that is "a dynamic libpython.so". Ubuntu's "system Python" is not build that way, as evidenced by the following (run in an Ubuntu container):

root@cbd4403178fe:/# ldd $(which python3)
    linux-vdso.so.1 (0x00007fb993681000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fb992fa9000)
    libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007fb992f78000)
    libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fb992f5c000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fb992d33000)
    /lib64/ld-linux-x86-64.so.2 (0x00007fb993683000)
root@cbd4403178fe:/# 

That also implies that any environment created via the standard venv package
using that "system Python" will not have a dynamic libpython.so, either. That's why @jackos suggested using pyenv or conda, since those tools build their own Python from scratch; crucially, with a dynamic libpython.so.

BTW, the official Python container images do have a dynamic libpython.so (in addition to their non-dynamic "system Python"); so, you could try running Mojo in a Docker container...

$ docker run --rm -it python ldd /usr/bin/python3 /usr/local/bin/python
/usr/bin/python3:
    linux-vdso.so.1 (0x00007f19dc436000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f19dc34b000)
    libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f19dc32c000)
    libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007f19dc301000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f19dc120000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f19dc438000)
/usr/local/bin/python:
    linux-vdso.so.1 (0x00007f46faea5000)
    libpython3.12.so.1.0 => /usr/local/bin/../lib/libpython3.12.so.1.0 (0x00007f46fa87b000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f46fa694000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f46fa5b5000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f46faea7000)
$ 

Alternatively, you could also just build your own Python with dynamic libpython.so from scratch following the recipe embedded in the Python image's history

$ docker history --no-trunc python | grep enable-shared
<missing>                                                                 8 weeks ago   RUN /bin/sh -c set -eux;   wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz";  wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc";  GNUPGHOME="$(mktemp -d)"; export GNUPGHOME;  gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$GPG_KEY";  gpg --batch --verify python.tar.xz.asc python.tar.xz;  gpgconf --kill all;  rm -rf "$GNUPGHOME" python.tar.xz.asc;  mkdir -p /usr/src/python;  tar --extract --directory /usr/src/python --strip-components=1 --file python.tar.xz;  rm python.tar.xz;   cd /usr/src/python;  gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)";  ./configure   --build="$gnuArch"   --enable-loadable-sqlite-extensions   --enable-optimizations   --enable-option-checking=fatal   --enable-shared   --with-lto   --with-system-expat   --without-ensurepip  ;  nproc="$(nproc)";  EXTRA_CFLAGS="$(dpkg-buildflags --get CFLAGS)";  LDFLAGS="$(dpkg-buildflags --get LDFLAGS)";  make -j "$nproc"   "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}"   "LDFLAGS=${LDFLAGS:-}"   "PROFILE_TASK=${PROFILE_TASK:-}"  ;  rm python;  make -j "$nproc"   "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}"   "LDFLAGS=${LDFLAGS:--Wl},-rpath='\$\$ORIGIN/../lib'"   "PROFILE_TASK=${PROFILE_TASK:-}"   python  ;  make install;   bin="$(readlink -ve /usr/local/bin/python3)";  dir="$(dirname "$bin")";  mkdir -p "/usr/share/gdb/auto-load/$dir";  cp -vL Tools/gdb/libpython.py "/usr/share/gdb/auto-load/$bin-gdb.py";   cd /;  rm -rf /usr/src/python;   find /usr/local -depth   \(    \( -type d -a \( -name test -o -name tests -o -name idle_test \) \)    -o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \) \)   \) -exec rm -rf '{}' +  ;   ldconfig;   python3 --version # buildkit   60.7MB    buildkit.dockerfile.v0
$ 

BUT, it's a whole lot simpler to just use pyenv.

JasonMendoza2008 commented 3 months ago

Ah I see sorry I had not understood that. I'm unfortunately too much of a beginner for this and will simply wait for a more stable version! I'm really far from being anything remotely close to decent when it comes to programming.

jackos commented 3 months ago

No worries thanks for the feedback @JasonMendoza2008. Reopening until that error message is improved. This will be in stable shortly, one catch-all way to resolve it is to run the steps here to install conda

Make sure you've run ~/miniconda3/bin/conda init --all and restarted your shell, then run:

conda create -n 3.11 python=3.11
conda activate 3.11

And try reinstalling with the activated conda envionrment.