Skip to content

Installation on M1 macOS #274

Closed
Closed

Description

@sawaish54

Operating system, python version, PyPortfolioOpt version
e.g MacOS 10.146, python 3.7.3, PyPortfolioOpt 1.2.6

Activity

  1. added
    bug
    on Feb 4, 2021
  2. added
    maintenance
    and removed
    bug
    on Feb 5, 2021
  3. changed the title [-]"pip install pyportfolioopt" is not working even after installing "cvxopt" and C++ as well! Please help![/-] [+]"pip install pyportfolioopt" is not working even after installing "cvxopt" and C++ as well![/+] on Feb 5, 2021
  4. robertmartin8 commented on Feb 5, 2021

    @robertmartin8
    Collaborator

    Hi,

    Firstly, have you looked through the previous macOS install errors? It's quite likely that someone has had the same problem.

    If none of these are applicable, please post your error message.

    Best,
    Robert

  5. javijupra commented on Feb 10, 2021

    @javijupra

    I'm experiencing the same problem when running make build after cloning the repo.
    Here's the error trace:

    Installing backend dependencies: finished with status 'error'
      ERROR: Command errored out with exit status 1:
       command: /usr/local/bin/python /usr/local/lib/python3.7/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-43g1ttd5/normal --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- qdldl
           cwd: None
      Complete output (128 lines):
      Collecting qdldl
        Downloading qdldl-0.1.5.post0.tar.gz (69 kB)
      Collecting numpy>=1.7
        Using cached numpy-1.20.1-cp37-cp37m-manylinux2014_aarch64.whl (12.6 MB)
      Collecting scipy>=0.13.2
        Using cached scipy-1.6.0-cp37-cp37m-manylinux2014_aarch64.whl (26.0 MB)
      Building wheels for collected packages: qdldl
        Building wheel for qdldl (setup.py): started
        Building wheel for qdldl (setup.py): finished with status 'error'
        ERROR: Command errored out with exit status 1:
         command: /usr/local/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-q3vwclg1/qdldl/setup.py'"'"'; __file__='"'"'/tmp/pip-install-q3vwclg1/qdldl/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-ylsdjb6c
             cwd: /tmp/pip-install-q3vwclg1/qdldl/
        Complete output (49 lines):
        running bdist_wheel
        running build
        running build_ext
        Traceback (most recent call last):
          File "/tmp/pip-install-q3vwclg1/qdldl/setup.py", line 78, in build_extensions
            check_output(['cmake', '--version'])
          File "/usr/local/lib/python3.7/subprocess.py", line 411, in check_output
            **kwargs).stdout
          File "/usr/local/lib/python3.7/subprocess.py", line 488, in run
            with Popen(*popenargs, **kwargs) as process:
          File "/usr/local/lib/python3.7/subprocess.py", line 800, in __init__
            restore_signals, start_new_session)
          File "/usr/local/lib/python3.7/subprocess.py", line 1551, in _execute_child
            raise child_exception_type(errno_num, err_msg, err_filename)
        FileNotFoundError: [Errno 2] No such file or directory: 'cmake': 'cmake'
      
        During handling of the above exception, another exception occurred:
      
        Traceback (most recent call last):
          File "<string>", line 1, in <module>
          File "/tmp/pip-install-q3vwclg1/qdldl/setup.py", line 124, in <module>
            ext_modules=[qdldl],
          File "/usr/local/lib/python3.7/site-packages/setuptools/__init__.py", line 161, in setup
            return distutils.core.setup(**attrs)
          File "/usr/local/lib/python3.7/distutils/core.py", line 148, in setup
            dist.run_commands()
          File "/usr/local/lib/python3.7/distutils/dist.py", line 966, in run_commands
            self.run_command(cmd)
          File "/usr/local/lib/python3.7/distutils/dist.py", line 985, in run_command
            cmd_obj.run()
          File "/usr/local/lib/python3.7/site-packages/wheel/bdist_wheel.py", line 223, in run
            self.run_command('build')
          File "/usr/local/lib/python3.7/distutils/cmd.py", line 313, in run_command
            self.distribution.run_command(command)
          File "/usr/local/lib/python3.7/distutils/dist.py", line 985, in run_command
            cmd_obj.run()
          File "/usr/local/lib/python3.7/distutils/command/build.py", line 135, in run
            self.run_command(cmd_name)
          File "/usr/local/lib/python3.7/distutils/cmd.py", line 313, in run_command
            self.distribution.run_command(command)
          File "/usr/local/lib/python3.7/distutils/dist.py", line 985, in run_command
            cmd_obj.run()
          File "/usr/local/lib/python3.7/site-packages/setuptools/command/build_ext.py", line 87, in run
            _build_ext.run(self)
          File "/usr/local/lib/python3.7/distutils/command/build_ext.py", line 340, in run
            self.build_extensions()
          File "/tmp/pip-install-q3vwclg1/qdldl/setup.py", line 80, in build_extensions
            raise RuntimeError("CMake must be installed to build qdldl")
        RuntimeError: CMake must be installed to build qdldl
        ----------------------------------------
        ERROR: Failed building wheel for qdldl
        Running setup.py clean for qdldl
      Failed to build qdldl
      Installing collected packages: numpy, scipy, qdldl
          Running setup.py install for qdldl: started
          Running setup.py install for qdldl: finished with status 'error'
          ERROR: Command errored out with exit status 1:
           command: /usr/local/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-q3vwclg1/qdldl/setup.py'"'"'; __file__='"'"'/tmp/pip-install-q3vwclg1/qdldl/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-2dze6r2t/install-record.txt --single-version-externally-managed --prefix /tmp/pip-build-env-43g1ttd5/normal --compile --install-headers /tmp/pip-build-env-43g1ttd5/normal/include/python3.7m/qdldl
               cwd: /tmp/pip-install-q3vwclg1/qdldl/
          Complete output (51 lines):
          running install
          running build
          running build_ext
          Traceback (most recent call last):
            File "/tmp/pip-install-q3vwclg1/qdldl/setup.py", line 78, in build_extensions
              check_output(['cmake', '--version'])
            File "/usr/local/lib/python3.7/subprocess.py", line 411, in check_output
              **kwargs).stdout
            File "/usr/local/lib/python3.7/subprocess.py", line 488, in run
              with Popen(*popenargs, **kwargs) as process:
            File "/usr/local/lib/python3.7/subprocess.py", line 800, in __init__
              restore_signals, start_new_session)
            File "/usr/local/lib/python3.7/subprocess.py", line 1551, in _execute_child
              raise child_exception_type(errno_num, err_msg, err_filename)
          FileNotFoundError: [Errno 2] No such file or directory: 'cmake': 'cmake'
      
          During handling of the above exception, another exception occurred:
      
          Traceback (most recent call last):
            File "<string>", line 1, in <module>
            File "/tmp/pip-install-q3vwclg1/qdldl/setup.py", line 124, in <module>
              ext_modules=[qdldl],
            File "/usr/local/lib/python3.7/site-packages/setuptools/__init__.py", line 161, in setup
              return distutils.core.setup(**attrs)
            File "/usr/local/lib/python3.7/distutils/core.py", line 148, in setup
              dist.run_commands()
            File "/usr/local/lib/python3.7/distutils/dist.py", line 966, in run_commands
              self.run_command(cmd)
            File "/usr/local/lib/python3.7/distutils/dist.py", line 985, in run_command
              cmd_obj.run()
            File "/usr/local/lib/python3.7/site-packages/setuptools/command/install.py", line 61, in run
              return orig.install.run(self)
            File "/usr/local/lib/python3.7/distutils/command/install.py", line 545, in run
              self.run_command('build')
            File "/usr/local/lib/python3.7/distutils/cmd.py", line 313, in run_command
              self.distribution.run_command(command)
            File "/usr/local/lib/python3.7/distutils/dist.py", line 985, in run_command
              cmd_obj.run()
            File "/usr/local/lib/python3.7/distutils/command/build.py", line 135, in run
              self.run_command(cmd_name)
            File "/usr/local/lib/python3.7/distutils/cmd.py", line 313, in run_command
              self.distribution.run_command(command)
            File "/usr/local/lib/python3.7/distutils/dist.py", line 985, in run_command
              cmd_obj.run()
            File "/usr/local/lib/python3.7/site-packages/setuptools/command/build_ext.py", line 87, in run
              _build_ext.run(self)
            File "/usr/local/lib/python3.7/distutils/command/build_ext.py", line 340, in run
              self.build_extensions()
            File "/tmp/pip-install-q3vwclg1/qdldl/setup.py", line 80, in build_extensions
              raise RuntimeError("CMake must be installed to build qdldl")
          RuntimeError: CMake must be installed to build qdldl
          ----------------------------------------
      ERROR: Command errored out with exit status 1: /usr/local/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-q3vwclg1/qdldl/setup.py'"'"'; __file__='"'"'/tmp/pip-install-q3vwclg1/qdldl/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-2dze6r2t/install-record.txt --single-version-externally-managed --prefix /tmp/pip-build-env-43g1ttd5/normal --compile --install-headers /tmp/pip-build-env-43g1ttd5/normal/include/python3.7m/qdldl Check the logs for full command output.
      WARNING: You are using pip version 20.1.1; however, version 21.0.1 is available.
      You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
      ----------------------------------------
    ERROR: Command errored out with exit status 1: /usr/local/bin/python /usr/local/lib/python3.7/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-43g1ttd5/normal --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- qdldl Check the logs for full command output.
    WARNING: You are using pip version 20.1.1; however, version 21.0.1 is available.
    You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
    ERROR: Service 'pypfopt' failed to build : The command '/bin/sh -c buildDeps='gcc g++' &&     apt-get update && apt-get install -y $buildDeps --no-install-recommends &&     pip install --no-cache-dir -r /tmp/pypfopt/requirements.txt &&     pip install --no-cache-dir /tmp/pyhrp &&     rm -r /tmp/pypfopt &&     apt-get purge -y --auto-remove $buildDeps' returned a non-zero code: 1
    make: *** [build] Error 1
    
  6. robertmartin8 commented on Feb 10, 2021

    @robertmartin8
    Collaborator

    Hi @xabiko,

    Thanks for raising this. What error message do you get when you pip install pyportfolioopt?

    Best,
    Robert

  7. javijupra commented on Feb 10, 2021

    @javijupra

    I get an even bigger error trace. At a glance, it warns me about Python 3.9 being incompatible (it seems like it'd be recommended to use 3.6, 3.7 or 3.8), it also mentions how it Could not build wheels for numpy which use PEP 517 and cannot be installed directly, as well as compiler warnings for architecture incompatibility (I'm using mac M1 chip, ARM)

    Numpy is a library that I already installed and can use on a python script with no problem. I'd be fine running this library on a Docker container, but it fails with the makefile/dockerfile provided.

  8. phschiele commented on Feb 10, 2021

    @phschiele
    Contributor

    @xabiko There are a few things to unpack:

    1. Regarding your first trace, looks like cmake is not installed? Have you tried installing it manually (see here)?
    2. Python 3.9 is not part of the current CI testing, but could (and should) eventually be added
    3. The ARM architecture presents another untested variable
    4. I think the Dockerfile also needs some updates (e.g., should move to poetry). Which error do you get when running docker build . in the repo?

    Would you mind trying either installing cmake (if you haven't already and the error is misleading), or try with Python 3.8 just to eliminate some variables?

  9. robertmartin8 commented on Feb 11, 2021

    @robertmartin8
    Collaborator

    @phschiele @xabiko Unfortunately, I can't officially support py3.9 yet because cvxopt doesn't support it. Most of the PyPortfolioOpt will work fine, there will just be some issues with the discrete allocation stuff that requires cvxopt's mixed-integer solvers.

    As for apple silicon, I'm afraid that is entirely out of my hands. There seems to be a long chain of people waiting on implementations, e.g I'm waiting on cvxpy, cvxpy is waiting on osqp, osqp is waiting on ... to provide M1 ARM support. It's one of those hit-or-miss things where you have to pray that Rosetta is able to figure it out without any issues :/

    @xabiko I think it's worth trying with python 3.8. The best way to run multiple python versions on a single machine is to use pyenv – makes it really easy to switch between installations, and avoids the hell of mixed python installs.

    @phschiele The docker file probably does need an update. Though if we make it so that requirements.txt derives from pyproject.toml (as we are discussing in #277 ) it should be ok?

  10. javijupra commented on Feb 11, 2021

    @javijupra

    I see, thanks for your prompt response. I just switched to a Linux machine and it all installed flawlessly.
    Thanks again.

  11. phschiele commented on Feb 12, 2021

    @phschiele
    Contributor

    @robertmartin8 I think one could easily install using poetry in the Dockerfile, which would be following the best practices of the repo. Although I am not quite sure yet what exactly is the use case for the Dockerfile(s) (but I have e.g. never used binder before), and there also seem to be some TODOs in them. Probably best to open a separate issue for that.

  12. changed the title [-]"pip install pyportfolioopt" is not working even after installing "cvxopt" and C++ as well![/-] [+]Installation on M1 macOS[/+] on Feb 13, 2021
  13. thirumalairajr commented on Dec 19, 2022

    @thirumalairajr

    Faced the same issue. Solved it by uninstalling cmake and tried installing again. Not sure why.

    pip uninstall cmake

  14. Zichen-Wu commented on May 17, 2023

    @Zichen-Wu

    For me using brew install cmake instead of 'pip install cmake' solved the problem. You may need to uninstall cmake before install it with brew.

  15. AlessandroSciarrillo commented on Oct 14, 2023

    @AlessandroSciarrillo

    Also for me brew install make worked after pip uninstall cmake and brew uninstall cmake.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    maintenance

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions