macOS M1安装miniconda和基本使用

安装

    1. 下载安装包
      download
    1. 修改刚刚下载的安装包权限
chomod 777 Miniconda3-latest-MacOSX-arm64.sh
    1. 执行安装
./Miniconda3-latest-MacOSX-arm64.sh
    1. 一路回车,如果遇到需要填写yes/no的填yes

基本使用

    1. 创建环境
 conda create -n sp3.9 python=3.9
    1. 切入环境
source activate sp3.9
    1. 安装包
 pip install torch

在系统层面的python安装失败的包,在conda环境依旧没有成功,不知道这个和M1 芯片是否有关系

下面这个包是为了安装一个github 开源图像库所需要的依赖,参考:https://www.jianshu.com/p/bd6b24380d68

pip install basicsr

报错信息

 error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [36 lines of output]
      /Users/shixiaolong/miniconda3/envs/sp3.9/lib/python3.9/site-packages/setuptools/installer.py:27: SetuptoolsDeprecationWarning: setuptools.installer is deprecated. Requirements should be satisfied by a PEP 517 installer.
        warnings.warn(
      WARNING: The repository located at mirrors.aliyun.com is not a trusted or secure host and is being ignored. If this repository is available via HTTPS we recommend you use HTTPS instead, otherwise you may silence this warning and allow it anyway with '--trusted-host mirrors.aliyun.com'.
      ERROR: Could not find a version that satisfies the requirement numpy (from versions: none)
      ERROR: No matching distribution found for numpy
      Traceback (most recent call last):
        File "/Users/shixiaolong/miniconda3/envs/sp3.9/lib/python3.9/site-packages/setuptools/installer.py", line 82, in fetch_build_egg
          subprocess.check_call(cmd)
        File "/Users/shixiaolong/miniconda3/envs/sp3.9/lib/python3.9/subprocess.py", line 373, in check_call
          raise CalledProcessError(retcode, cmd)
      subprocess.CalledProcessError: Command '['/Users/shixiaolong/miniconda3/envs/sp3.9/bin/python3.9', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', '/var/folders/25/vr51mkn918bb746n72nzdnvr0000gn/T/tmpleyajmvk', '--quiet', 'numpy']' returned non-zero exit status 1.

      The above exception was the direct cause of the following exception:

      Traceback (most recent call last):
        File "", line 2, in 
        File "", line 34, in 
        File "/private/var/folders/25/vr51mkn918bb746n72nzdnvr0000gn/T/pip-install-2i06xyu_/basicsr_f93ce8e08c1445159339f2d5e5e0ec29/setup.py", line 147, in 
          setup(
        File "/Users/shixiaolong/miniconda3/envs/sp3.9/lib/python3.9/site-packages/setuptools/__init__.py", line 86, in setup
          _install_setup_requires(attrs)
        File "/Users/shixiaolong/miniconda3/envs/sp3.9/lib/python3.9/site-packages/setuptools/__init__.py", line 80, in _install_setup_requires
          dist.fetch_build_eggs(dist.setup_requires)
        File "/Users/shixiaolong/miniconda3/envs/sp3.9/lib/python3.9/site-packages/setuptools/dist.py", line 875, in fetch_build_eggs
          resolved_dists = pkg_resources.working_set.resolve(
        File "/Users/shixiaolong/miniconda3/envs/sp3.9/lib/python3.9/site-packages/pkg_resources/__init__.py", line 789, in resolve
          dist = best[req.key] = env.best_match(
        File "/Users/shixiaolong/miniconda3/envs/sp3.9/lib/python3.9/site-packages/pkg_resources/__init__.py", line 1075, in best_match
          return self.obtain(req, installer)
        File "/Users/shixiaolong/miniconda3/envs/sp3.9/lib/python3.9/site-packages/pkg_resources/__init__.py", line 1087, in obtain
          return installer(requirement)
        File "/Users/shixiaolong/miniconda3/envs/sp3.9/lib/python3.9/site-packages/setuptools/dist.py", line 945, in fetch_build_egg
          return fetch_build_egg(self, req)
        File "/Users/shixiaolong/miniconda3/envs/sp3.9/lib/python3.9/site-packages/setuptools/installer.py", line 84, in fetch_build_egg
          raise DistutilsError(str(e)) from e
      distutils.errors.DistutilsError: Command '['/Users/shixiaolong/miniconda3/envs/sp3.9/bin/python3.9', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', '/var/folders/25/vr51mkn918bb746n72nzdnvr0000gn/T/tmpleyajmvk', '--quiet', 'numpy']' returned non-zero exit status 1.
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

M1芯片就python的相关依赖而言,很多都无法安装,用了不到三个月,在折腾环境安装东西这块累计浪费的时间差不多有150小时,而且结果都是没有解决。

M1 芯片对于图像,和pycurl 都不是能很好的支持(不支持),其中图像比如GFPGAN,paddle,

但是好像也有解决方案, 比如这里
https://github.com/PaddlePaddle/Paddle/issues/32377
https://github.com/conda-forge/miniforge/issues/165
conda环境利用rosseta来实现模拟Intel芯片,这样架构就切换成了X86

CONDA_SUBDIR=osx-64 conda create -n rosetta python   # create a new environment called rosetta with intel packages.
conda activate rosetta
python -c "import platform;print(platform.machine())"
conda config --env --set subdir osx-64  # make sure that conda commands in this environment use intel packages
CONDA_SUBDIR=osx-64 conda create -n pd_rosetta python // create a new environment called pd_rosetta with intel packages.
conda activate pd_rosetta
python -c "import platform;print(platform.machine())"  // should be ‘x86_64’ not ‘arm64’
conda env config vars set CONDA_SUBDIR=osx-64 // # make sure that conda commands in this environment use intel packages
conda deactivate
conda activate pd_rosetta
echo "CONDA_SUBDIR: $CONDA_SUBDIR"
python -m pip install paddlepaddle -i https://mirror.baidu.com/pypi/simple

通过模拟x86的环境,解决了上面的报错
rosetta3

查看当前环境的cpu架构

python -c "import platform;print(platform.architecture()[0]);print(platform.machine())"

你可能感兴趣的:(macOS M1安装miniconda和基本使用)