mojo
mojo copied to clipboard
[Mojo]: Env var PIP_REQUIRE_VIRTUALENV will cause `modular install mojo` to fail
Issue description
Installing mojo will fail if a user has the PIP_REQUIRE_VIRTUALENV=true
env var set. Setting this var has been a recommended practice in the Python community for a long time now. I had it in my .bashrc for example.
In addition, after the failure (in "Steps to reproduce") occurs, reinstall will also fail unless $ modular clean
is done first.
Steps to reproduce
$ export PIP_REQUIRE_VIRTUALENV=true
$ modular install mojo
# Found release for https://packages.modular.com/mojo @ 0.2.1, installing to /home/caleb/.modular/pkg/packages.modular.com_mojo
# Downloads complete, setting configs...
# Configs complete, running post-install hooks...
ERROR: Could not find an activated virtualenv (required).
modular: error: failed to run python:
Version Info
- Provide Modular CLI version by pasting the output of `modular -v`
modular 0.1.4 (6b54d308)
- What OS did you install modular CLI on ?
$ uname -a
Linux pop-os 6.4.6-76060406-generic #202307241739~1692717645~22.04~5597803 SMP PREEMPT_DYNAMIC Tue A x86_64 x86_64 x86_64 GNU/Linux
@cjrh Thank for the tip. I also wish to carry forward python's venv. To the point Modular team willing to implement Mojo venv with me. Thread: https://discord.com/channels/1087530497313357884/1143373527932743721
Things are clearer now.
The path setting are witten in modular.cfg
in .modular/
.
We can try to implement Mojo venv openly now! Even with Python!
Hope that os
and shutil
modules are implemented in mojo soon.
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 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.