05-03-2023 05:39 AM
I want to run NSO 6.0.4 as local_install to develop service model in local environment.
Environment:
MacBook Pro 14inch,2021
Apple M1 Pro
Monterey 12.0.1
I noticed NSO 6.1 has darwin/arm installer however 6.0.4 does not have arm installer.
When package reload, I got following result:
ncs_cli
admin@ncs# packages reload
reload-result {
package add_loopback
result false
info Python VM failed to start
}
reload-result {
package cisco-ios-cli-3.8
result true
}
ncs-python-vm.log
<INFO> 3-May-2023::21:26:15.419 H2201889 ncs[20011]: Restarted PyVM: <<"add_loopback">> , Port=#Port<0.30> , OSpid="20488"
<INFO> 3-May-2023::21:26:15.436 H2201889 ncs[20011]: add_loopback :: Starting python3 -u /Users/twatanabe/nso/6.0.4//src/ncs/pyapi/ncs_pyvm/startup.py -l info -f ./logs/ncs-python-vm -i add_loopback -s alarm
<INFO> 3-May-2023::21:26:15.878 H2201889 ncs[20011]: add_loopback :: Traceback (most recent call last):
File "/Users/twatanabe/nso/6.0.4//src/ncs/pyapi/ncs_pyvm/startup.py", line 6, in <module>
import ncsctlsock
File "/Users/twatanabe/nso/6.0.4/src/ncs/pyapi/ncs_pyvm/ncsctlsock.py", line 5, in <module>
import _ncs
File "/Users/twatanabe/nso/6.0.4/src/ncs/pyapi/_ncs/__init__.py", line 12, in <module>
from ._ncs_py3 import cdb
ImportError: dlopen(/Users/twatanabe/nso/6.0.4/src/ncs/pyapi/_ncs/_ncs_py3.abi3.so, 0x0002): tried: '/Users/twatanabe/nso/6.0.4/src/ncs/pyapi/_ncs/_ncs_py3.abi3.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/local/lib/_ncs_py3.abi3.so' (no such file), '/usr/lib/_ncs_py3.abi3.so' (no such file)
<INFO> 3-May-2023::21:26:15.886 H2201889 ncs[20011]: Got EXIT on Port= #Port<0.30>
It looks like arm/x86 architecture problem
Do you have any solutions?
Solved! Go to Solution.
05-04-2023 09:22 PM
I checked my python3 architecture then it was not universal2.
twatanabe:~/nso/6.0.4/post-modifications-test/packages/ 13:15:36 $ cd /Users/twatanabe/.pyenv/versions/3.8.16/
twatanabe:~/.pyenv/versions/3.8.16/ 13:15:48 $ ls
bin include lib share
twatanabe:~/.pyenv/versions/3.8.16/ 13:15:48 $
twatanabe:~/.pyenv/versions/3.8.16/ 13:15:48 $ file bin/python3
bin/python3: Mach-O 64-bit executable arm64
As you can see, I am using pyenv and pyenv looks like compile python binary not for universal2.
I investigated how to compile python3 as universal2 with pyenv but I could not find the way.
Anyway, it is not NSO issue so I switched python3 from pyenv to local system installed from universal2 installer.
twatanabe:~/nso/6.0.4/post-modifications-test/packages/ 13:12:48 $ file /Library/Frameworks/Python.framework/Versions/3.10/bin/python3
/Library/Frameworks/Python.framework/Versions/3.10/bin/python3: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64] [arm64:Mach-O 64-bit executable arm64]
/Library/Frameworks/Python.framework/Versions/3.10/bin/python3 (for architecture x86_64): Mach-O 64-bit executable x86_64
/Library/Frameworks/Python.framework/Versions/3.10/bin/python3 (for architecture arm64): Mach-O 64-bit executable arm64
twatanabe:~/nso/6.0.4/post-modifications-test/packages/ 13:12:57 $
After do that, I could start NSO and do package reload.
Thank you for your help!
05-03-2023 10:42 AM - edited 05-03-2023 10:47 AM
The Python3 version you use when running x86_64 programs on Apple silicone, e.g., M1, must be from a universal2 installer to support both arm64 and x86_64. https://www.python.org/downloads/macos/
The pre-installed Python3 version is usually installed here:
$ type -p python3
/usr/bin/python3
Also, I added the following to my ~/.zprofile
## Useful M1 aliases
alias arm="env /usr/bin/arch -arm64 /bin/zsh --login"
alias intel="env /usr/bin/arch -x86_64 /bin/zsh --login"
and ~/.bash_profile:
## Useful M1 aliases
alias arm="env /usr/bin/arch -arm64 /bin/bash --login"
alias intel="env /usr/bin/arch -x86_64 /bin/bash --login"
When I want to run an x86_64 application, I first run the "intel" alias:
$ intel
$ source nso-6.0.4/ncsrc
05-04-2023 09:22 PM
I checked my python3 architecture then it was not universal2.
twatanabe:~/nso/6.0.4/post-modifications-test/packages/ 13:15:36 $ cd /Users/twatanabe/.pyenv/versions/3.8.16/
twatanabe:~/.pyenv/versions/3.8.16/ 13:15:48 $ ls
bin include lib share
twatanabe:~/.pyenv/versions/3.8.16/ 13:15:48 $
twatanabe:~/.pyenv/versions/3.8.16/ 13:15:48 $ file bin/python3
bin/python3: Mach-O 64-bit executable arm64
As you can see, I am using pyenv and pyenv looks like compile python binary not for universal2.
I investigated how to compile python3 as universal2 with pyenv but I could not find the way.
Anyway, it is not NSO issue so I switched python3 from pyenv to local system installed from universal2 installer.
twatanabe:~/nso/6.0.4/post-modifications-test/packages/ 13:12:48 $ file /Library/Frameworks/Python.framework/Versions/3.10/bin/python3
/Library/Frameworks/Python.framework/Versions/3.10/bin/python3: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64] [arm64:Mach-O 64-bit executable arm64]
/Library/Frameworks/Python.framework/Versions/3.10/bin/python3 (for architecture x86_64): Mach-O 64-bit executable x86_64
/Library/Frameworks/Python.framework/Versions/3.10/bin/python3 (for architecture arm64): Mach-O 64-bit executable arm64
twatanabe:~/nso/6.0.4/post-modifications-test/packages/ 13:12:57 $
After do that, I could start NSO and do package reload.
Thank you for your help!
05-08-2023 01:40 AM - edited 05-08-2023 01:40 AM
I think this is the best way to run intel NSO on an apple silicon M1: start a shell, switch to "intel mode" and then run nso.
I had problem with python VM and a mismatch of libraries: pip3 on an M1 installs aarm64 version of python packages and some mathematical packages (numpy scipy) have a library binary which is accordingly compiled for aarm64. NSO is x86_64 and it starts an x86_64 python3.9 env, but then if any python package uses any of the above mentioned mathematical libraries, start-up halts due to a mismatch of architectures.
By switching to intel mode, you can install the intel version of the library and NSO will start-up succesfully.
As a downside, if any python package uses numpy or scipy in "arm mode" it will fail again with a mismatch of architecture.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide