4

I'm trying to install a new virtual environment in a new project folder and it's not installing pip in the virtual environment.

Here is the bash log:

$ virtualenv --version
12.1.1

$ sudo virtualenv venv
Password:
New python executable in venv/bin/python2.7
Not overwriting existing python script venv/bin/python (you must use venv/bin/python2.7)
Please make sure you remove any previous custom paths from your /Users/keithy/.pydistutils.cfg file.
Installing setuptools, pip...done.

$ source venv/bin/activate

(venv) $ which python
/Users/keithy/Desktop/learn/flasky/venv/bin/python

(venv) $ which pip
/usr/local/bin/pip

(venv) $ ls -l venv/bin
total 80
-rw-r--r--  1 root    staff   2220 May 18 08:48 activate
-rw-r--r--  1 root    staff   1276 May 18 08:48 activate.csh
-rw-r--r--  1 root    staff   2489 May 18 08:48 activate.fish
-rw-r--r--  1 root    staff   1137 May 18 08:48 activate_this.py
lrwxr-xr-x  1 root    staff      9 May 18 08:53 python -> python2.7
lrwxr-xr-x  1 root    staff      9 May 18 08:53 python2 -> python2.7
-rwxr-xr-x  1 keithy  staff  12616 May 18 08:53 python2.7

(venv) $ pip install flask-bootstrap
Collecting flask-bootstrap
  Downloading Flask-Bootstrap-3.3.4.1.tar.gz (442kB)
    100% |################################| 446kB 1.9MB/s
Requirement already satisfied (use --upgrade to upgrade): Flask>=0.8 in /lib/python2.7/site-packages (from flask-bootstrap)
Requirement already satisfied (use --upgrade to upgrade): Werkzeug>=0.7 in /lib/python2.7/site-packages (from Flask>=0.8->flask-bootstrap)
Requirement already satisfied (use --upgrade to upgrade): Jinja2>=2.4 in /lib/python2.7/site-packages (from Flask>=0.8->flask-bootstrap)
Requirement already satisfied (use --upgrade to upgrade): itsdangerous>=0.21 in /lib/python2.7/site-packages (from Flask>=0.8->flask-bootstrap)
Requirement already satisfied (use --upgrade to upgrade): markupsafe in /lib/python2.7/site-packages (from Jinja2>=2.4->Flask>=0.8->flask-bootstrap)
Installing collected packages: flask-bootstrap
  Running setup.py install for flask-bootstrap
    error: could not create '/lib/python2.7/site-packages/flask_bootstrap': Permission denied
    Complete output from command /usr/local/opt/python/bin/python2.7 -c "import setuptools, tokenize;__file__='/var/folders/rx/j0sk_6vs0dg59w3q4rm_wmwc0000gn/T/pip-build-wFK2ha/flask-bootstrap/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/rx/j0sk_6vs0dg59w3q4rm_wmwc0000gn/T/pip-UnbbND-record/install-record.txt --single-version-externally-managed --compile:
    running install

    running build

    running build_py

    creating build

    creating build/lib

    creating build/lib/flask_bootstrap

    copying flask_bootstrap/__init__.py -> build/lib/flask_bootstrap

    running egg_info

    writing requirements to Flask_Bootstrap.egg-info/requires.txt

    writing Flask_Bootstrap.egg-info/PKG-INFO

    writing top-level names to Flask_Bootstrap.egg-info/top_level.txt

    writing dependency_links to Flask_Bootstrap.egg-info/dependency_links.txt

    warning: manifest_maker: standard file '-c' not found



    reading manifest file 'Flask_Bootstrap.egg-info/SOURCES.txt'

    reading manifest template 'MANIFEST.in'

    writing manifest file 'Flask_Bootstrap.egg-info/SOURCES.txt'

    creating build/lib/flask_bootstrap/static

    copying flask_bootstrap/static/jquery.js -> build/lib/flask_bootstrap/static

    copying flask_bootstrap/static/jquery.min.js -> build/lib/flask_bootstrap/static

    copying flask_bootstrap/static/jquery.min.map -> build/lib/flask_bootstrap/static

    creating build/lib/flask_bootstrap/static/css

    copying flask_bootstrap/static/css/bootstrap-theme.css -> build/lib/flask_bootstrap/static/css

    copying flask_bootstrap/static/css/bootstrap-theme.css.map -> build/lib/flask_bootstrap/static/css

    copying flask_bootstrap/static/css/bootstrap-theme.min.css -> build/lib/flask_bootstrap/static/css

    copying flask_bootstrap/static/css/bootstrap.css -> build/lib/flask_bootstrap/static/css

    copying flask_bootstrap/static/css/bootstrap.css.map -> build/lib/flask_bootstrap/static/css

    copying flask_bootstrap/static/css/bootstrap.min.css -> build/lib/flask_bootstrap/static/css

    creating build/lib/flask_bootstrap/static/fonts

    copying flask_bootstrap/static/fonts/glyphicons-halflings-regular.eot -> build/lib/flask_bootstrap/static/fonts

    copying flask_bootstrap/static/fonts/glyphicons-halflings-regular.svg -> build/lib/flask_bootstrap/static/fonts

    copying flask_bootstrap/static/fonts/glyphicons-halflings-regular.ttf -> build/lib/flask_bootstrap/static/fonts

    copying flask_bootstrap/static/fonts/glyphicons-halflings-regular.woff -> build/lib/flask_bootstrap/static/fonts

    copying flask_bootstrap/static/fonts/glyphicons-halflings-regular.woff2 -> build/lib/flask_bootstrap/static/fonts

    creating build/lib/flask_bootstrap/static/js

    copying flask_bootstrap/static/js/bootstrap.js -> build/lib/flask_bootstrap/static/js

    copying flask_bootstrap/static/js/bootstrap.min.js -> build/lib/flask_bootstrap/static/js

    copying flask_bootstrap/static/js/npm.js -> build/lib/flask_bootstrap/static/js

    creating build/lib/flask_bootstrap/templates

    creating build/lib/flask_bootstrap/templates/bootstrap

    copying flask_bootstrap/templates/bootstrap/base.html -> build/lib/flask_bootstrap/templates/bootstrap

    copying flask_bootstrap/templates/bootstrap/fixes.html -> build/lib/flask_bootstrap/templates/bootstrap

    copying flask_bootstrap/templates/bootstrap/google.html -> build/lib/flask_bootstrap/templates/bootstrap

    copying flask_bootstrap/templates/bootstrap/pagination.html -> build/lib/flask_bootstrap/templates/bootstrap

    copying flask_bootstrap/templates/bootstrap/utils.html -> build/lib/flask_bootstrap/templates/bootstrap

    copying flask_bootstrap/templates/bootstrap/wtf.html -> build/lib/flask_bootstrap/templates/bootstrap

    running install_lib

    creating /lib/python2.7/site-packages/flask_bootstrap

    error: could not create '/lib/python2.7/site-packages/flask_bootstrap': Permission denied

    ----------------------------------------
    Command "/usr/local/opt/python/bin/python2.7 -c "import setuptools, tokenize;__file__='/var/folders/rx/j0sk_6vs0dg59w3q4rm_wmwc0000gn/T/pip-build-wFK2ha/flask-bootstrap/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/rx/j0sk_6vs0dg59w3q4rm_wmwc0000gn/T/pip-UnbbND-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /var/folders/rx/j0sk_6vs0dg59w3q4rm_wmwc0000gn/T/pip-build-wFK2ha/flask-bootstrap

The problem here is that pip is not being installed in venv/bin. My question is - is this normal? Am I supposed to install pip on my own? If so, how would I do it so that when I run something like pip install mypackage, mypackage is installed in venv?

I'm trying to keep everything in 2.7 by the way. keithy is my computer username.

Keith Yong
  • 1,474
  • 1
  • 15
  • 20
  • I'm also curious why you're creating your venv as `sudo`. I don't think tthat this is causing your issue, but it could potentially cause other issues. – Deacon May 18 '15 at 13:03
  • Have you tried to install anything in the virtual environment (using `pip` while it's `activate`d)? What happened? – jonrsharpe May 18 '15 at 13:07
  • 1
    Not overwriting existing python script venv/bin/python (you must use venv/bin/python2.7) Please make sure you remove any previous custom paths from your /Users/keithy/.pydistutils.cfg file. <--- these look suspicious. – James Mills May 18 '15 at 13:10
  • I'm using `sudo virtualenv` because `easy_install` doesn't work unless it's sudo'ed. I get this error `[Errno 13] Permission denied: '/lib/python2.7/site-packages/test-easy-install-31475.write-test'` when I do `easy_install` - I don't have write permission to site packages. – Keith Yong May 18 '15 at 13:11
  • @jonrsharpe [here is the pastebin log of me running `pip install flask-bootstrap`](http://pastebin.com/raw.php?i=NqDTR3Qr) – Keith Yong May 18 '15 at 13:13
  • 1
    doesn't virtualenv get installed using existing python lib's instead of installing duplicates. essentially if it's already there use that? there is a flag to turn this off right? I'm not sure this would apply to PIP itself though? – PythonIsGreat May 18 '15 at 13:15

2 Answers2

3

I solved it by removing $HOME/.pydistutils.cfg.

Yihe
  • 4,094
  • 2
  • 19
  • 21
  • 2
    After four hours of frustration, I finally found and tried this out- and it worked! I put a [detailed writeup in this SO answer](http://stackoverflow.com/a/39107650/4619397) with details on how to diagnose the problem. – emunsing Aug 23 '16 at 17:45
-5

I fixed it in an unconventional way: I just reinstalled OS X Yosemite from the ground up. I figured it was worth it as my various python distributions were messed up, especially since I messed around with the default Apple python distribution. I did a clean install, then brew install python and used the brew version. Everything works perfectly now. virtualenv venv now correctly installs pip to the venv folder.

Keith Yong
  • 1,474
  • 1
  • 15
  • 20