Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

Juan Perez
PLUS
Juan Perez
Courses Plus Student 8,944 Points

Problem with Installing and Using VirtualEnv

Hello all, I don't know why this is happening because I have installed it before and worked on it before (my computer was repaired by apple). So Im trying to install virtual env and It doesn't install correctly I get some error messages. that are :

ā†’ pip install virtualenv
Collecting virtualenv
  Using cached virtualenv-15.0.1-py2.py3-none-any.whl
Installing collected packages: virtualenv
Exception:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip/commands/install.py", line 317, in run
    prefix=options.prefix_path,
  File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 742, in install
    **kwargs
  File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 831, in install
    self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
  File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 1032, in move_wheel_files
    isolated=self.isolated,
  File "/Library/Python/2.7/site-packages/pip/wheel.py", line 346, in move_wheel_files
    clobber(source, lib_dir, True)
  File "/Library/Python/2.7/site-packages/pip/wheel.py", line 324, in clobber
    shutil.copyfile(srcfile, destfile)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 83, in copyfile
    with open(dst, 'wb') as fdst:
IOError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/virtualenv.py'

When I install using sudo, It works fine, but when I create the virtualenv , go into it and install django it doesn't create the directories and files it is supposed to (django-admin.py, manage.py, ect ect...).

How can I fix this problem? How can I know what the problem really is?

5 Answers

Juan Perez
PLUS
Juan Perez
Courses Plus Student 8,944 Points

OK. I believe I got it working for py3.

I hate how I have to stay stuck with py2 on my machine. Cant I just replace it or upgrade it and not have to versions installed?

Thanks alot for your help.

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

Yeah, you're having to use sudo because that's using the system-wide Python (which, note, is 2.7, not 3.x).

Running pip install django shouldn't create manage.py or anything, it just installs Django into site-packages. Can you do django-admin.py startproject foo after you pip install django?

Juan Perez
PLUS
Juan Perez
Courses Plus Student 8,944 Points

Cant get anything to work on my side. Im actually on frustration mode.

Kenneth Love
Kenneth Love
Treehouse Guest Teacher

So, you do sudo pip install virtualenv to install the virtualenv library.

Then, wherever you're gonna build your code, virtualenv env to create a virtualenv named "env".

source env/bin/activate to turn on the virtualenv.

pip install django to install the Django library.

And, finally, django-admin.py startproject something to create a Django project named "something".

Which part of that sequence is failing for you?

Juan Perez
PLUS
Juan Perez
Courses Plus Student 8,944 Points

Kenneth Love all of them. By any chance do you think it would be because im using zsh instead of bash?