Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Pip tries to install solver module globally #468

Open
andrewbaxter opened this issue Jun 26, 2024 · 1 comment
Open

[BUG] Pip tries to install solver module globally #468

andrewbaxter opened this issue Jun 26, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@andrewbaxter
Copy link

Contact Details

here

Description

I'm not sure what exact command CAD Sketcher runs for pip, but I assume it does it outside of a virtual environment. On Arch this is now restricted per https://peps.python.org/pep-0668/ with this warning message:

pip 24.0 from /usr/lib/python3.12/site-packages/pip (python 3.12)
error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try 'pacman -S
    python-xyz', where xyz is the package you are trying to
    install.
    
    If you wish to install a non-Arch-packaged Python package,
    create a virtual environment using 'python -m venv path/to/venv'.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip.
    
    If you wish to install a non-Arch packaged Python application,
    it may be easiest to use 'pipx install xyz', which will manage a
    virtual environment for you. Make sure you have python-pipx
    installed via pacman.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.

I'm not sure this is solvable. If blender runs in the system python context, solving it may require the user to run blender itself in a virtual environment to package, if that works at all (I haven't tried it, and it sounds hacky). https://projects.blender.org/blender/blender/issues/71420 describes a lot of issues with how blender handles pypi, including venvs, but it doesn't look like it's gone anywhere... I assume Windows is okay because the python bundled with blender is effectively a limited environment.

I assume the reason the solver can't be packaged together is because it's a c extension and needs to be compiled for each user?

Addon Version

0.27.3

Blender Version

4.1.1

What platform are you running on?

Linux

@andrewbaxter andrewbaxter added the bug Something isn't working label Jun 26, 2024
@Albanbrice
Copy link

I don't know if it may help, but I couldn't update pip and install the py_slvs module as explained on the installation instructions.
I am on Windows 10, Blender 3.6.
I found a workaround to manually install the module on the python instance embedded in Blender with the following commands

 # Get pip: equl to /blender-path/x.xx/python/bin/python3.7m -m ensurepip
blender -b --python-expr "__import__('ensurepip')._bootstrap()" 

# Update pip toolchain
blender -b --python-expr "__import__('pip._internal')._internal.main(['install', '-U', 'pip', 'setuptools', 'wheel'])"

# pip install py_slvs (or any package)
blender -b --python-expr "__import__('pip._internal')._internal.main(['install', 'py_slvs'])"

for more detail, check this on :
https://blender.stackexchange.com/questions/56011/how-to-install-pip-for-blenders-bundled-python

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants