Note: I also followed the same steps on a Ubuntu Desktop 16.04 but didn't get any error.
I'm on Ubuntu Server 16.04.
I am logged in as "user1" who has sudo privileges.
I installed Python 3.6.2 from source:
$ sudo apt install build-essential checkinstall
$ sudo apt install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
$ wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tar.xz
$ tar xvf Python-3.6.2.tar.xz
$ cd Python-3.6.2/
$ ./configure --enable-shared --prefix=/usr/local LDFLAGS="-Wl,--rpath=/usr/local/lib"
$ sudo make altinstall
The installation completes corrrectly, although the output ends like this:
The directory '/home/user1/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/user1/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting setuptools
Collecting pip
Installing collected packages: setuptools, pip
Successfully installed pip-9.0.1 setuptools-28.8.0
But I can see that "user1" is the owner of the ".cache" folder:
~$ ls -la .cache/
drwx------ 3 user1 sudo 4096 Sep 17 12:41 pip
I create a virtual environment called "test":
~/virtualenvs$ python3.6 -m venv test
Activate it:
~/virtualenvs$ source test/bin/activate
(test) ~/virtualenvs$
(test) ~/virtualenvs$ which python
/home/user1/virtualenvs/test/bin/python
(test) ~/virtualenvs$ which pip
/home/user1/virtualenvs/test/bin/pip
When I try to install the "mod_wsgi" package, I get a "Permission denied" error:
(test) ~/virtualenvs$ pip install mod_wsgi
Collecting mod_wsgi
Using cached mod_wsgi-4.5.18.tar.gz
Complete output from command python setup.py egg_info:
running egg_info
creating pip-egg-info/mod_wsgi.egg-info
writing pip-egg-info/mod_wsgi.egg-info/PKG-INFO
writing dependency_links to pip-egg-info/mod_wsgi.egg-info/dependency_links.txt
writing entry points to pip-egg-info/mod_wsgi.egg-info/entry_points.txt
writing top-level names to pip-egg-info/mod_wsgi.egg-info/top_level.txt
writing manifest file 'pip-egg-info/mod_wsgi.egg-info/SOURCES.txt'
/usr/local/lib/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'bugtrack_url'
warnings.warn(msg)
warning: manifest_maker: standard file '-c' not found
error: [Errno 13] Permission denied: '/usr/local/lib/python3.6/lib2to3/Grammar3.6.2.final.0.pickle'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-sp0fende/mod-wsgi/
If I change the following permission:
$ sudo chmod -R 777 /usr/local/lib/python3.6/lib2to3/
This solves the issue and I can install the package. But I would rather use another solution if possible.
Does anyone has an idea?
EDIT
I solved it by changing the permission of the following 2 files:
$ sudo chmod 777 /usr/local/lib/python3.6/lib2to3/Grammar3.6.2.final.0.pickle
$ sudo chmod 777 /usr/local/lib/python3.6/lib2to3/PatternGrammar3.6.2.final.0.pickle