Error while installing BeautifulSoup
<p>My question here is two fold. I am trying to install BeautifulSoup, but facing the below error:</p>

<pre><code>Rahul-MacBook-Air:~ rahul$ sudo easy_install pip
Password:
Searching for pip
Best match: pip 8.1.2
Processing pip-8.1.2-py2.7.egg
pip 8.1.2 is already the active version in easy-install.pth
Installing pip script to /usr/local/bin
Installing pip2.7 script to /usr/local/bin
Installing pip2 script to /usr/local/bin

Using /Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg
Processing dependencies for pip
Finished processing dependencies for pip

Rahul-MacBook-Air:~ rahul$ pip install beautifulsoup4
Collecting beautifulsoup4
  Using cached beautifulsoup4-4.5.1-py2-none-any.whl
Installing collected packages: beautifulsoup4
Exception:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg/pip/commands/install.py", line 317, in run
    prefix=options.prefix_path,
  File "/Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg/pip/req/req_set.py", line 742, in install
    **kwargs
  File "/Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg/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-8.1.2-py2.7.egg/pip/req/req_install.py", line 1032, in move_wheel_files
    isolated=self.isolated,
  File "/Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg/pip/wheel.py", line 346, in move_wheel_files
    clobber(source, lib_dir, True)
  File "/Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg/pip/wheel.py", line 317, in clobber
    ensure_dir(destdir)
  File "/Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg/pip/utils/__init__.py", line 83, in ensure_dir
    os.makedirs(path)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/beautifulsoup4-4.5.1.dist-info'
</code></pre>

<p>Can somebody please tell me what am I doing wrong here ?</p>

<p>My next question is related to the previous one. I have installed Python 3.5.2</p>

<pre><code>&gt;&gt;&gt; print(sys.version)
3.5.2 (v3.5.2:4def2a2901a5, Jun 26 2016, 10:47:25) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]
&gt;&gt;&gt; 
</code></pre>

<p>However on the terminal it shows me a different version:</p>

<pre><code>Rahul-MacBook-Air:~ rahul$ python -V
Python 2.7.10
</code></pre>

<p>So when I try to install BeautifulSoup it starts pointing to Python 2.7 which I think is wrong. It should point to the latest Python version i.e. 3.5.2</p>

<p>Also I have Python 2.7 pre-installed at <code>/usr/bin/python</code> and Python 3.5.2 is installed at <code>/usr/local/bin/python</code>.
How do I default the Python version such that every time I open my terminal it is already pointing to Python 3.5.2</p>

<p>Thanks,
Rahul</p>

<p>You have trouble installing BeautifulSoup because the user you're running he commands under doesn't have enough  permissions to access a system directory. Try running  the command with <code>sudo</code>:</p>

<pre><code>sudo pip install beautifulsoup4
</code></pre>

<p>Next, you're saying that you've installed Python 3.5.2, but aren't showing the command you're using to run it. I'm pretty sure it's something like <code>python3</code> (in any case, <em>not</em> simply <code>python</code>), so what makes you wonder why <code>python -V</code> shows a different version number? The command <code>python</code> runs a different Python interpreter.</p>

<p>If you want to install anything for Python 3.5, you'll need <code>pip3</code>, not <code>pip</code>.</p>

<p>You can make <code>python</code> an alias (or a symbolic link) to <code>python3.5</code> and probably rename the Python 2.7 interpreter to something like <code>python2.7</code>, if it hasn't been done already.</p>

python python-2.7 python-3.x