2

I'm wanting to install ten packages via pip in virtualenv.

I possibly used sudo improperly in my haste to get it "working" as suggested by https://stackoverflow.com/a/27939356/1063287, ie I installed virtualenv with sudo:

sudo virtualenv --no-site-packages ENV

I did this because without sudo I got this:

me@my-comp:/var/www/html$ virtualenv --no-site-packages ENV
Running virtualenv with interpreter /usr/bin/python2
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/virtualenv.py", line 2364, in <module>
    main()
  File "/usr/lib/python3/dist-packages/virtualenv.py", line 719, in main
    symlink=options.symlink)
  File "/usr/lib/python3/dist-packages/virtualenv.py", line 942, in create_environment
    site_packages=site_packages, clear=clear, symlink=symlink))
  File "/usr/lib/python3/dist-packages/virtualenv.py", line 1144, in install_python
    mkdir(lib_dir)
  File "/usr/lib/python3/dist-packages/virtualenv.py", line 324, in mkdir
    os.makedirs(path)
  File "/usr/lib/python2.7/os.py", line 150, in makedirs
    makedirs(head, mode)
  File "/usr/lib/python2.7/os.py", line 150, in makedirs
    makedirs(head, mode)
  File "/usr/lib/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/var/www/html/ENV'

In Ubuntu 16.04 I cannot see "Disk Utility" to test the solution offered however.

Trying to pip install lxml results in this final error:

Command "/var/www/html/ENV/bin/python2 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-jcCDbh/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-_oNugl-record/install-record.txt --single-version-externally-managed --compile --install-headers /var/www/html/ENV/include/site/python2.7/lxml" failed with error code 1 in /tmp/pip-build-jcCDbh/lxml/

Whilst two other examples are below:

pip install bottle:

(ENV) me@my-comp:/var/www/html/ENV$ pip install bottle
Collecting bottle
Installing collected packages: bottle
Exception:
Traceback (most recent call last):
  File "/var/www/html/ENV/local/lib/python2.7/site-packages/pip/basecommand.py", line 209, in main
    status = self.run(options, args)
  File "/var/www/html/ENV/local/lib/python2.7/site-packages/pip/commands/install.py", line 335, in run
    prefix=options.prefix_path,
  File "/var/www/html/ENV/local/lib/python2.7/site-packages/pip/req/req_set.py", line 732, in install
    **kwargs
  File "/var/www/html/ENV/local/lib/python2.7/site-packages/pip/req/req_install.py", line 835, in install
    self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
  File "/var/www/html/ENV/local/lib/python2.7/site-packages/pip/req/req_install.py", line 1030, in move_wheel_files
    isolated=self.isolated,
  File "/var/www/html/ENV/local/lib/python2.7/site-packages/pip/wheel.py", line 344, in move_wheel_files
    clobber(source, lib_dir, True)
  File "/var/www/html/ENV/local/lib/python2.7/site-packages/pip/wheel.py", line 322, in clobber
    shutil.copyfile(srcfile, destfile)
  File "/usr/lib/python2.7/shutil.py", line 83, in copyfile
    with open(dst, 'wb') as fdst:
IOError: [Errno 13] Permission denied: '/var/www/html/ENV/lib/python2.7/site-packages/bottle.pyc'

pip install requests:

(ENV) me@my-comp:/var/www/html/ENV$ pip install requests
Collecting requests
  Using cached requests-2.9.1-py2.py3-none-any.whl
Installing collected packages: requests
Exception:
Traceback (most recent call last):
  File "/var/www/html/ENV/local/lib/python2.7/site-packages/pip/basecommand.py", line 209, in main
    status = self.run(options, args)
  File "/var/www/html/ENV/local/lib/python2.7/site-packages/pip/commands/install.py", line 335, in run
    prefix=options.prefix_path,
  File "/var/www/html/ENV/local/lib/python2.7/site-packages/pip/req/req_set.py", line 732, in install
    **kwargs
  File "/var/www/html/ENV/local/lib/python2.7/site-packages/pip/req/req_install.py", line 835, in install
    self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
  File "/var/www/html/ENV/local/lib/python2.7/site-packages/pip/req/req_install.py", line 1030, in move_wheel_files
    isolated=self.isolated,
  File "/var/www/html/ENV/local/lib/python2.7/site-packages/pip/wheel.py", line 344, in move_wheel_files
    clobber(source, lib_dir, True)
  File "/var/www/html/ENV/local/lib/python2.7/site-packages/pip/wheel.py", line 315, in clobber
    ensure_dir(destdir)
  File "/var/www/html/ENV/local/lib/python2.7/site-packages/pip/utils/__init__.py", line 83, in ensure_dir
    os.makedirs(path)
  File "/var/www/html/ENV/lib/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/var/www/html/ENV/lib/python2.7/site-packages/requests-2.9.1.dist-info'

If I use sudo pip install bottle, I get:

sudo: pip: command not found

Update:

I ran this suggestion:

$sudo chown -R $(whoami) /var/www/html/ENV

and can now pip install bottle, requests, pymongo, beautifulsoup4, Beaker, pycrypto and tldextract. However, lxml and pillow are failing.

lxml fail:

Failed building wheel for lxml

Command "/var/www/html/ENV/bin/python2 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-yHLQQe/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-hLznuQ-record/install-record.txt --single-version-externally-managed --compile --install-headers /var/www/html/ENV/include/site/python2.7/lxml" failed with error code 1 in /tmp/pip-build-yHLQQe/lxml/

pillow fail:

Failed building wheel for pillow

Command "/var/www/html/ENV/bin/python2 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-IkuM34/pillow/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-60McJh-record/install-record.txt --single-version-externally-managed --compile --install-headers /var/www/html/ENV/include/site/python2.7/pillow" failed with error code 1 in /tmp/pip-build-IkuM34/pillow/

I have tried the suggestion here:

https://stackoverflow.com/a/6504860/1063287

for troubleshooting these remaining errors and libxml2-dev, libxslt1-dev and python2.7-dev are already installed.

Update 2:

Installed zlib1g-dev as per:

https://stackoverflow.com/a/19289133/1063287

and can install lxml now.

Still can't install pillow.

Update 3:

Installed libjpeg8-dev as per:

https://stackoverflow.com/a/33582789/1063287

and can now install pillow.

Community
  • 1
  • 1
user1063287
  • 10,265
  • 25
  • 122
  • 218

2 Answers2

1

Have you installed pip?

Try installing pip by

sudo apt-get install python

,download pip from https://pip.pypa.io/en/stable/installing/ then do a 'python get-pip.py'. This will install pip

Then for the issue of permission denied use

$sudo chown -R $(whoami) /var/www/html/ENV
Dendi Suhubdy
  • 2,877
  • 3
  • 19
  • 20
  • Thanks for idea, this seems to install pip though: `sudo virtualenv --no-site-packages ENV`. – user1063287 Apr 16 '16 at 07:55
  • I applied second suggestion re: permissions and could install some packages but not all, but after some troubleshooting got them all to install - see original post for "Update". – user1063287 Apr 16 '16 at 09:08
1

The solution was a combination of this suggestion:

$sudo chown -R $(whoami) /var/www/html/ENV

And making sure the following packages were installed:

Community
  • 1
  • 1
user1063287
  • 10,265
  • 25
  • 122
  • 218