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 trialJames White
6,159 PointsError installing virtualenv as --user
When I run
pip3 install --user virtualenv
I get the error:
~/python-projects pip3 install --user virtualenv [45/53]
Collecting virtualenv
Downloading virtualenv-12.1.1-py2.py3-none-any.whl (1.6MB)
100% |████████████████████████████████| 1.6MB 262kB/s
Installing collected packages: virtualenv
Exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.4/site-packages/pip-6.1.1- py3.4.egg/pip/basecommand.py", line 246, in main
status = self.run(options, args)
File "/usr/local/lib/python3.4/site-packages/pip-6.1.1- py3.4.egg/pip/commands/install.py", line 352, in run
root=options.root_path,
File "/usr/local/lib/python3.4/site-packages/pip-6.1.1- py3.4.egg/pip/req/req_set.py", line 693, in install
**kwargs
File "/usr/local/lib/python3.4/site-packages/pip-6.1.1- py3.4.egg/pip/req/req_install.py", line 817, in install
self.move_wheel_files(self.source_dir, root=root)
File "/usr/local/lib/python3.4/site-packages/pip-6.1.1- py3.4.egg/pip/req/req_install.py", line 1018, in move_wheel_files
isolated=self.isolated,
File "/usr/local/lib/python3.4/site-packages/pip-6.1.1-py3.4.egg/pip/wheel.py", line 138, in move_wheel_files
name, user=user, home=home, root=root, isolated=isolated
File "/usr/local/lib/python3.4/site-packages/pip-6.1.1-py3.4.egg/pip/locations.py", line 236, in distutils_scheme
i.finalize_options()
File "/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/distutils/command/install.py", line 251, in finalize_options
raise DistutilsOptionError("can't combine user with prefix, "
distutils.errors.DistutilsOptionError: can't combine user with prefix, exec_prefix/home, or install_(plat)base
When I run pip3 install virtualenv. I get no errors. Any reason not to go this route?
6 Answers
Kenneth Love
Treehouse Guest TeacherI'm assuming that homebrew's Python 3 has a set prefix, an alternate place to install libraries (probably inside of Cellar
). That's conflicting with --user
, as you can see from the error message.
Python 3.3+ has a nice venv
package already available that you could just use in the same way as virtualenv
. You'd do python -m venv my_venv
where my_venv
is the name of the virtualenv you want to create. You do the activating step the exact same way.
James White
6,159 PointsI just installed Python3 using Homebrew. The most recent version is 3.4. So should I just be using pyenv-3.4 instead of virtualenv?
James White
6,159 PointsI kinda did what you suggested but I'm using python 3.4. And I had to use pyenv-3.5 to create then activated the same way.
Kenneth Love
Treehouse Guest TeacherWhy did you have to use pyenv-3.5? Python 3.4 definitely has the venv
module and it works with exactly the command I gave before.
James White
6,159 PointsWell, I was following this (https://robinwinslow.co.uk/2013/12/26/python-3-4-virtual-environment/) before I got your answer. I didn't have to install it though, I guess it came with Python3.
James White
6,159 PointsAnd python -m venv my_env creates the same directory structure as pyenv-3.4 including the pyvenv.cfg file.
Kenneth Love
Treehouse Guest TeacherOK. I just haven't come across the pyenv
command for creating virtualenvs before, I guess.
I mean, I use pyenv to have more than one Python installed but that's about it.
James White
6,159 PointsI also mistyped the name of the command earlier. :(
I didn't use pyenv. I used pyvenv-3.4.