pip installs a django version different from the one specified in requirements.txt - pip

I'm trying to do the djangocms tutorial.
Everything is fine on my laptop (on Archlinux), but I tried to continue the project on a different computer (using Mac OS X).
I made my git clone, started a fresh virtualenv and tried to do a pip install -r requirements.txt.
Here is the content of my requirements.txt (I got it from a pip freeze output) :
dj-database-url==0.3.0
Django==1.6.11
django-classy-tags==0.6.2
django-cms==3.1.2
django-reversion==1.8.5
django-sekizai==0.8.2
Django-Select2==4.3.1
django-treebeard==3.0
djangocms-admin-style==0.2.7
djangocms-column==1.5
djangocms-file==0.1
djangocms-flash==0.2.0
djangocms-googlemap==0.2
djangocms-inherit==0.1
djangocms-installer==0.7.8
djangocms-link==1.6.2
djangocms-picture==0.1
djangocms-style==1.5
djangocms-teaser==0.1
djangocms-text-ckeditor==2.5.2
djangocms-video==0.1
html5lib==0.99999
Pillow==2.8.0
-e git+http://git#github.com/divio/django-polls.git#9fb91e49e2e56cf59ab0cfcddb17c35afbdd06da#egg=polls-master
pytz==2015.4
six==1.9.0
South==1.0.2
tzlocal==1.2
wheel==0.24.0
But the django version after the pip install is Django 1.7.4 (instead of Django 1.6.11).
And I don't understand why.
Here is the output of a pip freeze :
dj-database-url==0.3.0
Django==1.7.4
django-classy-tags==0.6.2
django-cms==3.1.2
django-reversion==1.8.5
django-sekizai==0.8.2
Django-Select2==4.3.1
django-treebeard==3.0
djangocms-admin-style==0.2.7
djangocms-column==1.5
djangocms-file==0.1
djangocms-flash==0.2.0
djangocms-googlemap==0.2
djangocms-inherit==0.1
djangocms-installer==0.7.8
djangocms-link==1.6.2
djangocms-picture==0.1
djangocms-style==1.5
djangocms-teaser==0.1
djangocms-text-ckeditor==2.5.2
djangocms-video==0.1
html5lib==0.99999
pbr==0.10.7
Pillow==2.8.0
-e git+http://git#github.com/divio/django-polls.git#9fb91e49e2e56cf59ab0cfcddb17c35afbdd06da#egg=polls-master
pytz==2015.4
six==1.9.0
South==1.0.2
stevedore==1.2.0
tzlocal==1.2
virtualenv==13.1.0
virtualenv-clone==0.2.5
virtualenvwrapper==4.6.0
wheel==0.24.0
Here is the output of the pip install -r requirements.txt :
/Volumes/Data/nfs/zfs-student-3/users/2013_paris/vmonteco/Envs/djangocms/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Collecting dj-database-url==0.3.0 (from -r requirements.txt (line 1))
/Volumes/Data/nfs/zfs-student-3/users/2013_paris/vmonteco/Envs/djangocms/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Downloading dj_database_url-0.3.0-py2.py3-none-any.whl
Collecting Django==1.6.11 (from -r requirements.txt (line 2))
Downloading Django-1.6.11-py2.py3-none-any.whl (6.7MB)
100% |████████████████████████████████| 6.7MB 75kB/s
Collecting django-classy-tags==0.6.2 (from -r requirements.txt (line 3))
Downloading django_classy_tags-0.6.2-py2-none-any.whl
Collecting django-cms==3.1.2 (from -r requirements.txt (line 4))
Downloading django_cms-3.1.2-py2.py3-none-any.whl (3.0MB)
100% |████████████████████████████████| 3.0MB 150kB/s
Collecting django-reversion==1.8.5 (from -r requirements.txt (line 5))
Downloading django-reversion-1.8.5.tar.gz (57kB)
100% |████████████████████████████████| 61kB 4.1MB/s
Collecting django-sekizai==0.8.2 (from -r requirements.txt (line 6))
Downloading django_sekizai-0.8.2-py2.py3-none-any.whl
Collecting Django-Select2==4.3.1 (from -r requirements.txt (line 7))
Downloading Django-Select2-4.3.1.tar.gz (97kB)
100% |████████████████████████████████| 98kB 3.0MB/s
Collecting django-treebeard==3.0 (from -r requirements.txt (line 8))
Downloading django-treebeard-3.0.tar.gz (93kB)
100% |████████████████████████████████| 94kB 1.8MB/s
Collecting djangocms-admin-style==0.2.7 (from -r requirements.txt (line 9))
Downloading djangocms_admin_style-0.2.7-py2.py3-none-any.whl (484kB)
100% |████████████████████████████████| 487kB 834kB/s
Collecting djangocms-column==1.5 (from -r requirements.txt (line 10))
Downloading djangocms_column-1.5-py2-none-any.whl (127kB)
100% |████████████████████████████████| 131kB 1.7MB/s
Collecting djangocms-file==0.1 (from -r requirements.txt (line 11))
Downloading djangocms_file-0.1-py2-none-any.whl (120kB)
100% |████████████████████████████████| 122kB 2.8MB/s
Collecting djangocms-flash==0.2.0 (from -r requirements.txt (line 12))
Downloading djangocms_flash-0.2.0-py2-none-any.whl (121kB)
100% |████████████████████████████████| 122kB 3.9MB/s
Collecting djangocms-googlemap==0.2 (from -r requirements.txt (line 13))
Downloading djangocms_googlemap-0.2-py2-none-any.whl (193kB)
100% |████████████████████████████████| 196kB 2.4MB/s
Collecting djangocms-inherit==0.1 (from -r requirements.txt (line 14))
Downloading djangocms_inherit-0.1-py2-none-any.whl (131kB)
100% |████████████████████████████████| 135kB 2.5MB/s
Collecting djangocms-installer==0.7.8 (from -r requirements.txt (line 15))
Downloading djangocms_installer-0.7.8-py2.py3-none-any.whl (47kB)
100% |████████████████████████████████| 49kB 3.9MB/s
Collecting djangocms-link==1.6.2 (from -r requirements.txt (line 16))
Downloading djangocms_link-1.6.2-py2-none-any.whl (151kB)
100% |████████████████████████████████| 151kB 1.3MB/s
Collecting djangocms-picture==0.1 (from -r requirements.txt (line 17))
Downloading djangocms_picture-0.1-py2-none-any.whl (154kB)
100% |████████████████████████████████| 155kB 2.6MB/s
Collecting djangocms-style==1.5 (from -r requirements.txt (line 18))
Downloading djangocms-style-1.5.tar.gz
Collecting djangocms-teaser==0.1 (from -r requirements.txt (line 19))
Downloading djangocms_teaser-0.1-py2-none-any.whl (121kB)
100% |████████████████████████████████| 122kB 3.0MB/s
Collecting djangocms-text-ckeditor==2.5.2 (from -r requirements.txt (line 20))
Downloading djangocms_text_ckeditor-2.5.2-py2.py3-none-any.whl (1.6MB)
100% |████████████████████████████████| 1.6MB 303kB/s
Collecting djangocms-video==0.1 (from -r requirements.txt (line 21))
Downloading djangocms_video-0.1-py2-none-any.whl (176kB)
100% |████████████████████████████████| 180kB 1.1MB/s
Collecting html5lib==0.99999 (from -r requirements.txt (line 22))
Downloading html5lib-0.99999.tar.gz (887kB)
100% |████████████████████████████████| 888kB 493kB/s
Collecting Pillow==2.8.0 (from -r requirements.txt (line 23))
Downloading Pillow-2.8.0-cp27-none-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (2.8MB)
100% |████████████████████████████████| 2.8MB 162kB/s
Obtaining polls-master from git+http://git#github.com/divio/django-polls.git#9fb91e49e2e56cf59ab0cfcddb17c35afbdd06da#egg=polls-master (from -r requirements.txt (line 24))
Cloning http://git#github.com/divio/django-polls.git (to 9fb91e49e2e56cf59ab0cfcddb17c35afbdd06da) to /Volumes/Data/nfs/zfs-student-3/users/2013_paris/vmonteco/Envs/djangocms/src/polls-master
Could not find a tag or branch '9fb91e49e2e56cf59ab0cfcddb17c35afbdd06da', assuming commit.
Collecting pytz==2015.4 (from -r requirements.txt (line 25))
Downloading pytz-2015.4-py2.py3-none-any.whl (475kB)
100% |████████████████████████████████| 475kB 1.1MB/s
Requirement already satisfied (use --upgrade to upgrade): six==1.9.0 in /Volumes/Data/nfs/zfs-student-3/users/2013_paris/vmonteco/Library/Python/2.7/lib/python/site-packages (from -r requirements.txt (line 26))
Collecting South==1.0.2 (from -r requirements.txt (line 27))
Downloading South-1.0.2.tar.gz (96kB)
100% |████████████████████████████████| 98kB 3.3MB/s
Collecting tzlocal==1.2 (from -r requirements.txt (line 28))
Downloading tzlocal-1.2.tar.gz
Requirement already satisfied (use --upgrade to upgrade): wheel==0.24.0 in /Volumes/Data/nfs/zfs-student-3/users/2013_paris/vmonteco/Envs/djangocms/lib/python2.7/site-packages (from -r requirements.txt (line 29))
Requirement already satisfied (use --upgrade to upgrade): argparse in /Volumes/Data/nfs/zfs-student-3/users/2013_paris/vmonteco/Library/Python/2.7/lib/python/site-packages (from djangocms-installer==0.7.8->-r requirements.txt (line 15))
Requirement already satisfied (use --upgrade to upgrade): pip in /Volumes/Data/nfs/zfs-student-3/users/2013_paris/vmonteco/Envs/djangocms/lib/python2.7/site-packages (from djangocms-installer==0.7.8->-r requirements.txt (line 15))
Building wheels for collected packages: django-reversion, Django-Select2, django-treebeard, djangocms-style, html5lib, South, tzlocal
Running setup.py bdist_wheel for django-reversion
Stored in directory: /nfs/zfs-student-3/users/2013_paris/vmonteco/Library/Caches/pip/wheels/51/b4/ea/033db3e78df246021ef65c216c3f716efd5882021289378705
Running setup.py bdist_wheel for Django-Select2
Stored in directory: /nfs/zfs-student-3/users/2013_paris/vmonteco/Library/Caches/pip/wheels/a7/e2/92/a069a90e2595d4a5dbc9f0609d52d8bea9555e42153828eebb
Running setup.py bdist_wheel for django-treebeard
Stored in directory: /nfs/zfs-student-3/users/2013_paris/vmonteco/Library/Caches/pip/wheels/73/8e/8b/3d72e01575557ffeeb1ef648581006d468a415ed868abbfb5d
Running setup.py bdist_wheel for djangocms-style
Stored in directory: /nfs/zfs-student-3/users/2013_paris/vmonteco/Library/Caches/pip/wheels/5b/80/87/41ea156cdab7a7a170122f3a3b77af473ae855612d4d88d6a2
Running setup.py bdist_wheel for html5lib
Stored in directory: /nfs/zfs-student-3/users/2013_paris/vmonteco/Library/Caches/pip/wheels/44/5c/08/f97a40f63f914c4c3a9798e1ff5606b5ab19fe5dcfb64e27b6
Running setup.py bdist_wheel for South
Stored in directory: /nfs/zfs-student-3/users/2013_paris/vmonteco/Library/Caches/pip/wheels/11/2b/ca/a57966e1943759859dd94f3ebc5c279450bee11e07d600e3a3
Running setup.py bdist_wheel for tzlocal
Stored in directory: /nfs/zfs-student-3/users/2013_paris/vmonteco/Library/Caches/pip/wheels/39/8d/3b/21db6b23bc7483a2e1cf391865427e8fbd090223d9db2cfab3
Successfully built django-reversion Django-Select2 django-treebeard djangocms-style html5lib South tzlocal
Installing collected packages: dj-database-url, Django, django-classy-tags, django-sekizai, django-treebeard, djangocms-admin-style, html5lib, django-cms, django-reversion, Django-Select2, djangocms-column, djangocms-file, djangocms-flash, djangocms-googlemap, djangocms-inherit, pytz, tzlocal, djangocms-installer, djangocms-link, djangocms-picture, djangocms-style, djangocms-teaser, Pillow, djangocms-text-ckeditor, djangocms-video, polls-master, South
Found existing installation: Django 1.7.4
Not uninstalling Django at /Volumes/Data/nfs/zfs-student-3/users/2013_paris/vmonteco/Library/Python/2.7/lib/python/site-packages, outside environment /Volumes/Data/nfs/zfs-student-3/users/2013_paris/vmonteco/Envs/djangocms
Running setup.py develop for polls-master
Successfully installed Django-1.7.4 Django-Select2-4.3.1 Pillow-2.8.0 South-1.0.2 dj-database-url-0.3.0 django-classy-tags-0.6.2 django-cms-3.1.2 django-reversion-1.8.5 django-sekizai-0.8.2 django-treebeard-3.0 djangocms-admin-style-0.2.7 djangocms-column-1.5 djangocms-file-0.1 djangocms-flash-0.2.0 djangocms-googlemap-0.2 djangocms-inherit-0.1 djangocms-installer-0.7.8 djangocms-link-1.6.2 djangocms-picture-0.1 djangocms-style-1.5 djangocms-teaser-0.1 djangocms-text-ckeditor-2.5.2 djangocms-video-0.1 html5lib-0.99999 polls-master pytz-2015.4 tzlocal-1.2
Django 1.7.4 seems to be installed at the end.
Why?
How could I avoid this? My current project can't work with this version and the tutorial requires Django 1.6.
EDIT :
I just found out that in the site-packages of my virtualenv, the version of django is 1.6.11. So my virtualenv may use the wrong site-package.
Why?
How could I fix this?
Usually, when we use a virtualenv, shouldn't it use the right site-package directory?

Last 5 lines of the pip install -r requirements.txt output gives you the answer:
Successfully built django-reversion Django-Select2 django-treebeard djangocms-style html5lib South tzlocal
Installing collected packages: dj-database-url, Django, django-classy-tags, django-sekizai, django-treebeard, djangocms-admin-style, html5lib, django-cms, django-reversion, Django-Select2, djangocms-column, djangocms-file, djangocms-flash, djangocms-googlemap, djangocms-inherit, pytz, tzlocal, djangocms-installer, djangocms-link, djangocms-picture, djangocms-style, djangocms-teaser, Pillow, djangocms-text-ckeditor, djangocms-video, polls-master, South
Found existing installation: Django 1.7.4
Not uninstalling Django at /Volumes/Data/nfs/zfs-student-3/users/2013_paris/vmonteco/Library/Python/2.7/lib/python/site-packages, outside environment /Volumes/Data/nfs/zfs-student-3/users/2013_paris/vmonteco/Envs/djangocms
Running setup.py develop for polls-master
Successfully installed Django-1.7.4 Django-Select2-4.3.1 Pillow-2.8.0 South-1.0.2 dj-database-url-0.3.0 django-classy-tags-0.6.2 django-cms-3.1.2 django-reversion-1.8.5 django-sekizai-0.8.2 django-treebeard-3.0 djangocms-admin-style-0.2.7 djangocms-column-1.5 djangocms-file-0.1 djangocms-flash-0.2.0 djangocms-googlemap-0.2 djangocms-inherit-0.1 djangocms-installer-0.7.8 djangocms-link-1.6.2 djangocms-picture-0.1 djangocms-style-1.5 djangocms-teaser-0.1 djangocms-text-ckeditor-2.5.2 djangocms-video-0.1 html5lib-0.99999 polls-master pytz-2015.4 tzlocal-1.2
You have Django 1.7.4 installed already:
Found existing installation: Django 1.7.4. I believe that is the reason why Django 1.6.11 is not being installed. Hence the output message: Not uninstalling Django at /Volumes/Data/...

Someone on IRC explained me the problem :
It had to do with my sys.path and my $PYTHONPATH :
I added the main python path (the standard one, without using a virtualenv) in my $PYTHONPATH, so my $PYTHONPATH was added to my sys.path as a prefix, and the django from outside the virtualenv was imported prior to the one inside.
I only had to unset $PYTHONPATH in my ~/.zshrc and it worked like a charm!

Related

Installing style50 on windows

I was trying to install style50 on windows (having MSYS2) using pip install style50 , the concluding message doesnt mention of anything failing. But thereafter when I run style50 --version for verifying, I get the following error(2):
$ pip install style50
Collecting style50
Using cached style50-2.7.5-py3-none-any.whl (24 kB)
Collecting icdiff
Downloading icdiff-2.0.5.tar.gz (15 kB)
Preparing metadata (setup.py) ... done
Collecting jsbeautifier
Downloading jsbeautifier-1.14.4.tar.gz (74 kB)
|████████████████████████████████| 74 kB 474 kB/s
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Collecting termcolor
Using cached termcolor-1.1.0.tar.gz (3.9 kB)
Preparing metadata (setup.py) ... done
Collecting python-magic
Downloading python_magic-0.4.27-py2.py3-none-any.whl (13 kB)
Collecting autopep8>=1.4.3
Using cached autopep8-1.6.0-py2.py3-none-any.whl (45 kB)
Collecting jinja2>=2.10
Downloading Jinja2-3.1.2-py3-none-any.whl (133 kB)
|████████████████████████████████| 133 kB 1.1 MB/s
Collecting argparse
Using cached argparse-1.4.0-py2.py3-none-any.whl (23 kB)
Collecting pycodestyle>=2.8.0
Using cached pycodestyle-2.8.0-py2.py3-none-any.whl (42 kB)
Collecting toml
Using cached toml-0.10.2-py2.py3-none-any.whl (16 kB)
Collecting MarkupSafe>=2.0
Downloading MarkupSafe-2.1.1-cp310-cp310-win_amd64.whl (17 kB)
Collecting six>=1.13.0
Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting editorconfig>=0.12.2
Using cached EditorConfig-0.12.3-py3-none-any.whl (16 kB)
Using legacy 'setup.py install' for icdiff, since package 'wheel' is not installed.
Using legacy 'setup.py install' for termcolor, since package 'wheel' is not installed.
Building wheels for collected packages: jsbeautifier
Building wheel for jsbeautifier (pyproject.toml) ... done
Created wheel for jsbeautifier: filename=jsbeautifier-1.14.4-py3-none-any.whl size=93566 sha256=d10a21fd9f6ab76149c7440ac34f03eb81bcc7789a847f81704262d4d835ee65
Stored in directory: c:\users\<user>\appdata\local\pip\cache\wheels\80\98\1e\487c168894ca20596545a8bb7addfabc1465ea3a80ef8ba76d
Successfully built jsbeautifier
Installing collected packages: toml, six, pycodestyle, MarkupSafe, editorconfig, termcolor, python-magic, jsbeautifier, jinja2, icdiff, autopep8, argparse, style50
Running setup.py install for termcolor ... done
Running setup.py install for icdiff ... done
Successfully installed MarkupSafe-2.1.1 argparse-1.4.0 autopep8-1.6.0 editorconfig-0.12.3 icdiff-2.0.5 jinja2-3.1.2 jsbeautifier-1.14.4 pycodestyle-2.8.0 python-magic-0.4.27 six-1.16.0 style50-2.7.5 termcolor-1.1.0 toml-0.10.2
WARNING: You are using pip version 21.3.1; however, version 22.1.2 is available.
You should consider upgrading via the 'C:\Users\<user>\AppData\Local\Programs\Python\Python310\python.exe -m pip install --upgrade pip' command.
$ style50 --version
Traceback (most recent call last):
File "C:\Users\<user>\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\<user>\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Users\<user>\AppData\Local\Programs\Python\Python310\Scripts\style50.exe\__main__.py", line 4, in <module>
File "C:\Users\<user>\AppData\Local\Programs\Python\Python310\lib\site-packages\style50\__init__.py", line 20, in <module>
from ._api import Style50, StyleCheck, Error
File "C:\Users\<user>\AppData\Local\Programs\Python\Python310\lib\site-packages\style50\_api.py", line 4, in <module>
import fcntl
ModuleNotFoundError: No module named 'fcntl'
As per the documentation on Github (emphasis mine):
Along with most of CS50's command line tools, style50 supports being run on Windows but only via the Linux Subsystem in Windows 10. After launching it, style50 can be installed using the pip command above.

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

Cant install PyTorch using pip on Windows

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.

Installing tensorflow on Google Colaboratory shows a dependency problem

Collecting tensorflow
Downloading https://files.pythonhosted.org/packages/97/ae/0b08f53498417914f2274cc3b5576d2b83179b0cbb209457d0fde0152174/tensorflow-2.3.0-cp36-cp36m-manylinux2010_x86_64.whl (320.4MB)
|████████████████████████████████| 320.4MB 49kB/s
Collecting protobuf>=3.9.2
Downloading https://files.pythonhosted.org/packages/63/14/dc43f81adc543c435cfeb45dd4ac048a97a1eb621c2ccb68ab3d15118737/protobuf-3.12.4-cp36-cp36m-manylinux1_x86_64.whl (1.3MB)
|████████████████████████████████| 1.3MB 54.5MB/s
Collecting google-pasta>=0.1.8
Downloading https://files.pythonhosted.org/packages/a3/de/c648ef6835192e6e2cc03f40b19eeda4382c49b5bafb43d88b931c4c74ac/google_pasta-0.2.0-py3-none-any.whl (57kB)
|████████████████████████████████| 61kB 10.2MB/s
Collecting absl-py>=0.7.0
Downloading https://files.pythonhosted.org/packages/1a/53/9243c600e047bd4c3df9e69cfabc1e8004a82cac2e0c484580a78a94ba2a/absl-py-0.9.0.tar.gz (104kB)
|████████████████████████████████| 112kB 61.6MB/s
Collecting termcolor>=1.1.0
Downloading https://files.pythonhosted.org/packages/8a/48/a76be51647d0eb9f10e2a4511bf3ffb8cc1e6b14e9e4fab46173aa79f981/termcolor-1.1.0.tar.gz
Collecting scipy==1.4.1
Downloading https://files.pythonhosted.org/packages/dc/29/162476fd44203116e7980cfbd9352eef9db37c49445d1fec35509022f6aa/scipy-1.4.1-cp36-cp36m-manylinux1_x86_64.whl (26.1MB)
|████████████████████████████████| 26.1MB 116kB/s
Collecting grpcio>=1.8.6
Downloading https://files.pythonhosted.org/packages/f0/61/91641ea993600493d37f4897dc14ef396086868c586869937f6d57479a13/grpcio-1.31.0-cp36-cp36m-manylinux2014_x86_64.whl (3.4MB)
|████████████████████████████████| 3.4MB 48.2MB/s
Collecting h5py<2.11.0,>=2.10.0
Downloading https://files.pythonhosted.org/packages/60/06/cafdd44889200e5438b897388f3075b52a8ef01f28a17366d91de0fa2d05/h5py-2.10.0-cp36-cp36m-manylinux1_x86_64.whl (2.9MB)
|████████████████████████████████| 2.9MB 50.8MB/s
Collecting tensorboard<3,>=2.3.0
Downloading https://files.pythonhosted.org/packages/e9/1b/6a420d7e6ba431cf3d51b2a5bfa06a958c4141e3189385963dc7f6fbffb6/tensorboard-2.3.0-py3-none-any.whl (6.8MB)
|████████████████████████████████| 6.8MB 48.8MB/s
Collecting wrapt>=1.11.1
Downloading https://files.pythonhosted.org/packages/82/f7/e43cefbe88c5fd371f4cf0cf5eb3feccd07515af9fd6cf7dbf1d1793a797/wrapt-1.12.1.tar.gz
Collecting opt-einsum>=2.3.2
Downloading https://files.pythonhosted.org/packages/bc/19/404708a7e54ad2798907210462fd950c3442ea51acc8790f3da48d2bee8b/opt_einsum-3.3.0-py3-none-any.whl (65kB)
|████████████████████████████████| 71kB 11.1MB/s
Collecting tensorflow-estimator<2.4.0,>=2.3.0
Downloading https://files.pythonhosted.org/packages/e9/ed/5853ec0ae380cba4588eab1524e18ece1583b65f7ae0e97321f5ff9dfd60/tensorflow_estimator-2.3.0-py2.py3-none-any.whl (459kB)
|████████████████████████████████| 460kB 53.6MB/s
Collecting astunparse==1.6.3
Downloading https://files.pythonhosted.org/packages/2b/03/13dde6512ad7b4557eb792fbcf0c653af6076b81e5941d36ec61f7ce6028/astunparse-1.6.3-py2.py3-none-any.whl
Collecting wheel>=0.26
Downloading https://files.pythonhosted.org/packages/8c/23/848298cccf8e40f5bbb59009b32848a4c38f4e7f3364297ab3c3e2e2cd14/wheel-0.34.2-py2.py3-none-any.whl
Collecting gast==0.3.3
Downloading https://files.pythonhosted.org/packages/d6/84/759f5dd23fec8ba71952d97bcc7e2c9d7d63bdc582421f3cd4be845f0c98/gast-0.3.3-py2.py3-none-any.whl
Collecting six>=1.12.0
Using cached https://files.pythonhosted.org/packages/ee/ff/48bde5c0f013094d729fe4b0316ba2a24774b3ff1c52d924a8a4cb04078a/six-1.15.0-py2.py3-none-any.whl
Collecting keras-preprocessing<1.2,>=1.1.1
Downloading https://files.pythonhosted.org/packages/79/4c/7c3275a01e12ef9368a892926ab932b33bb13d55794881e3573482b378a7/Keras_Preprocessing-1.1.2-py2.py3-none-any.whl (42kB)
|████████████████████████████████| 51kB 8.6MB/s
Collecting numpy<1.19.0,>=1.16.0
Downloading https://files.pythonhosted.org/packages/b3/a9/b1bc4c935ed063766bce7d3e8c7b20bd52e515ff1c732b02caacf7918e5a/numpy-1.18.5-cp36-cp36m-manylinux1_x86_64.whl (20.1MB)
|████████████████████████████████| 20.1MB 1.2MB/s
Collecting setuptools
Downloading https://files.pythonhosted.org/packages/ed/16/e9f5c5b86696da09298ea10c32d68ad8ea21f888e45b11aa9e615adda6c9/setuptools-49.2.1-py3-none-any.whl (789kB)
|████████████████████████████████| 798kB 52.8MB/s
Collecting werkzeug>=0.11.15
Downloading https://files.pythonhosted.org/packages/cc/94/5f7079a0e00bd6863ef8f1da638721e9da21e5bacee597595b318f71d62e/Werkzeug-1.0.1-py2.py3-none-any.whl (298kB)
|████████████████████████████████| 307kB 52.4MB/s
Collecting google-auth<2,>=1.6.3
Downloading https://files.pythonhosted.org/packages/0f/79/4c59796bb02535aee5e5d2e2c5e16008aaf48903c2ec2ff566a2774bb3e0/google_auth-1.20.1-py2.py3-none-any.whl (91kB)
|████████████████████████████████| 92kB 13.4MB/s
Collecting tensorboard-plugin-wit>=1.6.0
Downloading https://files.pythonhosted.org/packages/b6/85/5c5ac0a8c5efdfab916e9c6bc18963f6a6996a8a1e19ec4ad8c9ac9c623c/tensorboard_plugin_wit-1.7.0-py3-none-any.whl (779kB)
|████████████████████████████████| 788kB 54.0MB/s
Collecting requests<3,>=2.21.0
Using cached https://files.pythonhosted.org/packages/45/1e/0c169c6a5381e241ba7404532c16a21d86ab872c9bed8bdcd4c423954103/requests-2.24.0-py2.py3-none-any.whl
Collecting markdown>=2.6.8
Downloading https://files.pythonhosted.org/packages/a4/63/eaec2bd025ab48c754b55e8819af0f6a69e2b1e187611dd40cbbe101ee7f/Markdown-3.2.2-py3-none-any.whl (88kB)
|████████████████████████████████| 92kB 13.4MB/s
Collecting google-auth-oauthlib<0.5,>=0.4.1
Downloading https://files.pythonhosted.org/packages/7b/b8/88def36e74bee9fce511c9519571f4e485e890093ab7442284f4ffaef60b/google_auth_oauthlib-0.4.1-py2.py3-none-any.whl
Collecting pyasn1-modules>=0.2.1
Downloading https://files.pythonhosted.org/packages/95/de/214830a981892a3e286c3794f41ae67a4495df1108c3da8a9f62159b9a9d/pyasn1_modules-0.2.8-py2.py3-none-any.whl (155kB)
|████████████████████████████████| 163kB 54.5MB/s
Collecting rsa<5,>=3.1.4; python_version >= "3.5"
Downloading https://files.pythonhosted.org/packages/1c/df/c3587a667d6b308fadc90b99e8bc8774788d033efcc70f4ecaae7fad144b/rsa-4.6-py3-none-any.whl (47kB)
|████████████████████████████████| 51kB 8.3MB/s
Collecting cachetools<5.0,>=2.0.0
Downloading https://files.pythonhosted.org/packages/cd/5c/f3aa86b6d5482f3051b433c7616668a9b96fbe49a622210e2c9781938a5c/cachetools-4.1.1-py3-none-any.whl
Collecting idna<3,>=2.5
Using cached https://files.pythonhosted.org/packages/a2/38/928ddce2273eaa564f6f50de919327bf3a00f091b5baba8dfa9460f3a8a8/idna-2.10-py2.py3-none-any.whl
Collecting chardet<4,>=3.0.2
Using cached https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl
Collecting certifi>=2017.4.17
Using cached https://files.pythonhosted.org/packages/5e/c4/6c4fe722df5343c33226f0b4e0bb042e4dc13483228b4718baf286f86d87/certifi-2020.6.20-py2.py3-none-any.whl
Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1
Using cached https://files.pythonhosted.org/packages/9f/f0/a391d1463ebb1b233795cabfc0ef38d3db4442339de68f847026199e69d7/urllib3-1.25.10-py2.py3-none-any.whl
Collecting importlib-metadata; python_version < "3.8"
Downloading https://files.pythonhosted.org/packages/8e/58/cdea07eb51fc2b906db0968a94700866fc46249bdc75cac23f9d13168929/importlib_metadata-1.7.0-py2.py3-none-any.whl
Collecting requests-oauthlib>=0.7.0
Using cached https://files.pythonhosted.org/packages/a3/12/b92740d845ab62ea4edf04d2f4164d82532b5a0b03836d4d4e71c6f3d379/requests_oauthlib-1.3.0-py2.py3-none-any.whl
Collecting pyasn1<0.5.0,>=0.4.6
Downloading https://files.pythonhosted.org/packages/62/1e/a94a8d635fa3ce4cfc7f506003548d0a2447ae76fd5ca53932970fe3053f/pyasn1-0.4.8-py2.py3-none-any.whl (77kB)
|████████████████████████████████| 81kB 12.2MB/s
Collecting zipp>=0.5
Downloading https://files.pythonhosted.org/packages/b2/34/bfcb43cc0ba81f527bc4f40ef41ba2ff4080e047acb0586b56b3d017ace4/zipp-3.1.0-py3-none-any.whl
Collecting oauthlib>=3.0.0
Using cached https://files.pythonhosted.org/packages/05/57/ce2e7a8fa7c0afb54a0581b14a65b56e62b5759dbc98e80627142b8a3704/oauthlib-3.1.0-py2.py3-none-any.whl
Building wheels for collected packages: absl-py, termcolor, wrapt
Building wheel for absl-py (setup.py) ... done
Created wheel for absl-py: filename=absl_py-0.9.0-cp36-none-any.whl size=121931 sha256=85a9d87c8ec866ac12d5b25049a090ab949857c4d39d4793b368cff06c7e94ac
Stored in directory: /root/.cache/pip/wheels/8e/28/49/fad4e7f0b9a1227708cbbee4487ac8558a7334849cb81c813d
Building wheel for termcolor (setup.py) ... done
Created wheel for termcolor: filename=termcolor-1.1.0-cp36-none-any.whl size=4832 sha256=2c15675c61e919a4f30b0b4c575b43abf65cf7b7e671c24e2df484b0fcf669ff
Stored in directory: /root/.cache/pip/wheels/7c/06/54/bc84598ba1daf8f970247f550b175aaaee85f68b4b0c5ab2c6
Building wheel for wrapt (setup.py) ... done
Created wheel for wrapt: filename=wrapt-1.12.1-cp36-cp36m-linux_x86_64.whl size=67489 sha256=75a9a273381441c10d1d2bbe7305c9bb68ce54033a916bea154a55afc4a208c1
Stored in directory: /root/.cache/pip/wheels/b1/c2/ed/d62208260edbd3fa7156545c00ef966f45f2063d0a84f8208a
Successfully built absl-py termcolor wrapt
ERROR: kaggle 1.5.6 has requirement urllib3<1.25,>=1.21.1, but you'll have urllib3 1.25.10 which is incompatible.
ERROR: google-colab 1.0.0 has requirement google-auth~=1.17.2, but you'll have google-auth 1.20.1 which is incompatible.
ERROR: google-colab 1.0.0 has requirement requests~=2.23.0, but you'll have requests 2.24.0 which is incompatible.
ERROR: datascience 0.10.6 has requirement folium==0.2.1, but you'll have folium 0.8.3 which is incompatible.
ERROR: albumentations 0.1.12 has requirement imgaug<0.2.7,>=0.2.5, but you'll have imgaug 0.2.9 which is incompatible.
Installing collected packages: six, setuptools, protobuf, google-pasta, absl-py, termcolor, numpy, scipy, grpcio, h5py, werkzeug, wheel, pyasn1, pyasn1-modules, rsa, cachetools, google-auth, tensorboard-plugin-wit, idna, chardet, certifi, urllib3, requests, zipp, importlib-metadata, markdown, oauthlib, requests-oauthlib, google-auth-oauthlib, tensorboard, wrapt, opt-einsum, tensorflow-estimator, astunparse, gast, keras-preprocessing, tensorflow
Successfully installed absl-py-0.9.0 astunparse-1.6.3 cachetools-4.1.1 certifi-2020.6.20 chardet-3.0.4 gast-0.3.3 google-auth-1.20.1 google-auth-oauthlib-0.4.1 google-pasta-0.2.0 grpcio-1.31.0 h5py-2.10.0 idna-2.10 importlib-metadata-1.7.0 keras-preprocessing-1.1.2 markdown-3.2.2 numpy-1.18.5 oauthlib-3.1.0 opt-einsum-3.3.0 protobuf-3.12.4 pyasn1-0.4.8 pyasn1-modules-0.2.8 requests-2.24.0 requests-oauthlib-1.3.0 rsa-4.6 scipy-1.4.1 setuptools-49.2.1 six-1.15.0 tensorboard-2.3.0 tensorboard-plugin-wit-1.7.0 tensorflow-2.3.0 tensorflow-estimator-2.3.0 termcolor-1.1.0 urllib3-1.25.10 werkzeug-1.0.1 wheel-0.34.2 wrapt-1.12.1 zipp-3.1.0
ERROR: Exception:
Traceback (most recent call last):
File "/usr/lib/python3.6/shutil.py", line 550, in move
os.rename(src, real_dst)
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pip-target-x6fc9bjj/lib/python/protobuf-3.12.4-py3.6-nspkg.pth' -> '/content/notebooks/protobuf-3.12.4-py3.6-nspkg.pth'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/cli/base_command.py", line 153, in _main
status = self.run(options, args)
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/commands/install.py", line 505, in run
options.target_dir, target_temp_dir, options.upgrade
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/commands/install.py", line 563, in _handle_target_dir
target_item_dir
File "/usr/lib/python3.6/shutil.py", line 564, in move
copy_function(src, real_dst)
File "/usr/lib/python3.6/shutil.py", line 263, in copy2
copyfile(src, dst, follow_symlinks=follow_symlinks)
File "/usr/lib/python3.6/shutil.py", line 121, in copyfile
with open(dst, 'wb') as fdst:
FileNotFoundError: [Errno 2] No such file or directory: '/content/notebooks/protobuf-3.12.4-py3.6-nspkg.pth'
WARNING: The following packages were previously imported in this runtime:
[cachetools,certifi,chardet,google,idna,numpy,oauthlib,pyasn1,pyasn1_modules,requests_oauthlib,rsa,six]
You must restart the runtime in order to use newly installed versions.
As you can see, kaggle, google-colab, datascience and albumentations show dependency problem. When I tried installing them manually, they show another dependency problem and I become so puzzled that I don't know what to do. I think it may be related to Colab because when I try installing tensorflow in my computer, it works well. How can I solve this dependency problem?
Google Colab usually have all the libraries pre-installled in it. Most of the time you will not need to install any library. In case you find that something is missing then you can install them easily using:
!pip install tensorflow==1.2
If you want to install system libs then :
!apt-get -qq install -y libfluidsynth1
see the syntax is similar to Jupyter Notebook

Permission denied when trying to install inside a virtualenv using ansible

I have this play in my ansible playbook
- name: Setup virtualenv
pip:
requirements="/vagrant/webapp/requirements/{{ requirements_filename }}"
virtualenv="$HOME/.envs/{{ project_name }}"
However, I am receiving a Permission denied error. It seems like ansible is trying to install the package into the system path and not into the virtualenv.
Here's the full traceback:
TASK: [deploy | Setup virtualenv] *********************************************
failed: [default] => {"cmd": "/usr/bin/pip install -r /vagrant/webapp/requirements/dev.txt", "failed": true}
msg: stdout: New python executable in /home/vagrant/.envs/venv/bin/python
Installing setuptools, pip...done.
Downloading/unpacking django>=1.8 (from -r /vagrant/webapp/requirements/requirements.txt (line 3))
Requirement already satisfied (use --upgrade to upgrade): wsgiref>=0.1.2 in /usr/lib/python2.7 (from -r /vagrant/webapp/requirements/requirements.txt (line 4))
Downloading/unpacking django-allauth>=0.19.1 (from -r /vagrant/webapp/requirements/requirements.txt (line 5))
Running setup.py (path:/tmp/pip_build_vagrant/django-allauth/setup.py) egg_info for package django-allauth
Downloading/unpacking psycopg2>=2.6 (from -r /vagrant/webapp/requirements/requirements.txt (line 6))
Running setup.py (path:/tmp/pip_build_vagrant/psycopg2/setup.py) egg_info for package psycopg2
Downloading/unpacking django-currencies>=0.3.3 (from -r /vagrant/webapp/requirements/requirements.txt (line 7))
Downloading django-currencies-0.3.3.tar.gz
Running setup.py (path:/tmp/pip_build_vagrant/django-currencies/setup.py) egg_info for package django-currencies
Downloading/unpacking django-countries>=3.2 (from -r /vagrant/webapp/requirements/requirements.txt (line 8))
Running setup.py (path:/tmp/pip_build_vagrant/django-countries/setup.py) egg_info for package django-countries
Downloading/unpacking stripe>=1.22.1 (from -r /vagrant/webapp/requirements/requirements.txt (line 9))
Running setup.py (path:/tmp/pip_build_vagrant/stripe/setup.py) egg_info for package stripe
Downloading/unpacking pillow>=2.8.0 (from -r /vagrant/webapp/requirements/requirements.txt (line 10))
Running setup.py (path:/tmp/pip_build_vagrant/pillow/setup.py) egg_info for package pillow
Single threaded build, not installing mp_compile: 1 processes
warning: no files found matching 'LICENSE' under directory 'docs'
Downloading/unpacking django-compressor>=1.4 (from -r /vagrant/webapp/requirements/requirements.txt (line 11))
Downloading/unpacking djangorestframework>=3.1.1 (from -r /vagrant/webapp/requirements/requirements.txt (line 12))
Downloading/unpacking django-filter>=0.9.2 (from -r /vagrant/webapp/requirements/requirements.txt (line 13))
Downloading django_filter-0.9.2-py2.py3-none-any.whl
Obtaining formtools from git+https://github.com/django/django-formtools.git#egg=formtools (from -r /vagrant/webapp/requirements/requirements.txt (line 14))
Cloning https://github.com/django/django-formtools.git to ./src/formtools
Running setup.py (path:/tmp/src/formtools/setup.py) egg_info for package formtools
Installing extra requirements: 'egg'
Downloading/unpacking django-widget-tweaks>=1.3 (from -r /vagrant/webapp/requirements/requirements.txt (line 15))
Downloading django-widget-tweaks-1.3.tar.gz
Running setup.py (path:/tmp/pip_build_vagrant/django-widget-tweaks/setup.py) egg_info for package django-widget-tweaks
Downloading/unpacking django-braces>=1.4.0 (from -r /vagrant/webapp/requirements/requirements.txt (line 16))
Downloading django_braces-1.4.0-py2.py3-none-any.whl
Downloading/unpacking django-debug-toolbar>=1.3.0 (from -r /vagrant/webapp/requirements/dev.txt (line 4))
Downloading/unpacking python-openid>=2.2.5 (from django-allauth>=0.19.1->-r /vagrant/webapp/requirements/requirements.txt (line 5))
Running setup.py (path:/tmp/pip_build_vagrant/python-openid/setup.py) egg_info for package python-openid
warning: no files found matching 'CHANGELOG'
warning: no files found matching '*.css' under directory 'doc'
warning: no files found matching '*.html' under directory 'doc'
Downloading/unpacking requests-oauthlib>=0.3.0 (from django-allauth>=0.19.1->-r /vagrant/webapp/requirements/requirements.txt (line 5))
Downloading requests_oauthlib-0.4.2-py2.py3-none-any.whl
Requirement already satisfied (use --upgrade to upgrade): requests>=1.0.3 in /usr/lib/python2.7/dist-packages (from django-allauth>=0.19.1->-r /vagrant/webapp/requirements/requirements.txt (line 5))
Downloading/unpacking django-appconf>=0.4 (from django-compressor>=1.4->-r /vagrant/webapp/requirements/requirements.txt (line 11))
Downloading django_appconf-1.0.1-py2.py3-none-any.whl
Requirement already satisfied (use --upgrade to upgrade): six in /usr/local/lib/python2.7/dist-packages (from django-braces>=1.4.0->-r /vagrant/webapp/requirements/requirements.txt (line 16))
Downloading/unpacking sqlparse (from django-debug-toolbar>=1.3.0->-r /vagrant/webapp/requirements/dev.txt (line 4))
Running setup.py (path:/tmp/pip_build_vagrant/sqlparse/setup.py) egg_info for package sqlparse
Downloading/unpacking oauthlib>=0.6.2 (from requests-oauthlib>=0.3.0->django-allauth>=0.19.1->-r /vagrant/webapp/requirements/requirements.txt (line 5))
Running setup.py (path:/tmp/pip_build_vagrant/oauthlib/setup.py) egg_info for package oauthlib
Installing collected packages: django, django-allauth, psycopg2, django-currencies, django-countries, stripe, pillow, django-compressor, djangorestframework, django-filter, formtools, django-widget-tweaks, django-braces, django-debug-toolbar, python-openid, requests-oauthlib, django-appconf, sqlparse, oauthlib
Cleaning up...
Exception:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 122, in main
status = self.run(options, args)
File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 283, in run
requirement_set.install(install_options, global_options, root=options.root_path)
File "/usr/lib/python2.7/dist-packages/pip/req.py", line 1435, in install
requirement.install(install_options, global_options, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/pip/req.py", line 671, in install
self.move_wheel_files(self.source_dir, root=root)
File "/usr/lib/python2.7/dist-packages/pip/req.py", line 901, in move_wheel_files
pycompile=self.pycompile,
File "/usr/lib/python2.7/dist-packages/pip/wheel.py", line 206, in move_wheel_files
clobber(source, lib_dir, True)
File "/usr/lib/python2.7/dist-packages/pip/wheel.py", line 193, in clobber
os.makedirs(destsubdir)
File "/usr/lib/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/Django-1.8.dist-info'
Storing debug log for failure in /home/vagrant/.pip/pip.log
FATAL: all hosts have already failed -- aborting
I solved the problem by setting the path explicitly and not using the $HOME variable.
- name: Setup virtualenv
pip:
virtualenv="/home/vagrant/.envs/{{ project_name }}"
requirements="/vagrant/webapp/requirements/{{ requirements_filename }}"
Try specifying a pip executable path as well:
executable="$HOME/.envs/{{ project_name }}/bin/pip"
Didn't search for an exact reason TBH, but had to do the same to get stuff installed into virtual environments. Seemed like it tried to install into a virtual environment using global pip. Maybe that's possible to do under some circumstances, wasn't my case.
It seems the pip module is using the system Python so it will try and install the package on the expected system path to site-packages and since you're not running this as root or using sudo it can't write to '/usr/local/lib/python2.7/...'
I'm assuming you want to install the pip package under the virtualenv, correct?
If so beware that Ansible modules always use, by default, the system default Python interpreter unless you set ansible_python_interpreter.
An example of how to do this can be found on Best way to always run ansible inside a virtualenv on remote machines?
A link to a short discussion about the subject and why Ansible people don't want to change #!/usr/bin/python for the more virtualenv-friendly #!/usr/bin/env python can be found here.
As a note you'll have the same problem if you're running Ansible from a local virtualenv and try and use say ec2 module without having boto installed at the system-level (but installed at the virtualenv level).
Looks like it is using /usr/bin/pip, not pip from virtualenv. Not sure why this happens - a bug in Ansible? Can you manually check your virtualenv has pip command? One thing I can think out from my head pip is created for root (sudo) and you try to run the command as a normal user and it doesn't have read access to virtualenv'ed pip.
You can probably use pip manually like this for workaround.
- name: Create virtualenv for app using chosen Python
shell: virtualenv --python=python3.4 {{deploy_location}}/venv
sudo: yes
- name: Install Python packages
sudo: yes
command: {{deploy_location}}/venv/bin/pip -r {{deploy_location}}/requirements.txt

Resources