Last active
August 22, 2021 02:33
-
-
Save a-voronov/f47c367a84d876748e9f42bccaa7e447 to your computer and use it in GitHub Desktop.
OpenCV Courses - Jupyter + Python on Big Sur M1 arm64
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
appnope==0.1.2 | |
argon2-cffi==20.1.0 | |
attrs==21.2.0 | |
backcall==0.2.0 | |
bleach==4.0.0 | |
certifi==2021.5.30 | |
cffi==1.14.6 | |
cycler==0.10.0 | |
debugpy==1.4.1 | |
decorator==4.4.2 | |
defusedxml==0.7.1 | |
docutils==0.17.1 | |
entrypoints==0.3 | |
importlib-metadata==4.0.1 | |
imutils==0.5.4 | |
ipykernel==6.2.0 | |
ipython==7.24.1 | |
ipython-genutils==0.2.0 | |
ipywidgets==7.6.3 | |
jedi==0.17.2 | |
Jinja2==3.0.1 | |
joblib==1.0.1 | |
jsonschema==3.2.0 | |
jupyter==1.0.0 | |
jupyter-client==7.0.1 | |
jupyter-console==6.4.0 | |
jupyter-core==4.7.1 | |
jupyterlab-pygments==0.1.2 | |
jupyterlab-widgets==1.0.0 | |
kiwisolver==1.3.1 | |
lz4==3.1.3 | |
MarkupSafe==2.0.1 | |
matplotlib==3.4.2 | |
matplotlib-inline==0.1.2 | |
mistune==0.8.4 | |
mock==4.0.3 | |
more-itertools==8.8.0 | |
nbclient==0.5.4 | |
nbconvert==6.1.0 | |
nbformat==5.1.3 | |
nest-asyncio==1.5.1 | |
notebook==6.4.3 | |
numpy==1.20.3 | |
olefile==0.46 | |
packaging==21.0 | |
pandocfilters==1.4.3 | |
parso==0.8.1 | |
path.py==12.0.1 | |
pbr==5.6.0 | |
pexpect==4.8.0 | |
pickleshare==0.7.5 | |
Pillow==8.3.1 | |
pip==21.2.4 | |
prometheus-client==0.11.0 | |
prompt-toolkit==3.0.19 | |
ptyprocess==0.7.0 | |
pycparser==2.20 | |
Pygments==2.9.0 | |
pyparsing==2.4.7 | |
pyrsistent==0.18.0 | |
python-dateutil==2.8.2 | |
pytz==2021.1 | |
pyzmq==22.2.1 | |
qtconsole==5.1.1 | |
QtPy==1.10.0 | |
scikit-learn==0.24.1 | |
scipy==1.6.3 | |
Send2Trash==1.8.0 | |
setuptools==57.2.0.post0 | |
six==1.16.0 | |
terminado==0.11.1 | |
testpath==0.5.0 | |
threadpoolctl==2.2.0 | |
toml==0.10.2 | |
tornado==6.1 | |
traitlets==5.0.5 | |
wcwidth==0.2.5 | |
webencodings==0.5.1 | |
wheel==0.37.0 | |
widgetsnbextension==3.5.1 | |
zipp==3.4.1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with import <nixpkgs> { localSystem = "aarch64-darwin"; }; | |
let | |
pythonPackages = python38Packages; | |
in pkgs.mkShell rec { | |
name = "opencvCoursesPythonEnv"; | |
venvDir = "./.venv"; | |
buildInputs = [ | |
# A Python interpreter including the 'venv' module is required to bootstrap the environment. | |
pythonPackages.python | |
# fails to install with pip | |
pythonPackages.scipy | |
pythonPackages.scikit-learn | |
# pythonPackages.scikitimage | |
# easier to install here | |
pythonPackages.matplotlib | |
pythonPackages.numpy | |
pythonPackages.ipython | |
pythonPackages.opencv4 | |
# This execute some shell code to initialize a venv in $venvDir before | |
# dropping into the shell | |
pythonPackages.venvShellHook | |
]; | |
packages = [ | |
clang_12 | |
libffi | |
# These are needed if installing matplotlib with pip | |
# also check this one https://github.com/matplotlib/matplotlib/issues/20661#issuecomment-889189712 | |
# | |
# openblas | |
# libjpeg | |
# freetype | |
# xz | |
# pkgs.darwin.apple_sdk.frameworks.frameworks.Cocoa | |
]; | |
# Run this command, only after creating the virtual environment | |
postVenvCreation = '' | |
unset SOURCE_DATE_EPOCH | |
python -m pip install --upgrade pip | |
python -m pip install -r requirements-arm64.txt | |
# Check if it's still needed for arm64 setup | |
# | |
# Fixing iPython Kernel + Jupyter on Apple M1 Big Sur ... | |
# https://github.com/minrk/appnope/issues/12#issuecomment-741625144 | |
ipythonConfDir=~/.ipython/profile_default | |
ipythonConf=~/.ipython/profile_default/ipython_kernel_config.py | |
ipythonFix="c.Kernel._darwin_app_nap = False" | |
mkdir -p $ipythonConfDir | |
if ! grep -q "$ipythonFix" "$ipythonConf"; then | |
echo "$ipythonFix" >> $ipythonConf | |
fi | |
unset ipythonConfDir | |
unset ipythonConf | |
unset ipythonFix | |
''; | |
# For the first-time use, run these commands if there's no requirements-arm64.txt | |
# python -m pip install setuptools wheel jupyter imutils | |
# | |
# Freeze requirements using format from list to avoid nix paths https://stackoverflow.com/a/62886215/1376429 | |
# pip list --format=freeze > requirements-arm64.txt | |
# Now we can execute any commands within the virtual environment. | |
# This is optional and can be left out to run pip manually. | |
postShellHook = '' | |
# allow pip to install wheels | |
unset SOURCE_DATE_EPOCH | |
''; | |
} | |
# There's a known issue on macOS Big Sur caused by send2trash package when running `jupyter notebook`: | |
# > AttributeError: dlsym(RTLD_DEFAULT, GetMacOSStatusCommentString): symbol not found | |
# | |
# These are the current hotfixes: | |
# https://github.com/arsenetar/send2trash/issues/51#issuecomment-858111428 | |
# https://github.com/jupyter/notebook/pull/6016#issuecomment-858164229 | |
# TL;DR: make sure to include `pyobjc-framework-Cocoa==7.3 send2trash==1.7.1` into requirements.txt | |
# Also, consider trying jupyterWith from tweag (but it has same issue): | |
# https://github.com/tweag/jupyterWith/issues/144 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment