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

vpype[all] can't be installed on Mac OSX on ARM based Macs (M1) #320

Closed
theomega opened this issue Oct 16, 2021 · 32 comments
Closed

vpype[all] can't be installed on Mac OSX on ARM based Macs (M1) #320

theomega opened this issue Oct 16, 2021 · 32 comments

Comments

@theomega
Copy link
Contributor

theomega commented Oct 16, 2021

Edit by @abey79:

Thanks to MacPorts now properly supporting pyside2 and its dependences (in particular qt5-qtwebengine, thanks @chrstphrchvz!), this issue is now resolved. The install procedure is as follows:

Install/upgrade MacPorts

If you don't have MacPorts installed, install it from here. You will need to install Xcode if you haven't already.

If you had MacPorts previously installed, make sure its package database is up-to-date:

sudo port selfupdate
sudo port upgrade outdated

Install required packages

sudo port install python39 py39-shapely py39-scipy py39-numpy py39-pyside2

(optional) Make Python 3.9 the default interpreter

This is not strictly necessary, but this step will make python point towards MacPorts' Python 3.9.x.

sudo port select --set python python39

Create a virtual environment for vpype

cd path/where/the/venv/should/be
/opt/local/bin/python3.9 -m venv vpype_venv --system-site-packages

Important: note the use of --system-site-packages. This will make the MacPorts-installed package (in particular pyside2) available to the virtuel environment. This is critically important because pip is unable to install PySide2 on arm64 Macs (this will likely never change).

Using the full path for the python interpreter is not needed if python points to the right interpreter (ie. you did the previous step and your PATH is not messed up.

Activate the virtual environment and install vpype

source vpype_venv/bin/activate
pip install "vpype[all]"

Check that the install was successful:

vpype random show

original message by @theomega

This is very likely not vpypes fault, but you can't install vpype using pip on Mac OSX if your machine is one of the new m1 based arm machines.

Reason is that the PySides2 package can't be installed on these machines as there is no official port of QT python bindings for the M1 yet.

Error Message:

ERROR: Cannot install vpype[all]==1.4.0, vpype[all]==1.5.0, vpype[all]==1.5.1, vpype[all]==1.6.0 and vpype[all]==1.7.0 because these package versions have conflicting dependencies.

The conflict is caused by:
    vpype[all] 1.7.0 depends on PySide2<6.0.0 and >=5.15.2; extra == "all"
    vpype[all] 1.6.0 depends on PySide2<6.0.0 and >=5.15.2
    vpype[all] 1.5.1 depends on PySide2<6.0.0 and >=5.15.2
    vpype[all] 1.5.0 depends on PySide2<6.0.0 and >=5.15.2
    vpype[all] 1.4.0 depends on PySide2<6.0.0 and >=5.15.2

Manual install of PySide2:

$ pip install PySide2
ERROR: Could not find a version that satisfies the requirement PySide2 (from versions: none)
ERROR: No matching distribution found for PySide2

Some more information can be found on the QT Forum here:
https://forum.qt.io/topic/124289/mac-m1-pyside-2-6-can-t-install-lib

@abey79
Copy link
Owner

abey79 commented Oct 17, 2021

Yes, this is a pity and I hope it get fixed soon.

The workarounds are:

  • use vpype (not vpype[all]), thereby loosing the show command
  • manually build pyside2 for ARM Mac (I'll most likely get one of the newer MacBook Pro to be announced tomorrow -- I'll be able to explore this way whenever I get it)
  • manually pip install matplotlib on top of a base vpype install to access the classic viewer

Side note: my preferred python distrib being MacPort, I'll be tracking ARM availability here.

@abey79 abey79 changed the title vypye can't be installed on Mac OSX on ARM based Macs (M1) vpype[all] can't be installed on Mac OSX on ARM based Macs (M1) Oct 28, 2021
@abey79
Copy link
Owner

abey79 commented Oct 28, 2021

FYI, I just got a new M1 Max MBP and I'm actively researching this issue. My current understanding is that the situation will take some time to fully normalise, but there may be ways to get this sorted "manually" in the mean time. I'll post here whenever I have such a method sorted out.

WIP notes/pointers:

  • The official Qt 6.2.1 distribution is intel/apple universal, but 5.15.2 is not.
  • I already managed to build pyside6 from source based on the official qt build. Next: make a branch of vpype based on PySide6.
  • edit: pyside6-based vpype is tricky as the integration with ModernGL must be adapted
  • My attempt to build pyside2 from source failed.
  • qt6 in MacPorts in in the work: qt6: Add initial qt6 ports macports/macports-ports#12676
  • my attempts with installing pyside2 with Homebrew failed

@rcyrus
Copy link

rcyrus commented Nov 11, 2021

For what its worth, I am using miniforge which seems to have a good amount of M1 binaries in its channel, with the exception of PySide2.

I too was able to build PySide6 from source and gave the WIP vpype pyside6 branch a try and was able to get almost everything to work. The view window opens but without a render in it. I also used the pyside6 version of vpype with vsketch with similar results. No render shows but I am able to modify parameters and save sketches.

@abey79
Copy link
Owner

abey79 commented Nov 12, 2021

Indeed the issue with Qt6 is that QGLWidget has been removed in favour of a new QOpenGLWidget. The way external renderer/GL librairies (in this case, ModernGL) are interfaced is one of the main difference and more complicated than before. The current integration is currently broken, which is why the display is blank. This is something I'm looking at but in the mean time MacPort has made great progress with Qt5 on M1/Monterey (though issues remain), so PySide2 is still an option for me.

@abey79
Copy link
Owner

abey79 commented Nov 18, 2021

Edit: updated required package list based on @abruto's feedback.
Edit: added forced submodule updated based on @abruto's feedback.

I just managed to get everything running on Monterey/M1 using the following procedure

TL;DR

  • Python, Qt5 and librairies from MacPorts
  • PySide2 5.15.2 compiled from source

Install/upgrade MacPorts

If you don't have MacPorts installed, install it from here. You will need to install Xcode if you haven't already.

If you had MacPorts previously installed, make sure its package database is up-to-date:

sudo port selfupdate
sudo port upgrade outdated

Install required packages

sudo port install python39 qt5 py39-shapely py39-scipy py39-numpy llvm-13 clang-13 cmake

Create a virtual environment for vpype

cd path/where/the/venv/should/be
/opt/local/bin/python3.9 -m venv vpype_venv

Note the use of the full path for the python interpreter to ensure that the good one is actually used for the venv.

Build PySide2 from source

Checkout PySide2 source:

git clone --recursive https://code.qt.io/pyside/pyside-setup
cd pyside-setup
git checkout 5.15.2
git submodule update --init

Build PySide2 and install it in your virtual environment. CAUTION: the vpype_venv virtual environment must be activated before running this command!

CLANG_INSTALL_DIR=/opt/local/libexec/llvm-13 python setup.py install --qmake=/opt/local/libexec/qt5/bin/qmake --build-tests --ignore-git --parallel=8 --reuse-build

Install vpype

pip would fail installing PySide2 but, since it is already installed, it will simply skip it and the regular install should work:

pip install vpype[all]

Check that the install was successful:

vpype random show

@consier
Copy link

consier commented Nov 20, 2021

@abey79 how did you manage to install gcc11?
I'm also on a M1 Monterey Macbook, however building gcc11 fails every time. All other ports install as they should.

@abey79
Copy link
Owner

abey79 commented Nov 20, 2021

@abruto It worked for me somehow. Do you get the same error as in this issue?

@consier
Copy link

consier commented Nov 20, 2021

yes, it is the same error. There doesn't seem to be a solution yet.

@abey79
Copy link
Owner

abey79 commented Nov 20, 2021

Just to be sure, did you properly update MacPorts beforehand? If so, it might be worthwhile to chime in in that issue to give it some visibility.

Side note: gcc11 is need to have a fortran compiler, which is in turn needed for scipy to build from source. I believe an ARM binary will soon be available for scipy. When this happens, gcc11 will no longer be necessary.

@abey79
Copy link
Owner

abey79 commented Nov 20, 2021

@abruto which version of clang do you have currently installed? You can check with port echo installed | grep clang.

It's kind of weird because the gcc11 port is listed as needing clang-9 for build, but I don't have it installed. Instead, I have version 11, 12 and 13 installed. Since it appears to be related to a C-compiler, I wonder if you could work around it by uninstalling whatever old clang version you may have and install a more recent one instead. Quite the long shot, but it's all I have to offer...

@consier
Copy link

consier commented Nov 20, 2021

Yes, I did update MacPorts. This should not be the problem.

I had clang-11 installed. clang-11 @11.1.0_3+analyzer
I did uninstall clang-11 and installed clang-12 instead.
sudo port clean gcc11 + sudo port install gcc11 still failed to build gcc11
the same with clang-13 as only installed version of clang

@abey79
Copy link
Owner

abey79 commented Nov 20, 2021

Well I'm not sure what else to suggest then. The ARM scipy release is likely imminent (scipy/scipy#13409 (comment)). In the mean time, one work around is to pip install vpype matplotlib and use the classic viewer.

@abey79
Copy link
Owner

abey79 commented Nov 23, 2021

@abruto You may try gcc-devel instead of gcc11 actually. If you do, please let me know if it works for you – I may update the instructions.

@consier
Copy link

consier commented Nov 23, 2021

I started over with no ports installed. I noticed that it was not necessary to install gcc-devel or gcc11 as scipy built just fine.
however - following the error messages when trying to build - clang-13 and cmake are necessary.
I ended up installing python39 qt5 py39-shapely py39-scipy py39-numpy llvm-13 clang-13 cmake

after installing all these ports the build process looks ok but in the end it fails:

CMake Error: The source directory ".../vpype/pyside-setup/sources/pyside2-tools" does not appear to contain CMakeLists.txt.

setup.py invocation failed with exit code: 1

CMakeLists.txt is in the pyside-setup directory though

@abey79
Copy link
Owner

abey79 commented Nov 24, 2021

It definitely makes sense to add clang-13 and cmake indeed (I had them installed too).

I'm not sure about the error though. The triple-period (...) at the beginning for the path is somewhat suspicious. Is it something that has been shortened for display or a mistake that should have been a double-period?

@consier
Copy link

consier commented Nov 24, 2021

@abey79 yes I did shorten the path for display. I did not realize this could be misleading.

I don't know why but the submodule pyside2-tools did not clone properly every time I tried. It was only an empty folder.
git submodule update --init did solve this problem. (as described here)

I think it would be a good idea to always write pip install 'vpype[all]' in the documentation as the default macOS shell zsh cannot deal with brackets otherwise.

@abey79
Copy link
Owner

abey79 commented Nov 24, 2021

yes I did shorten the path for display. I did not realize this could be misleading.

No worries, I was just trying to think of something.

I don't know why but the submodule pyside2-tools did not clone properly every time I tried. It was only an empty folder.
git submodule update --init did solve this problem. (as described here)

Oh ok. Does that mean you could successfully build PySide2 now?

I think it would be a good idea to always write pip install 'vpype[all]' in the documentation as the default macOS shell zsh cannot deal with brackets otherwise.

Yeah I've already updated the documentation. However it only shows with the `"latest" version of the doc. By default, the version linked to the last release shows up. It'll update when I get vpype 1.8 out.

@consier
Copy link

consier commented Nov 25, 2021

Yes, I could successfully build Pyside2 and install vpype. Thank you for the support!

@abey79
Copy link
Owner

abey79 commented Nov 25, 2021

scipy 1.7.3 with arm binaries has been released yesterday 🎉

@jkenzer
Copy link

jkenzer commented Nov 30, 2021

The workarounds are:

* use `vpype` (not `vpype[all]`), thereby loosing the `show` command

I tried this and got the same error.

@abey79
Copy link
Owner

abey79 commented Nov 30, 2021

@jkenzer Can you provide a full error log?

@jkenzer
Copy link

jkenzer commented Nov 30, 2021

@jkenzer Can you provide a full error log?

Of course. Sorry about that.

I ran:

pip install vpype

error:

ERROR: Cannot install vpype==1.4.0, vpype==1.5.0, vpype==1.5.1, vpype==1.6.0, vpype==1.7.0 and vpype==1.8.0 because these package versions have conflicting dependencies.

The conflict is caused by:
vpype 1.8.0 depends on Shapely[vectorized]<1.9.0 and >=1.7.1
vpype 1.7.0 depends on Shapely[vectorized]<1.8.0 and >=1.7.1
vpype 1.6.0 depends on PySide2<6.0.0 and >=5.15.2
vpype 1.5.1 depends on PySide2<6.0.0 and >=5.15.2
vpype 1.5.0 depends on PySide2<6.0.0 and >=5.15.2
vpype 1.4.0 depends on PySide2<6.0.0 and >=5.15.2

To fix this you could try to:

  1. loosen the range of package versions you've specified
  2. remove package versions to allow pip attempt to solve the dependency conflict

@abey79
Copy link
Owner

abey79 commented Dec 1, 2021

@jkenzer Your error is rather weird. Can you try installing in a fresh virtual environment? It looks like yours is in some strange shape. I just tried on my M1 mac with no issue.

@jkenzer
Copy link

jkenzer commented Dec 1, 2021

@abey79 Got it. I was actually missing geos which was causing Shapely not to install. I had to run:

brew install geos

Excited to get the full vpype[all] installed when the libraries have better support for M1. Thanks for your work!

@abey79 abey79 pinned this issue Dec 14, 2021
@abey79
Copy link
Owner

abey79 commented Dec 14, 2021

PySide2 is now available in MacPorts 🥳 I've put the updated installation instruction in the top comment and pinned this issue for visibility.

@abey79 abey79 closed this as completed Dec 14, 2021
@krummrey
Copy link

I have homebrew on my Mac already installed. Both don't seem to get along very well. Any chance to get it up and running with brew?

@abey79
Copy link
Owner

abey79 commented Feb 13, 2022

@krummrey I'm assuming Mac M1? It appears that Homebrew now has pyside2 for arm architecture. So in theory it should be possible by using the same strategy as above (install pyside2 with brew and use --system-site-packages). I haven't tried myself though, so I can't confirm.

Generally, I don't recommend Homebrew because I've had multiple reports of installation issues in the past, but this shouldn't deter anyone from trying (after all, it should work).

@krummrey
Copy link

@abey79 Thanks for your reply. I did manage to get pyside installed brew install pyside@2.
python3 -m venv vpype_venv --system-site-packages to create an environment.
pip3 install vype did work. pip3 install "vpype[all]" did not.
Again there seem to be two conflicting ways of installing python stuff. I'm using conda-forge.
Here are the reports on pastebin:
pip3 install "vpype[all]"
conda list
pip3 list --local
I'm not a dev, just a designer trying to get it to work. ;)

@abey79
Copy link
Owner

abey79 commented Feb 14, 2022

@krummrey from the pip3 install error, it appears that scipy was the culprit. Try to install it with Homebrew as well (as well as numpy for good measure):

brew install numpy
brew install scipy

@krummrey
Copy link

@abey79 No, that didn't work. Still going down the versions but can't resolve the conflicts.
pastebin

@abey79
Copy link
Owner

abey79 commented Feb 14, 2022

@krummrey honestly I'm not sure what's going on exactly. In such case I would try to delete the virtual environment and start from scratch, make sure that you create the venv with the right python executable (using full path ideally):

/usr/local/bin/python3 -m venv vpype_venv --system-site-packages
source vpype_venv/bin/activate
pip install -U pip vpype[all]

@alessbell
Copy link

alessbell commented Nov 20, 2022

Just did a successful install of "vpype[all]" on an M1 2020 MacBook using homebrew. I had failures with the error message from the original issue description and ran:

  • brew install pyside@2
  • brew install numpy
  • then attempted pip install "vpype[all]" and it succeeded
  • vpype random show works 😎

Thanks for the instructions above :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants