Cant install PyTorch using pip on Windows - installation

Hi after pasting this command to console: pip install torch==1.7.1+cpu torchvision==0.8.2+cpu torchaudio===0.7.2 -f https://download.pytorch.org/whl/torch_stable.html (as shown on PyTorch website) I get this error:
C:\Users\m.povilaika>pip install torch==1.7.1+cpu torchvision==0.8.2+cpu torchaudio===0.7.2 -f https://download.pytorch.org/whl/torch_stable.html
Looking in links: https://download.pytorch.org/whl/torch_stable.html
Collecting torch==1.7.1+cpu
Using cached https://download.pytorch.org/whl/cpu/torch-1.7.1%2Bcpu-cp39-cp39-win_amd64.whl (184.2 MB)
Collecting torchvision==0.8.2+cpu
Using cached https://download.pytorch.org/whl/cpu/torchvision-0.8.2%2Bcpu-cp39-cp39-win_amd64.whl (804 kB)
Collecting torchaudio===0.7.2
Using cached https://download.pytorch.org/whl/torchaudio-0.7.2-cp39-none-win_amd64.whl (103 kB)
Requirement already satisfied: numpy in c:\users\m.povilaika\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from torch==1.7.1+cpu) (1.19.4)
Requirement already satisfied: typing-extensions in c:\users\m.povilaika\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from torch==1.7.1+cpu) (3.7.4.3)
Requirement already satisfied: pillow>=4.1.1 in c:\users\m.povilaika\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from torchvision==0.8.2+cpu) (8.1.0)
Installing collected packages: torch, torchvision, torchaudio
ERROR: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: 'C:\\Users\\m.povilaika\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python39\\site-packages\\caffe2\\python\\serialized_test\\data\\operator_test\\collect_and_distribute_fpn_rpn_proposals_op_test.test_collect_and_dist.zip'
Please help, I don't usually use windows, not sure what to do about the path error.
Thanks in advance.

Related

install `pysal` but get error report: `ERROR: No .egg-info directory found in C:\users\xxxx\AppData\Local\Temp\pip-pip-egg-info-ygsexy4a`

Trying to install pysal, (Python Spatial Analysis Library), but get the error report. I have searched and read lots of answers, most of the solutions are upgrade setuptools. But I have tried and nothing changed. I tried to reinstall pandas with pip, everything goes well without any error report. By the way, I have also tried to install the old version of setuptools and pip, the error still occurred.
Can anyone help me solve this error? Thanks for your help.
C:\Users\kenny>pip install --upgrade setuptools
Looking in indexes: https://pypi.mirrors.ustc.edu.cn/simple
Requirement already satisfied: setuptools in d:\users\kenny\appdata\local\programs\python\python39\lib\site-packages (63.2.0)
C:\Users\kenny>python -m pip install --upgrade pip
Looking in indexes: https://pypi.mirrors.ustc.edu.cn/simple
Requirement already satisfied: pip in d:\users\kenny\appdata\local\programs\python\python39\lib\site-packages (22.2.1)
C:\Users\kenny>pip install pysal
Looking in indexes: https://pypi.mirrors.ustc.edu.cn/simple
Collecting pysal
Using cached https://mirrors.bfsu.edu.cn/pypi/web/packages/e0/da/6d67ab14112985dd0d530c058fd1004a3b8ba8514f6166c7903104c65f2e/pysal-2.6.0-py3-none-any.whl (17 kB)
Collecting spopt>=0.2.1
Using cached https://mirrors.bfsu.edu.cn/pypi/web/packages/a6/e4/24e4efa4798372a04ece786bc4983c7617cc0fece1e4f6e980d723bee63b/spopt-0.4.1-py3-none-any.whl (84 kB)
Collecting access>=1.1.3
Downloading https://mirrors.bfsu.edu.cn/pypi/web/packages/06/34/3fa0407af9ac1c27784d816629480e3ea11f5ba6317a1bb04ebb6097e134/access-1.1.8-py3-none-any.whl (21 kB)
Collecting inequality>=1.0.0
Using cached https://mirrors.bfsu.edu.cn/pypi/web/packages/74/0f/9ed2d097f29160d0c873f33ffc0b9806c1083e3611acb2143eb66adcf580/inequality-1.0.0.tar.gz (11 kB)
Preparing metadata (setup.py) ... done
ERROR: No .egg-info directory found in C:\Users\kenny\AppData\Local\Temp\pip-pip-egg-info-ygsexy4a
I have no idea about this question. Just provide another solution to install pysal. I installed this package from git directly and successful. just git clone https://github.com/pysal/pysal - cd pysal - python setup.py install. I hope this can help you. End

installing imblearn on jupyter notebook anaconda

I have been trying to install imblearn on jupyter for some time.
I run to the error:
!pip install imblearn --ignore-installed scikit-learn
collecting imblearn
Using cached https://files.pythonhosted.org/packages/81/a7/4179e6ebfd654bd0eac0b9c06125b8b4c96a9d0a8ff9e9507eb2a26d2d7e/imblearn-0.0-py2.py3-none-any.whl
Collecting scikit-learn
Using cached https://files.pythonhosted.org/packages/9d/20/0ffe8665a44bce7616bd33d4368a198fecad3b226bcafa38c63ef0f6286f/scikit_learn-1.0.2-cp37-cp37m-win_amd64.whl
Collecting imbalanced-learn (from imblearn)
Using cached https://files.pythonhosted.org/packages/19/79/e86c8fd859dca4fb1fbfc61376afc63210177a235a7bfbe7219b02edf8f3/imbalanced_learn-0.9.1-py3-none-any.whl
Collecting threadpoolctl>=2.0.0 (from scikit-learn)
Using cached https://files.pythonhosted.org/packages/61/cf/6e354304bcb9c6413c4e02a747b600061c21d38ba51e7e544ac7bc66aecc/threadpoolctl-3.1.0-py3-none-any.whl
Collecting joblib>=0.11 (from scikit-learn)
Using cached https://files.pythonhosted.org/packages/3e/d5/0163eb0cfa0b673aa4fe1cd3ea9d8a81ea0f32e50807b0c295871e4aab2e/joblib-1.1.0-py2.py3-none-any.whl
Collecting scipy>=1.1.0 (from scikit-learn)
Using cached https://files.pythonhosted.org/packages/40/69/4af412d078cef2298f7d90546fa0e03e65a032558bd85319239c72ae0c3c/scipy-1.7.3-cp37-cp37m-win_amd64.whl
Collecting numpy>=1.14.6 (from scikit-learn)
Using cached https://files.pythonhosted.org/packages/97/9f/da37cc4a188a1d5d203d65ab28d6504e17594b5342e0c1dc5610ee6f4535/numpy-1.21.6-cp37-cp37m-win_amd64.whl
Installing collected packages: numpy, scipy, threadpoolctl, joblib, scikit-learn, imbalanced-learn, imblearn
i have tried to upgrade my scikit-learn version to 1.1.0 that also returned an error that this is not availble .
i also tried to run this on the command prompt:
(base) C:\Users\agns1>pip install imblearn on anaconda pip install imblearn
Collecting imblearn
Using cached https://files.pythonhosted.org/packages/81/a7/4179e6ebfd654bd0eac0b9c06125b8b4c96a9d0a8ff9e9507eb2a26d2d7e/imblearn-0.0-py2.py3-none-any.whl
Collecting on
Downloading https://files.pythonhosted.org/packages/ec/8a/a19679d9e009f8eeedce74fdcc252c5a5c834b30f98c4c13a3a93ff92842/on-0.0.4-py3-none-any.whl (47kB)
|████████████████████████████████| 51kB 469kB/s
Collecting anaconda
Downloading https://files.pythonhosted.org/packages/bd/81/44690deb604d72ffa59ec6e5552f4ef21afb59c8e2698717c8a6be4af09c/anaconda-0.0.1.1.tar.gz
Requirement already satisfied: pip in c:\users\agns1\anaconda3\lib\site-packages (19.2.3)
Collecting install
Downloading https://files.pythonhosted.org/packages/4d/c8/8cbca135f9e167810756ea2bc34b028501936675fcbd7dadccf752fa4622/install-1.3.5-py3-none-any.whl
Collecting imbalanced-learn (from imblearn)
Using cached https://files.pythonhosted.org/packages/19/79/e86c8fd859dca4fb1fbfc61376afc63210177a235a7bfbe7219b02edf8f3/imbalanced_learn-0.9.1-py3-none-any.whl
Requirement already satisfied: joblib>=1.0.0 in c:\users\agns1\anaconda3\lib\site-packages (from imbalanced-learn->imblearn) (1.1.0)
Collecting numpy>=1.17.3 (from imbalanced-learn->imblearn)
Using cached https://files.pythonhosted.org/packages/97/9f/da37cc4a188a1d5d203d65ab28d6504e17594b5342e0c1dc5610ee6f4535/numpy-1.21.6-cp37-cp37m-win_amd64.whl
Requirement already satisfied: threadpoolctl>=2.0.0 in c:\users\agns1\anaconda3\lib\site-packages (from imbalanced-learn->imblearn) (3.1.0)
Collecting scikit-learn>=1.1.0 (from imbalanced-learn->imblearn)
ERROR: Could not find a version that satisfies the requirement scikit-learn>=1.1.0 (from imbalanced-learn->imblearn) (from versions: 0.9, 0.10, 0.11, 0.12, 0.12.1, 0.13, 0.13.1, 0.14, 0.14.1, 0.15.0b1, 0.15.0b2, 0.15.0, 0.15.1, 0.15.2, 0.16b1, 0.16.0, 0.16.1, 0.17b1, 0.17, 0.17.1, 0.18, 0.18.1, 0.18.2, 0.19b2, 0.19.0, 0.19.1, 0.19.2, 0.20rc1, 0.20.0, 0.20.1, 0.20.2, 0.20.3, 0.20.4, 0.21rc2, 0.21.0, 0.21.1, 0.21.2, 0.21.3, 0.22rc2.post1, 0.22rc3, 0.22, 0.22.1, 0.22.2, 0.22.2.post1, 0.23.0rc1, 0.23.0, 0.23.1, 0.23.2, 0.24.dev0, 0.24.0rc1, 0.24.0, 0.24.1, 0.24.2, 1.0rc1, 1.0rc2, 1.0, 1.0.1, 1.0.2)
ERROR: No matching distribution found for scikit-learn>=1.1.0 (from imbalanced-learn->imblearn)
(base) C:\Users\agns1>scikit-learn
ERROR: imbalanced-learn 0.9.1 has requirement scikit-learn>=1.1.0, but you'll have scikit-learn 1.0.2 which is incompatible.
ERROR: Could not install packages due to an EnvironmentError: [WinError 5] Access is denied: 'C:\\Users\\agns1\\Anaconda3\\Lib\\site-packages\\numpy\\.libs\\libopenblas.XWYDX2IKJW2NMTWSFYNGFUWKQU3LYTCZ.gfortran-win_amd64.dll'
Consider using the `--user` option or check the permissions.
it also returned an error is there any way to install imblearn in order to use the SMOTE from it ?
thank you:)
Conda is throwing an environment error that basically says: "you cannot upgrade scikit-learn because you do not have permission to update libopenblas."
The easiest fix would be to create a new environment and install a fresh set of dependencies:
conda create -y -n imblearn python=3.9
conda activate imblearn
python -m pip install imbalanced-learn
Fixing the permission error in the base environment is a different matter. Reinstalling conda might be the easiest option. The conda getting started guide should be helpful for these points:
https://conda.io/projects/conda/en/latest/user-guide/getting-started.html

Pip does ONLY install old and wrong version of my own package

I am working on a package https://pypi.org/project/sgraphic/ it is at version 0.1.1 but pip does not care. It only installs version 0.0.3
I've tried many solutions suggested here without luck. Ugprading pip, installing packages with no_cache but nothing works.
Any ideas what to try?
Here is a dump of me trying to upgrade
pip install sgraphic --upgrade
Requirement already satisfied: sgraphic in /home/user/anaconda3/lib/python3.7/site-packages (0.0.3)
Collecting sgraphic
Downloading sgraphic-0.1.1.tar.gz (4.4 kB)
Requirement already satisfied: skia-python in /home/user/anaconda3/lib/python3.7/site-packages (from sgraphic) (87.1)
Requirement already satisfied: IPython in /home/user/anaconda3/lib/python3.7/site-packages (from sgraphic) (7.22.0)
Using cached sgraphic-0.1.0.tar.gz (4.4 kB)
Using cached sgraphic-0.0.5-py3-none-any.whl (5.8 kB)
Requirement already satisfied: easing-functions in /home/user/anaconda3/lib/python3.7/site-packages (from sgraphic) (1.0.3)
Requirement already satisfied: numpy in /home/user/anaconda3/lib/python3.7/site-packages (from sgraphic) (1.20.3)
Using cached sgraphic-0.0.4-py3-none-any.whl (5.8 kB)
when running pip show sgraphic i get
Name: sgraphic
Version: 0.0.3
It seems to me that the current version (0.1.1) requires PIL, which cannot be installed using pip:
pip install sgraphic==0.1.1
Collecting sgraphic==0.1.1
Using cached sgraphic-0.1.1.tar.gz (4.4 kB)
Collecting skia-python
Using cached skia_python-87.2-cp39-cp39-win_amd64.whl (4.3 MB)
Collecting IPython
Using cached ipython-7.27.0-py3-none-any.whl (787 kB)
ERROR: Could not find a version that satisfies the requirement PIL (from sgraphic) (from versions: none)
ERROR: No matching distribution found for PIL
Because pip cannot install all dependencies, it fails to install sgraphic 0.1.1. However, if you do not explicitly request this version, pip will try to find an older version that it can install. Apparently, version 0.0.3 is the latest version it can install, so in your case it did that.
I think this is simply a bug in the latest versions of the sgraphic package. The code contains import PIL, but the package that contains PIL is actually called Pillow. It's also possible that (the original) PIL is supposed to be installed in another way, but I could not find any information about that.
NB: I created an issue on github to ask the author of the package. It was indeed a bug and is now fixed in version 0.1.2, which I could install successfully using pip.

How can I install GRPCIO on an Apple M1 Silicon laptop?

Every time I try to install a pip package with GRPCIO as a dependency inside a .direnv project I get a build failure due to my architecture being arm64. How can I work around this while waiting for the GRPCIO crew to release an update?
Using cached grpcio-1.34.0.tar.gz (21.0 MB)
ERROR: Command errored out with exit status 1:
command: /Users/yoav/Library/Caches/pypoetry/virtualenvs/orca-g6p4a6cZ-py3.8/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/jj/r3j0p91s2qgdpcpf5ptqr9qm0000gn/T/pip-install-n05vw0u0/grpcio_103d947f24954cde8b8a019b4c9f88fe/setup.py'"'"'; __file__='"'"'/private/var/folders/jj/r3j0p91s2qgdpcpf5ptqr9qm0000gn/T/pip-install-n05vw0u0/grpcio_103d947f24954cde8b8a019b4c9f88fe/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/jj/r3j0p91s2qgdpcpf5ptqr9qm0000gn/T/pip-pip-egg-info-z41yqiw6
cwd: /private/var/folders/jj/r3j0p91s2qgdpcpf5ptqr9qm0000gn/T/pip-install-n05vw0u0/grpcio_103d947f24954cde8b8a019b4c9f88fe/
Complete output (10 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/jj/r3j0p91s2qgdpcpf5ptqr9qm0000gn/T/pip-install-n05vw0u0/grpcio_103d947f24954cde8b8a019b4c9f88fe/setup.py", line 359, in <module>
if mac_target and (pkg_resources.parse_version(mac_target) <
File "/Users/yoav/Library/Caches/pypoetry/virtualenvs/orca-g6p4a6cZ-py3.8/lib/python3.8/site-packages/pkg_resources/__init__.py", line 113, in parse_version
return packaging.version.Version(v)
File "/Users/yoav/Library/Caches/pypoetry/virtualenvs/orca-g6p4a6cZ-py3.8/lib/python3.8/site-packages/pkg_resources/_vendor/packaging/version.py", line 275, in __init__
match = self._regex.search(version)
TypeError: expected string or bytes-like object
ASM Builds for BoringSSL currently not supported on: macosx-11-arm64
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
This seems to work well, do the following in the terminal
export GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1
export GRPC_PYTHON_BUILD_SYSTEM_ZLIB=1
And then install whatever package that you wanted to install, in my case I was trying to install firebase admin and I had to run the following
pip install firebase-admin
Or just run the below command if you just want to install grpcio
pip install grpcio
I found this thread helpful to understand this issue in detail
https://github.com/grpc/grpc/issues/25082
CFLAGS="-I /opt/homebrew/opt/openssl/include" LDFLAGS="-L /opt/homebrew/opt/openssl/lib" GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1 GRPC_PYTHON_BUILD_SYSTEM_ZLIB=1 pip install -r requirements.txt
this works for me in my mac book pro M1 bigsur.
Thanks for the solution
I found a solution that works taking from https://github.com/grpc/grpc/issues/25082 with more detail and the removal of certain unnecessary steps. Note that this only works on python version 3.9 as of this post date.
First, install pyenv and pyenv-virtualenv.
brew install pyenv pyenv-virtualenv
Note that you might need to futz with the shell evaluation variable as simply adding eval "$(pyenv init -)" does not seem to work on the Apple M1 computers. Instead, run the following
pyenv init - >> .zshrc
pyenv virtualenv-init - >> .zshrc
Then go to your python project directory and create an .envrc and register it with direnv
echo 'layout pyenv 3.9.1' > .envrc
direnv allow
Next there install your requirements.txt via
GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1 GRPC_PYTHON_BUILD_SYSTEM_ZLIB=1 pip install -r requirements.txt
Collecting google-cloud-pubsub
Using cached google_cloud_pubsub-2.3.0-py2.py3-none-any.whl (210 kB)
Collecting proto-plus>=1.7.1
Using cached proto_plus-1.17.0-py3-none-any.whl (42 kB)
Collecting grpc-google-iam-v1<0.13dev,>=0.12.3
Using cached grpc-google-iam-v1-0.12.3.tar.gz (13 kB)
Collecting libcst>=0.3.10
Using cached libcst-0.3.17-py3-none-any.whl (507 kB)
Collecting google-api-core[grpc]<2.0.0dev,>=1.22.2
Using cached google_api_core-1.26.1-py2.py3-none-any.whl (92 kB)
Collecting protobuf>=3.12.0
Using cached protobuf-3.15.6-py2.py3-none-any.whl (173 kB)
Collecting grpcio<2.0.0dev,>=1.0.0
Using cached grpcio-1.36.1.tar.gz (21.5 MB)
Collecting googleapis-common-protos[grpc]<2.0.0dev,>=1.5.2
Using cached googleapis_common_protos-1.53.0-py2.py3-none-any.whl (198 kB)
Collecting typing-inspect>=0.4.0
Using cached typing_inspect-0.6.0-py3-none-any.whl (8.1 kB)
Processing /Users/rkmacmini/Library/Caches/pip/wheels/b7/a5/c4/504d913c2a55bb09c607541578ec5f844d1ff33467abe93ba5/PyYAML-5.4.1-cp39-cp39-macosx_11_0_arm64.whl
Collecting typing-extensions>=3.7.4.2
Using cached typing_extensions-3.7.4.3-py3-none-any.whl (22 kB)
Collecting six>=1.13.0
Using cached six-1.15.0-py2.py3-none-any.whl (10 kB)
Collecting google-auth<2.0dev,>=1.21.1
Using cached google_auth-1.27.1-py2.py3-none-any.whl (136 kB)
Collecting pytz
Using cached pytz-2021.1-py2.py3-none-any.whl (510 kB)
Requirement already satisfied: setuptools>=40.3.0 in ./.direnv/python-3.9.1/lib/python3.9/site-packages (from google-api-core[grpc]<2.0.0dev,>=1.22.2->google-cloud-pubsub->-r requirements.txt (line 1)) (49.2.1)
Collecting packaging>=14.3
Using cached packaging-20.9-py2.py3-none-any.whl (40 kB)
Collecting requests<3.0.0dev,>=2.18.0
Using cached requests-2.25.1-py2.py3-none-any.whl (61 kB)
Collecting mypy-extensions>=0.3.0
Using cached mypy_extensions-0.4.3-py2.py3-none-any.whl (4.5 kB)
Collecting pyasn1-modules>=0.2.1
Using cached pyasn1_modules-0.2.8-py2.py3-none-any.whl (155 kB)
Collecting cachetools<5.0,>=2.0.0
Using cached cachetools-4.2.1-py3-none-any.whl (12 kB)
Collecting rsa<5,>=3.1.4; python_version >= "3.6"
Using cached rsa-4.7.2-py3-none-any.whl (34 kB)
Collecting pyparsing>=2.0.2
Using cached pyparsing-2.4.7-py2.py3-none-any.whl (67 kB)
Collecting idna<3,>=2.5
Using cached idna-2.10-py2.py3-none-any.whl (58 kB)
Collecting urllib3<1.27,>=1.21.1
Downloading urllib3-1.26.4-py2.py3-none-any.whl (153 kB)
|████████████████████████████████| 153 kB 1.1 MB/s
Collecting certifi>=2017.4.17
Using cached certifi-2020.12.5-py2.py3-none-any.whl (147 kB)
Collecting chardet<5,>=3.0.2
Using cached chardet-4.0.0-py2.py3-none-any.whl (178 kB)
Collecting pyasn1<0.5.0,>=0.4.6
Using cached pyasn1-0.4.8-py2.py3-none-any.whl (77 kB)
Using legacy 'setup.py install' for grpc-google-iam-v1, since package 'wheel' is not installed.
Using legacy 'setup.py install' for grpcio, since package 'wheel' is not installed.
Installing collected packages: six, protobuf, proto-plus, grpcio, googleapis-common-protos, grpc-google-iam-v1, mypy-extensions, typing-extensions, typing-inspect, pyyaml, libcst, pyasn1, pyasn1-modules, cachetools, rsa, google-auth, pytz, pyparsing, packaging, idna, urllib3, certifi, chardet, requests, google-api-core, google-cloud-pubsub
Running setup.py install for grpcio ... done
Running setup.py install for grpc-google-iam-v1 ... done
Successfully installed cachetools-4.2.1 certifi-2020.12.5 chardet-4.0.0 google-api-core-1.26.1 google-auth-1.27.1 google-cloud-pubsub-2.3.0 googleapis-common-protos-1.53.0 grpc-google-iam-v1-0.12.3 grpcio-1.36.1 idna-2.10 libcst-0.3.17 mypy-extensions-0.4.3 packaging-20.9 proto-plus-1.17.0 protobuf-3.15.6 pyasn1-0.4.8 pyasn1-modules-0.2.8 pyparsing-2.4.7 pytz-2021.1 pyyaml-5.4.1 requests-2.25.1 rsa-4.7.2 six-1.15.0 typing-extensions-3.7.4.3 typing-inspect-0.6.0 urllib3-1.26.4
NOTE: Some references say you need to point your CFLAGS, etc, at the brew installed openssl locations but that has not seemed necessary for me. If you have issue you can try the command with the CFLAGS enabled via
CFLAGS="-I /opt/homebrew/opt/openssl/include" LDFLAGS="-L /opt/homebrew/opt/openssl/lib" GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1 GRPC_PYTHON_BUILD_SYSTEM_ZLIB=1 pip install -r requirements.txt
There's a much simpler and more reliable option:
pip uninstall grpcio
conda install grpcio
Unfortunately, Google does not provide grpcio wheels built for Apple Silicon Macs. As you see from this issue, users have come up with a variety of compiler flags to compile the library on M1, which don't always work.
Tired of these problems, I published the grpcio-mac-arm-build repository, which contains a daily GitHub Actions job that compiles the latest stable grpcio and grpcio-tools releases for Apple Silicon. The compiled wheels for Python 3.8, 3.9, 3.10, and 3.11 are available for download in the "Releases" page. Everything is open sourced and released with the same license of the grpcio library. This way, you don't need to compile the library at all.
After many attempts, I finally got it installed by running these commands:
xcode-select --install
brew install openssl re2
export LDFLAGS="-L$(/opt/homebrew/bin/brew --prefix openssl)/lib -L$(/opt/homebrew/bin/brew --prefix re2)/lib"
export CPPFLAGS="-I$(/opt/homebrew/bin/brew --prefix openssl)/include -I$(/opt/homebrew/bin/brew --prefix re2)/include"
GRPC_BUILD_WITH_BORING_SSL_ASM=""
GRPC_PYTHON_BUILD_SYSTEM_RE2=true
GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=true
GRPC_PYTHON_BUILD_SYSTEM_ZLIB=true
pip install grpcio
Taken from here: https://candid.technology/error-command-usr-bin-clang-failed-with-exit-code-1/
I manage to get it work without changing any variable in my OS. This seems to be to do with python version issue.. i was using 3.7.12 failed. 3.8.12 failed. Finally, 3.10.2 got this package installed.
None of the suggestion worked for me. What worked is below (assuming you have homebrew installed):
Run brew install miniconda (follow through with - conda init "$(basename "${SHELL}")", as instructed.)
Either source your ~/.zshrc or kill your terminal and reopen.
Run conda create --name myenv python=3.10.
Run conda activate myenv.
Run pip install grpcio.
This has brew install the correct arm64 conda env in step 1, hence the rest is doable.
The following settings worked for me,
Used https://asdf-vm.com/ to install and manage my python
Used https://direnv.net and created $PWD/.envrc with just one line
layout python
Made sure I installed latest python 3.9 using asdf
asdf plugin-add python
asdf install python 3.9.15
Then did,
direnv allow .
That should create a python venv under $PWD/.direnv, then did
pip install -U pip wheel grpcio
IMPORTANT: Python versions other than 3.9.x did not work for my e.g. 3.10 fails with some clang issue

No matching distribution found for tf-nightly when installing tensorflowjs

I am trying to install tensorflowjs on my virtual environment, but am getting the following error:
Could not find a version that satisfies the requirement tf-nightly-2.0-preview>=2.0.0.dev20190304 (from tensorflowjs) (from versions: )
No matching distribution found for tf-nightly-2.0-preview>=2.0.0.dev20190304 (from tensorflowjs)
I have tried upgrading pip and creating the virtual environment with both virtualenv and venv, and installing it with and without the option --no-cache-dir.
To reproduce the error, I do the following:
python3 -m venv .env
source .env/bin/activate
pip install tensorflowjs
This results in the output:
Collecting tensorflowjs
Downloading https://files.pythonhosted.org/packages/79/29/35e1aa467436ff46b98df65a08c49faaedb3429e1c512d1d90fe308040a0/tensorflowjs-1.0.1-py3-none-any.whl
Collecting tensorflow-hub==0.3.0 (from tensorflowjs)
Downloading https://files.pythonhosted.org/packages/9e/f0/3a3ced04c8359e562f1b91918d9bde797c8a916fcfeddc8dc5d673d1be20/tensorflow_hub-0.3.0-py2.py3-none-any.whl (73kB)
100% |████████████████████████████████| 81kB 7.6MB/s
Collecting numpy==1.15.1 (from tensorflowjs)
Downloading https://files.pythonhosted.org/packages/d4/fd/6c1c98862f78b1aacd8d81811900ddd5cbe34a6ed168e8f84e4df7cac30f/numpy-1.15.1-cp37-cp37m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (24.5MB)
100% |████████████████████████████████| 24.5MB 39.6MB/s
Collecting h5py==2.8.0 (from tensorflowjs)
Downloading https://files.pythonhosted.org/packages/2a/13/d3fb885ff877578e0fddd8c71e1ed9e22207cec8469c0ef1e483ab5ca0d3/h5py-2.8.0-cp37-cp37m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (6.0MB)
100% |████████████████████████████████| 6.1MB 42.3MB/s
Collecting keras==2.2.4 (from tensorflowjs)
Downloading https://files.pythonhosted.org/packages/5e/10/aa32dad071ce52b5502266b5c659451cfd6ffcbf14e6c8c4f16c0ff5aaab/Keras-2.2.4-py2.py3-none-any.whl (312kB)
100% |████████████████████████████████| 317kB 44.3MB/s
Collecting six==1.11.0 (from tensorflowjs)
Downloading https://files.pythonhosted.org/packages/67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe3056e86a/six-1.11.0-py2.py3-none-any.whl
Collecting tf-nightly-2.0-preview>=2.0.0.dev20190304 (from tensorflowjs)
Could not find a version that satisfies the requirement tf-nightly-2.0-preview>=2.0.0.dev20190304 (from tensorflowjs) (from versions: )
No matching distribution found for tf-nightly-2.0-preview>=2.0.0.dev20190304 (from tensorflowjs)
I am using Python 3.7.2, pip 19.0.3, on a macOS 10.13.6.
tf-nightly-2.0-preview releases binaries for MacOS only for Python 2.7 and 3.6.
Always usage of stable version of tf-nightly is recommended, use command
!pip install tf-nightly
I ran into the same issue and only had success with python 3.6, give that a try if you can.

Resources