Interesting, I was able to replicate this here too.

I can see how venv may get confused; it’s being run via mayapy which itself
is run under Rosetta 2 for x86 emulation. I would have expected venv to
only reference things relative the Python it was called from, but as
evident by the actual executable it’s creating, Python rather than mayapy,
I suspect it’s reaching out into the OS for the binaries, rather than
mayapy itself.

I got a handful of clues by attempting to print the venv executable.

marcus@macos ~ %
/Applications/Autodesk/maya2022/Maya.app/Contents/bin/mayapy -m venv
temptest
marcus@macos ~ % cat ./temptest/bin/Python
??????? H__PAGEZERO?__TEXT__text__TEXTp
p?__stubs__TEXTz?__stub_helper__TEXT???__unwind_info__TEXT?H?__eh_frame__TEXT???__DATA__nl_symbol_ptr__DATA__la_symbol_ptr__DATH__LINKEDIT
P ?N"?   8 0 !p!H
                                                                            P`!

        /usr/lib/dyldā^4????r
                    1?r$

*(?p
    
hW?/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
    P@executable_path/../Frameworks/Python.framework/Python

Those paths at the bottom suggests to me that it’s calling on arm64 things,
rather than what Rosetta provides.

To work around it, I would pip install some_package --target ./some/path
whereby you can add ./some/path to your PYTHONPATH. You could make a shell
script to launch you into a shell where this was already set, and remember
to install using --target each time. That should get you into close to what
venv would do for you normally.

On Fri, 3 Feb 2023 at 14:18, François Grosbellet <[email protected]>
wrote:

> Hi everyone,
>
> I am trying to set a proper dev environment by creating a functional
> virtual environment from the mayapy Maya included python interpreter,
> without any success. I work with Maya2023 on a macOS ARM laptop.
>
> Creating a venv using
> *mayapy -m venv <venv_folder>*
> result in a non functional venv (missing amongst many other things the
> activate script) and yells the following error:
>
>    - Command '['<venv_folder>/bin/mayapy', '-Im', 'ensurepip',
>    '--upgrade', '--default-pip']' returned non-zero exit status 1.
>
>
> Creating a venv without pip using
>
> *mayapy -m venv <venv_folder> --without-pip*does not yell any error. But
> when activating the newly created venv, here is the output I get:
>
>    - Fatal Python error: init_fs_encoding: failed to get the Python codec
>    of the filesystem encoding
>    Python runtime state: core initialized
>    ModuleNotFoundError: No module named 'encodings'
>    Current thread 0x000000020461b2c0 (most recent call first):
>    <no Python frame>
>
>
> Does anyone have experience with successfully doing this?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/4ec8665b-97a1-450e-aec4-459a2009947cn%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/4ec8665b-97a1-450e-aec4-459a2009947cn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODv3t%2BoxUfEsHEkXwJa6f7EQVoA4iAFRMrHzvZ5it8PEg%40mail.gmail.com.

Reply via email to