Jupyter install fails on Mac

2024/9/7 19:41:36

I'm trying to install Jupyter on my Mac (OS X El Capitan) and I'm getting an error in response to:

sudo pip install -U jupyter

At first the download/install starts fine, but then I run into this:

Installing collected packages: six, singledispatch, certifi, backports-abc, tornado, jupyter-core, pyzmq, jupyter-client, functools32, jsonschema, nbformat, pygments, mistune, MarkupSafe, jinja2, nbconvert, path.py, pickleshare, simplegeneric, setuptools, gnureadline, appnope, ptyprocess, pexpect, ipython, ipykernel, terminado, notebook, ipywidgets, jupyter-console, qtconsole, jupyterFound existing installation: six 1.4.1DEPRECATION: Uninstalling a distutils installed project (six) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.Uninstalling six-1.4.1:
Exception:
Traceback (most recent call last):File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 209, in mainstatus = self.run(options, args)File "/Library/Python/2.7/site-packages/pip/commands/install.py", line 317, in runprefix=options.prefix_path,File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 726, in installrequirement.uninstall(auto_confirm=True)File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 746, in uninstallpaths_to_remove.remove(auto_confirm)File "/Library/Python/2.7/site-packages/pip/req/req_uninstall.py", line 115, in removerenames(path, new_path)File "/Library/Python/2.7/site-packages/pip/utils/__init__.py", line 267, in renamesshutil.move(old, new)File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 302, in movecopy2(src, real_dst)File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 131, in copy2copystat(src, dst)File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 103, in copystatos.chflags(dst, st.st_flags)
OSError: [Errno 1] Operation not permitted: '/tmp/pip-ByX5xW-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info'

What can I do to fix this?

Answer

The default OS X Python that El Capitan ships with is unfortunately rather badly mispackaged (grrr, Apple). Not only have they shipped some rather strange 3rd party packages already installed, but strange (old) and beta versions of those packages. Furthermore, they are heavily system protected.

This makes the default python rather unfriendly to do work with (as you have found out). In your specific case, juypter would like to install a recent version of the six library, but the system installed version is a strange old one and will not let pip update it (jupyter requires an updated version).

In general, to alleviate all future headaches, I recommend getting a different distribution of python, and putting that on your path so it is your new default. There are a couple of choices; what's important is only using one at a time (otherwise they're apt to confuse eachother, or confuse you).

  1. Python.org - From the Python developers themselves
  2. Homebrew - a unixy package manager for OS X, which has a normally-functioning python package
  3. Anaconda Python - A scientific python distribution, with many 'harder-to-install' scientific packages already available and 'just working' (including jupyter).

I recommend going with Anaconda for now, if you don't know what to choose.

https://en.xdnf.cn/q/73037.html

Related Q&A

Python Error Codes are upshifted

Consider a python script error.pyimport sys sys.exit(3)Invokingpython error.py; echo $?yields the expected "3". However, consider runner.pyimport os result = os.system("python error.py&…

Running dozens of Scrapy spiders in a controlled manner

Im trying to build a system to run a few dozen Scrapy spiders, save the results to S3, and let me know when it finishes. There are several similar questions on StackOverflow (e.g. this one and this oth…

How to merge two DataFrame columns and apply pandas.to_datetime to it?

Im learning to use pandas, to use it for some data analysis. The data is supplied as a csv file, with several columns, of which i only need to use 4 (date, time, o, c). Ill like to create a new DataFr…

Breaking a parent function from within a child function (PHP Preferrably)

I was challenged how to break or end execution of a parent function without modifying the code of the parent, using PHPI cannot figure out any solution, other than die(); in the child, which would end …

Get absolute path of caller file

Say I have two files in different directories: 1.py (say, in C:/FIRST_FOLDER/1.py) and 2.py (say, in C:/SECOND_FOLDER/2.py).The file 1.py imports 2.py (using sys.path.insert(0, #path_of_2.py) followed,…

Pandas dataframe to excel gives file is not UTF-8 encoded

Im working on lists that I want to export into an Excel file.I found a lot of people advising to use pandas.dataframe so thats what I did. I could create the dataframe but when I try to export it to Ex…

Finding complex roots from set of non-linear equations in python

I have been testing an algorithm that has been published in literature that involves solving a set of m non-linear equations in both Matlab and Python. The set of non-linear equations involves input v…

Python on Raspberry Pi user input inside infinite loop misses inputs when hit with many

I have a very basic parrot script written in Python that simply prompts for a user input and prints it back inside an infinite loop. The Raspberry Pi has a USB barcode scanner attached for the input.wh…

How to append two bytes in python?

Say you have b\x04 and b\x00 how can you combine them as b\x0400?

Pythonic way to write a function which modifies a list?

In python function arguments are passed by object reference. This means the simplest code to modify a list will modify the object itself.a = [1,2,3]def remove_one(b):b.remove(1)remove_one(a) print(a)T…