Leo’s resurrection story under M1macOS

Original link: https://blog.zoomquiet.io/leo-install-m1mac-story.html

Background¶

background

Leo is a literary editing environment, an excellent development/editing/thinking/… environment maintained by EKR /Ling Laozi alone for a long time;
Since I started in 2005, I have been happily using it in various scenarios.
After WindownsNT/Ubuntu/ MAC to the present macOS 12.*,
It can be said that relying on the cross-platform attributes of Python, it has been able to migrate relatively smoothly;

For example: Leo 5.2 theme custom

In fact, the official documentation: Installing Leo — Leo 6.6.2 documentation ~ Installing Leo on MacOs 10.7 (Lion) is actually a translation of my notes.

In order to solve local development and testing, and reuse the runtime to similar projects as much as possible, the management tool of choice in the past is pyenv/pyenv: Simple Python version management

Reference: Modern Python Environments – dependency and workspace management | TestDriven.io

Modern Python Environments

Habits that have been formed in the past are:

  • Using PyENV to install different versions of Python runtimes, after all, different projects are deployed on different target hosts and depend on different versions of Python
  • Based on the automatic binding mechanism of PyENV, in the corresponding directory through the instruction pyenv local [指定运行时别名]
    • You can memorize the binding relationship, and then enter the relevant directory, and the runtime switch will be automatically completed.
    • No need to explicitly run activation commands manually like other tools
  • After entering the corresponding environment, use pip for standard module dependency management

The overall effect can be achieved:

  • Local and production environments can deploy the same PyENV environment
  • Support for different versions of Python runtime
  • Support different projects to have their own module dependency tree, isolated from other projects
  • Support different projects, if the fields are close, you can bind the PyENV environment of other projects to save the repeated installation of the same module
  • …ie: Python runtime version/project directory/project dependencies can be configured/managed relatively independently
    • Moreover, it is worth emphasizing that for the configured environment, when cd enters, the switch is automatically completed
    • At the same time, all customized operating environments are uniformly installed in the specified directory and have nothing to do with the project directory, so there is no need for special git ignore configuration

Troubles¶

question

However, after upgrading the hardware to the new MBP chip M1max earlier this year, there have been problems:

Reference: How to settle into M1maxMBP / Ye Yehu ( ̄▽ ̄) / ZoomQuiet.io

Although I was lucky to use the official migration tool at that time, almost 94.2% of the environment and data were automatically migrated successfully;
Due to the different underlying chips, although the Python local runtime environment can be used in the past,
However, it is not possible to further install a new version of the Python runtime, and upgrade Leo to the latest version…

specific:

  • The PyENV environment that was originally installed/configured on the Intel chip can run
    • However, the new version of the Python environment cannot be installed
    • It is also impossible to install new modules using pip in the corresponding environment.
  • The miniconda environment that was originally installed/configured in the Intel chip can run
    • However, conda info error
  • .. It feels like only a small set of snaps can be used, not two complete and controllable Python runtime management environments

Goal¶

Target

To restore control of the local Python environment:

  • You can freely install multiple versions of the Python runtime
  • You can bind different module dependency trees for different projects, of course, you can also reuse the same
  • Can install and run the latest Leo version
    • Currently available is 5.9-b2
    • The official version is already 6.6.2

Tracing¶

explore

Current environment:

screenfetch

Try PyENV¶

Everything is normal, in fact, it relies on the [email protected] installed by brew to complete the bootstrapping

 Python 3.9.8 (main, Nov 10 2021, 03:55:42) [Clang 13.0.0 (clang-1300.0.29.3)] on darwin

Unfortunately, try to install other versions of Python environment through the pyenv install command,
I have encountered compilation failure, repeated exploration, and used all the tricks on the Internet, but I still can’t solve it.

Try miniconda¶

It is suspected that the compilation scripts prepared by PyENV are all for the Intel background

So, turn your attention to Anaconda again, knowing that this project can not only manage the Python environment, but also manage various other runtime environments, including rust/haskell/… which can be deployed consistently through conda instructions,
Moreover, it has been pre-compiled for different platforms in advance, without tossing locally, directly download and expand it;

Moreover, after entering the conda runtime environment, you can continue to use conda commands to install related modules, or you can use pip to download and install from PyPI…

The only thing inferior to PyENV is the conda environment, which must be activated manually and cannot be automatically bound;

Before miniconda was manually installed, now there is a new arm version brew environment,
Reference: Using Homebrew on an M1 Chip Mac – Minority

Standard installation:

 abrew install miniconda

Because of the multi-homebrew environment configuration:

  • ibrew points to the Intel version homebrew migrated from the old system
  • abrew points to a freshly installed ARM version of homebrew

Then, you can probe which Python versions are currently supported:

 $ conda search "^Python $ " Loading channels: done # Name Version Build Channel python 3 .8.11 hbdb9e5c_5 pkgs/main python 3 .8.13 hbdb9e5c_0 pkgs/main python 3 .9.6 hc70090a_5 pkgs/main python 3 .9.7 hc70090a_1 pkgs/main python 3 .9.11 hbdb9e5c_1 pkgs/main python 3 .9.11 hbdb9e5c_2 pkgs/main python 3 .9.12 hbdb9e5c_0 pkgs/main python 3 .10.0 hbdb9e5c_1 pkgs/main python 3 .10.0 hbdb9e5c_2 pkgs/main python 3 .10.0 hbdb9e5c_3 pkgs/main python 3 .10.0 hbdb9e5c_5 pkgs/main python 3 .10.3 hbdb9e5c_5 pkgs/main python 3 .10.4 hbdb9e5c_0 pkgs/main

Install a Leo-specific environment:

 $ conde create -n leo3811 python = 3 .8.11

Enter by command:

 $ conda activate leo3811

By installing pip_search in advance, you can search whether the configured PyPI image contains Leo:

pip_search

Install Leo via pip:

 $ pip install leo 

PyQt

During the process, many compilation errors can be observed,
However, the install script is smart enough to drop version by version to try and eventually be compatible;
Once installed, try running:

 $ leo leoQt . py : can not fully import PyQt5. Traceback ( most recent call last ): File "/opt/homebrew/Caskroom/miniconda/base/envs/leo3811/lib/python3.8/site-packages/leo/core/leoQt.py" , line 55 , in < module > from PyQt5 import QtCore ModuleNotFoundError : No module named 'PyQt5.sip' Traceback ( most recent call last ): File "/opt/homebrew/Caskroom/miniconda/base/envs/leo3811/bin/leo" , line 5 , in < module > from leo.core.runLeo import run File "/opt/homebrew/Caskroom/miniconda/base/envs/leo3811/lib/python3.8/site-packages/leo/core/runLeo.py" , line 27 , in < module > leoGlobals . app = leoApp . LeoApp () File "/opt/homebrew/Caskroom/miniconda/base/envs/leo3811/lib/python3.8/site-packages/leo/core/leoApp.py" , line 334 , in __init__ import leo.core.leoFrame as leoFrame File "/opt/homebrew/Caskroom/miniconda/base/envs/leo3811/lib/python3.8/site-packages/leo/core/leoFrame.py" , line 13 , in < module > import leo.core.leoColorizer as leoColorizer File "/opt/homebrew/Caskroom/miniconda/base/envs/leo3811/lib/python3.8/site-packages/leo/core/leoColorizer.py" , line 18 , in < module > from leo.core.leoQt import Qsci , QtGui , QtWidgets File "/opt/homebrew/Caskroom/miniconda/base/envs/leo3811/lib/python3.8/site-packages/leo/core/leoQt.py" , line 88 , in < module > qt_version = QtCore . QT_VERSION_STR NameError : name 'QtCore' is not defined

No way, ask Leo official mailling-list: https://ift.tt/hVPxLv9

Soon, [email protected] suggested:

this looks like a problem with Qt or PyQt, not leo per se. possibilities:

  • try to install PyQt6 on its own (without the rest of leo);
  • try to install an earlier version of PyQt6, if you can figure out which ones are available;
  • try installing PyQt5 instead of PyQt6 (Leo can use either one);
  • install python 3.9 and see whether PyQt6 or PyQt5 will install without errors.

PyQt¶

Thinking about Qt is a magical thing…

When doing desktop development before, PyQt could not be simply installed, and the corresponding search

Domestic users must first configure the conda source:

 $ conda config --set show_channel_urls yes

After generating the ~/.condarc file, modify it accordingly. For example, I am currently:

 auto_activate_base : true report_errors : true show_channel_urls : true channels :  - defaults default_channels :  - http :// mirrors . aliyun . com /anaconda/pkgs/ main  - http :// mirrors . aliyun . com /anaconda/pkgs/ r  - http :// mirrors . aliyun . com /anaconda/pkgs/ msys2  - https :// repo . anaconda . com /pkgs/ main  - https :// repo . anaconda . com /pkgs/ r  - https :// repo . anaconda . com /pkgs/ msys2 custom_channels :  conda - forge : http :// mirrors . aliyun . com /anaconda/ cloud  msys2 : http :// mirrors . aliyun . com /anaconda/ cloud  bioconda : http :// mirrors . aliyun . com /anaconda/ cloud  menpo : http :// mirrors . aliyun . com /anaconda/ cloud  pytorch : http :// mirrors . aliyun . com /anaconda/ cloud  simpleitk : http :// mirrors . aliyun . com /anaconda/ cloud
  conda create - n leo3911 python = 3.9 . 11 Collecting package metadata ( current_repodata . json ): done Solving environment : failed with repodata from current_repodata . json , will retry with next repodata source . Collecting package metadata ( repodata . json ): done Solving environment : done ## Package Plan ##  environment location : / opt / homebrew / Caskroom / miniconda / base / envs / leo3911  added / updated specs :    - python = 3.9 . 11 The following packages will be downloaded :    package                    |            build    ---------------------------|-----------------    python - 3.9 . 11              |       hbdb9e5c_2        10.1 MB  defaults    ------------------------------------------------------------                                           Total :        10.1 MB The following NEW packages will be INSTALLED :  ca - certificates    pkgs / main / osx - arm64 :: ca - certificates - 2022.4 . 26 - hca03da5_0  certifi            anaconda / pkgs / main / noarch :: certifi - 2020.6 . 20 - pyhd3eb1b0_3  libcxx             pkgs / main / osx - arm64 :: libcxx - 12.0 . 0 - hf6beb65_1  libffi             pkgs / main / osx - arm64 :: libffi - 3.4 . 2 - hc377ac9_2  ncurses            pkgs / main / osx - arm64 :: ncurses - 6.3 - h1a28f6b_2  openssl            pkgs / main / osx - arm64 :: openssl - 1.1 . 1 o - h1a28f6b_0  pip                pkgs / main / osx - arm64 :: pip - 21.2 . 4 - py39hca03da5_0  python             pkgs / main / osx - arm64 :: python - 3.9 . 11 - hbdb9e5c_2  readline           pkgs / main / osx - arm64 :: readline - 8.1 . 2 - h1a28f6b_1  setuptools         pkgs / main / osx - arm64 :: setuptools - 61.2 . 0 - py39hca03da5_0  sqlite             pkgs / main / osx - arm64 :: sqlite - 3.38 . 3 - h1058600_0  tk                 pkgs / main / osx - arm64 :: tk - 8.6 . 11 - hb8d0fd4_1  tzdata             anaconda / pkgs / main / noarch :: tzdata - 2022 a - hda174b7_0  wheel              anaconda / pkgs / main / noarch :: wheel - 0.37 . 1 - pyhd3eb1b0_0  xz                 pkgs / main / osx - arm64 :: xz - 5.2 . 5 - h1a28f6b_1  zlib               pkgs / main / osx - arm64 :: zlib - 1.2 . 12 - h5a0b063_2 Proceed ([ y ] / n ) ? Downloading and Extracting Packages python - 3.9 . 11        | 10.1 MB   | ##################################################################################################################################### | 100% Preparing transaction : done Verifying transaction : done Executing transaction : done # # To activate this environment, use # # $ conda activate leo3911 # # To deactivate an active environment, use # # $ conda deactivate

Check the installation results:

 $ conda env list # conda environments: # base * /opt/homebrew/Caskroom/miniconda/base leo3811 /opt/homebrew/Caskroom/miniconda/base/envs/leo3811 leo3911 /opt/homebrew/Caskroom/miniconda/base/envs/leo3911
 $ conda install PyQt Collecting package metadata ( current_repodata . json ) : done Solving environment : done ## Package Plan ##  environment location : / opt / homebrew / Caskroom / miniconda / base / envs / leo3811  added / updated specs :    - pyqt The following NEW packages will be INSTALLED :  adwaita - icon - theme pkgs / main / osx - arm64 : : adwaita - icon - theme - 40.1.1 - hca03da5_1  atk - 1.0            pkgs / main / osx - arm64 : : atk - 1.0 - 2.36.0 - h7fe96df_0  cairo              pkgs / main / osx - arm64 : : cairo - 1.16.0 - h0ab239c_1  dbus               pkgs / main / osx - arm64 : : dbus - 1.13.18 - h8280c03_0  epoxy              pkgs / main / osx - arm64 : : epoxy - 1.5.4 - h1a28f6b_2  expat              pkgs / main / osx - arm64 : : expat - 2.4.4 - hc377ac9_0  fontconfig         pkgs / main / osx - arm64 : : fontconfig - 2.13.1 - h1f4a5ec_0  freetype           pkgs / main / osx - arm64 : : freetype - 2.11.0 - h1192e45_0  fribidi            pkgs / main / osx - arm64 : : fribidi - 1.0.10 - h1a28f6b_0  gdk - pixbuf         pkgs / main / osx - arm64 : : gdk - pixbuf - 2.42.6 - h74ef11a_4  gettext            pkgs / main / osx - arm64 : : gettext - 0.21.0 - h826f4ad_0  giflib             pkgs / main / osx - arm64 : : giflib - 5.2.1 - h1a28f6b_0  glib               pkgs / main / osx - arm64 : : glib - 2.69.1 - h98b2900_1  gobject - introspec ~ pkgs / main / osx - arm64 : : gobject - introspection - 1.68.0 - py38h3459c9f_3  graphite2          pkgs / main / osx - arm64 : : graphite2 - 1.3.14 - h0e5e14a_0  gtk3               pkgs / main / osx - arm64 : : gtk3 - 3.24.21 - h321fa23_1  harfbuzz           pkgs / main / osx - arm64 : : harfbuzz - 2.8.1 - hffeda63_0  hicolor - icon - theme pkgs / main / osx - arm64 : : hicolor - icon - theme - 0.17 - hca03da5_2  icu                pkgs / main / osx - arm64 : : icu - 68.1 - hc377ac9_0  jpeg               pkgs / main / osx - arm64 : : jpeg - 9 e - h1a28f6b_0  krb5               pkgs / main / osx - arm64 : : krb5 - 1.19.2 - h3b8d789_0  libedit            pkgs / main / osx - arm64 : : libedit - 3.1.20210910 - h1a28f6b_0  libevent           pkgs / main / osx - arm64 : : libevent - 2.1.12 - hf27765b_0  libiconv           pkgs / main / osx - arm64 : : libiconv - 1.16 - h1a28f6b_2  libpng             pkgs / main / osx - arm64 : : libpng - 1.6.37 - hb8d0fd4_0  libpq              pkgs / main / osx - arm64 : : libpq - 12.9 - h65cfe13_1  librsvg            pkgs / main / osx - arm64 : : librsvg - 2.50.7 - h90a7944_0  libtiff            pkgs / main / osx - arm64 : : libtiff - 4.2.0 - h01837e1_1  libwebp            pkgs / main / osx - arm64 : : libwebp - 1.2.2 - h68602c7_0  libwebp - base       pkgs / main / osx - arm64 : : libwebp - base - 1.2.2 - h1a28f6b_0  libxml2            pkgs / main / osx - arm64 : : libxml2 - 2.9.14 - h8c5e841_0  libxslt            pkgs / main / osx - arm64 : : libxslt - 1.1.34 - h9833966_0  llvm - openmp        pkgs / main / osx - arm64 : : llvm - openmp - 12.0.0 - haf9daa7_1  lz4 - c              pkgs / main / osx - arm64 : : lz4 - c - 1.9.3 - hc377ac9_0  ninja              pkgs / main / osx - arm64 : : ninja - 1.10.2 - hca03da5_5  ninja - base         pkgs / main / osx - arm64 : : ninja - base - 1.10.2 - h525c30c_5  nspr               pkgs / main / osx - arm64 : : nspr - 4.33 - hc377ac9_0  nss                pkgs / main / osx - arm64 : : nss - 3.74 - h142855e_0  pango              pkgs / main / osx - arm64 : : pango - 1.48.7 - h79d33a7_0  pcre               pkgs / main / osx - arm64 : : pcre - 8.45 - hc377ac9_0  pixman             pkgs / main / osx - arm64 : : pixman - 0.40.0 - h1a28f6b_0  pyqt               pkgs / main / osx - arm64 : : pyqt - 5.15.2 - py38he8f2410_0  qt                 pkgs / main / osx - arm64 : : qt - 5.15.2 - h4e944ae_2  zstd               pkgs / main / osx - arm64 : : zstd - 1.5.2 - h8574219_0 Proceed ( [ y ]/ n ) ?

$ pip install leo

PyQtWebEngine

There are also installation failures and continuous automatic downgrades…

Finally successfully installed:

  • Successfully built lazy-object-proxy wrapt tornado
  • Installing collected packages: zipp, wrapt, typing-extensions, traitlets, pytz, pyrsistent, MarkupSafe, lazy-object-proxy, dialite, attrs, webruntime, tornado, tomli, sphinxcontrib-serializinghtml, sphinxcontrib-qthelp, sphinxcontrib-jsmath, sphinxcontrib- htmlhelp, sphinxcontrib-devhelp, sphinxcontrib-applehelp, snowballstemmer, pscript, platformdirs, mccabe, jupyter-core, jsonschema, Jinja2, isort, importlib-metadata, imagesize, fastjsonschema, docutils, dill, babel, astroid, alabaster, sphinx, six, pylint, pyflakes, nbformat, future, flexx, leo
  • Successfully installed Jinja2-3.1.2 MarkupSafe-2.1.1 alabaster-0.7.12 astroid-2.11.5 attrs-21.4.0 babel-2.10.1 dialite-0.5.3 dill-0.3.5.1 docutils-0.17.1 fastjsonschema-2.15 .3 flexx-0.8.4 future-0.18.2 imagesize-1.3.0 importlib-metadata-4.11.4 isort-5.10.1 jsonschema-4.5.1 jupyter-core-4.10.0 lazy-object-proxy-1.7.1 leo-5.9 mccabe-0.7.0 nbformat-5.4.0 platformdirs-2.5.2 pscript-0.7.7 pyflakes-2.4.0 pylint-2.13.9 pyrsistent-0.18.1 pytz-2022.1 six-1.16.0 snowballstemmer-2.2. 0 sphinx-4.5.0 sphinxcontrib-applehelp-1.0.2 sphinxcontrib-devhelp-1.0.2 sphinxcontrib-htmlhelp-2.0.0 sphinxcontrib-jsmath-1.0.1 sphinxcontrib-qthelp-1.0.3 sphinxcontrib-serializinghtml-1.1.5 tomli- 2.0.1 tornado-6.1 traitlets-5.2.1.post0 typing-extensions-4.2.0 webruntime-0.5.8 wrapt-1.14.1 zipp-3.8.0

However, the runtime gives a magic error:

 $ leo Sorry, "python" cannot be run on this version of macOS. Qt requires macOS 11 .1.0 or later, you have macOS 10 .16.0.

Mixed installation:

Decisively M1 environment is currently the most reliable brew system

Reference: How to install pyqt5 of python on MacBook Pro m1 version? – Know almost

  • First use abrew install pyqt@5 to complete the Qt installation for the ARM environment
  • Then manually copy the corresponding installed lib to the corresponding conda environment
    • For example, recreate the dedicated environment
    • conda create -n leo3912 python=3.9.12
  • Then, the manual copy is:
    • All directories in /opt/homebrew/Cellar/pyqt@5/5.15.6/lib/python3.9/site-packages/
    • to /opt/homebrew/Caskroom/miniconda/base/envs/leo3912/lib/python3.9/site-packages/

Include:

 PyQt3D-5.15.5.dist-info PyQt5 PyQt5-5.15.6.dist-info PyQt5_sip-12.9.0-py3.9.egg-info PyQtChart-5.15.5.dist-info PyQtDataVisualization-5.15.5.dist-info PyQtNetworkAuth-5.15.5.dist-info PyQtPurchasing-5.15.5.dist-info

Download the latest source code package from the official Latest link and deploy it to /opt/bin

Then, call in the corresponding environment:

 ( conda : leo3912 ) $ python / opt / bin / leo / launchLeo . py setting leoID from os . getenv ( 'USER' ): 'zoomq' PYLINTHOME is now '/Users/zoomq/Library/Caches/pylint' but obsolescent '/Users/zoomq/.pylint.d' is found ; you can safely remove the latter duplicate , ( not conflicting ) key bindings in myLeoSettings . leo all    Alt + ) move - past - close all    Alt + ) move - past - close duplicate , ( not conflicting ) key bindings in myLeoSettings . leo all    Alt + } forward - paragraph all    Alt + } forward - paragraph - extend - selection duplicate , ( not conflicting ) key bindings in myLeoSettings . leo all    Ctrl + ( add - comments all    Ctrl + ( add - comments duplicate , ( not conflicting ) key bindings in myLeoSettings . leo all    Ctrl + ) delete - comments all    Ctrl + ) delete - comments all    Ctrl + ) delete - comments duplicate , ( not conflicting ) key bindings in myLeoSettings . leo all    Ctrl + { promote all    Ctrl + { promote duplicate , ( not conflicting ) key bindings in myLeoSettings . leo all    Ctrl + } demote all    Ctrl + } demote Leo 6.6 . 2 Python 3.9 . 12 , PyQt version 5.15 . 3 darwin expand_css_constants Unresolved @ constants [    '@bookmarks_base_decoration' ,    '@bookmarks_children_family' ,    '@bookmarks_base_border' ,    '@bookmarks_base_family' ,    '@checkbox-font-family' ,    '@dialog-font-family' ,    '@dialog-font-weight' ,    '@status-font-family' ,    '@dialog-font-style' ,    '@dialog-font-size' ] qt . qpa . fonts : Populating font family aliases took 163 ms . Replace uses of missing font family "Monoid Retina" with one that exists to avoid this cost . not found : '@auto 4py3ch.md' not found : '@auto 4py4ch.md' not found : '@auto 4py5ch.md' not found : '@auto 4py6ch.md' not found : '@auto 4pyend.md' not found : / Users / zoomq / Sites / 101. camp / utility / announcer / tasks . py not found : / Users / zoomq / Sites / 101. camp / utility / pol / camp . yaml not found : / Users / zoomq / Sites / 101. camp / utility / pol / st . py not found : / Users / zoomq / Sites / 101. camp / utility / pol / tasks . py not found : / Users / zoomq / Sites / 101. camp / utility / pow / tasks . py not found : / Users / zoomq / Sites / 101. camp / _course / 101 camp1py / pow / tasks . py expand_css_constants Unresolved @ constants [    '@bookmarks_base_decoration' ,    '@bookmarks_children_family' ,    '@bookmarks_base_border' ,    '@bookmarks_base_family' ,    '@checkbox-font-family' ,    '@dialog-font-family' ,    '@dialog-font-weight' ,    '@status-font-family' ,    '@dialog-font-style' ,    '@dialog-font-size' ] expand_css_constants Unresolved @ constants [    '@bookmarks_base_decoration' ,    '@bookmarks_children_family' ,    '@bookmarks_base_border' ,    '@bookmarks_base_family' ,    '@checkbox-font-family' ,    '@dialog-font-family' ,    '@dialog-font-weight' ,    '@status-font-family' ,    '@dialog-font-style' ,    '@dialog-font-size' ] wrote / Users / zoomq /. leo / leo . session wrote recent file : / Users / zoomq /. leo /. leoRecentFiles . txt 

Leo 6.6.2

Once it can start normally, wrap the directive as an alias:

Append ~/.bash_profile :

 alias leo6lanch="python /opt/bin/leo/launchLeo.py >> /dev/null 2>&1 &"

It is called in two steps in the terminal every day:

 $ conda activate leo3912 $ leo6lanch

PS :

If you install leo above and run it directly in the conda environment, you will find:

 $  leo Traceback ( most recent call last ):  File "/opt/homebrew/Caskroom/miniconda/base/envs/leo3912/bin/leo" , line 8 , in < module >    sys . exit ( run ())  File "/opt/homebrew/Caskroom/miniconda/base/envs/leo3912/lib/python3.9/site-packages/leo/core/runLeo.py" , line 72 , in run    g . app . loadManager . load ( fileName , pymacs )  File "/opt/homebrew/Caskroom/miniconda/base/envs/leo3912/lib/python3.9/site-packages/leo/core/leoApp.py" , line 2252 , in load    t1 = time . clock () AttributeError : module 'time' has no attribute 'clock'

After code inspection, it was found that time.clock() has been deprecated after Py3.8,
In other words, the latest version of Leo must not contain such a function,
That is, during the pip installation process, for compatibility, it was automatically downgraded to an old version… After exploration:

/opt/homebrew/Caskroom/miniconda/base/envs/leo3912/lib/python3.9/site-packages/leo/core/leoVersion.py

Decisively written 5.9-b2 , is the 19th version;

Summary¶

summary

It looks complicated, but in fact, after exploring various possibilities, I know how to install Leo in the macOS environment of the M1 chip reasonably:

  • Install PyQt@5 based on arm version homebrew
  • Install other dependencies based on miniconda’s Py3.9 environment
  • Start based on launchLeo.py in the official source code

Specific key instructions:

The following similar configuration should be found in ~/.bash_profile :

 # >>> conda initialize >>> # !! Contents within this block are managed by 'conda init' !! __conda_setup = "$('/opt/homebrew/Caskroom/miniconda/base/bin/conda' 'shell.bash' 'hook' 2> /dev/null)" if [ $ ? - eq 0 ]; then    eval "$__conda_setup" else    if [ - f "/opt/homebrew/Caskroom/miniconda/base/etc/profile.d/conda.sh" ]; then        . "/opt/homebrew/Caskroom/miniconda/base/etc/profile.d/conda.sh"    else        export PATH = "/opt/homebrew/Caskroom/miniconda/base/bin:$PATH"    fi fi unset __conda_setup # <<< conda initialize <<<
  • Use conda info to check whether the current environment is normal
  • Then, create the Leo private environment:
    • conda create -n leo3912 python=3.9.12
    • Note that the [email protected] environment is installed by default in the current brew environment, so the corresponding conda environment should also be above 3.9
  • Manually copy the PyQt package from the brew environment to the corresponding conda environment, for example:
    • All directories in /opt/homebrew/Cellar/pyqt@5/5.15.6/lib/python3.9/site-packages/
    • to /opt/homebrew/Caskroom/miniconda/base/envs/leo3912/lib/python3.9/site-packages/
  • Manually download and deploy the latest Leo source code from github
  • Then, call launchLeo.py from the conda environment
  • Once it can start normally, wrap the directive as an alias:

Append ~/.bash_profile :

 alias leo6lanch="python /opt/bin/leo/launchLeo.py >> /dev/null 2>&1 &"

It is called in two steps in the terminal every day:

 $ conda activate leo3912 $ leo6lanch

logging¶

  • 220529 Organized into articles
  • 220528 miniconda success
  • 220527 Decided to start over
  • 220506 tried again, failed
  • 220401 Tried, failed
  • 211113 Triggered, Doubtful

This article is reprinted from: https://blog.zoomquiet.io/leo-install-m1mac-story.html
This site is for inclusion only, and the copyright belongs to the original author.

Leave a Comment