简体   繁体   中英

Error in upgrading pip in Jupyter Notebook with a M1 chip mac

I was working on a macOS Monterey Macbook Pro with an M1 chip and trying to install some packages in Jupyter Notebook. When I was trying to install librosa I got the following error message:

Collecting librosa
Exception:
Traceback (most recent call last):
  File "/Users/tanhaikang/miniforge3/lib/python3.9/site-packages/pip/_internal/cli/base_command.py", line 143, in main
    status = self.run(options, args)
  File "/Users/tanhaikang/miniforge3/lib/python3.9/site-packages/pip/_internal/commands/install.py", line 318, in run
    resolver.resolve(requirement_set)
  File "/Users/tanhaikang/miniforge3/lib/python3.9/site-packages/pip/_internal/resolve.py", line 102, in resolve
    self._resolve_one(requirement_set, req)
  File "/Users/tanhaikang/miniforge3/lib/python3.9/site-packages/pip/_internal/resolve.py", line 256, in _resolve_one
    abstract_dist = self._get_abstract_dist_for(req_to_install)
  File "/Users/tanhaikang/miniforge3/lib/python3.9/site-packages/pip/_internal/resolve.py", line 207, in _get_abstract_dist_for
    abstract_dist = self.preparer.prepare_linked_requirement(
  File "/Users/tanhaikang/miniforge3/lib/python3.9/site-packages/pip/_internal/operations/prepare.py", line 218, in prepare_linked_requirement
    req.populate_link(finder, upgrade_allowed, require_hashes)
  File "/Users/tanhaikang/miniforge3/lib/python3.9/site-packages/pip/_internal/req/req_install.py", line 164, in populate_link
    self.link = finder.find_requirement(self, upgrade)
  File "/Users/tanhaikang/miniforge3/lib/python3.9/site-packages/pip/_internal/index.py", line 572, in find_requirement
    all_candidates = self.find_all_candidates(req.name)
  File "/Users/tanhaikang/miniforge3/lib/python3.9/site-packages/pip/_internal/index.py", line 530, in find_all_candidates
    for page in self._get_pages(url_locations, project_name):
  File "/Users/tanhaikang/miniforge3/lib/python3.9/site-packages/pip/_internal/index.py", line 675, in _get_pages
    page = self._get_page(location)
  File "/Users/tanhaikang/miniforge3/lib/python3.9/site-packages/pip/_internal/index.py", line 793, in _get_page
    return _get_html_page(link, session=self.session)
  File "/Users/tanhaikang/miniforge3/lib/python3.9/site-packages/pip/_internal/index.py", line 127, in _get_html_page
    resp = session.get(
  File "/Users/tanhaikang/miniforge3/lib/python3.9/site-packages/pip/_vendor/requests/sessions.py", line 525, in get
    return self.request('GET', url, **kwargs)
  File "/Users/tanhaikang/miniforge3/lib/python3.9/site-packages/pip/_internal/download.py", line 396, in request
    return super(PipSession, self).request(method, url, *args, **kwargs)
  File "/Users/tanhaikang/miniforge3/lib/python3.9/site-packages/pip/_vendor/requests/sessions.py", line 512, in request
    resp = self.send(prep, **send_kwargs)
  File "/Users/tanhaikang/miniforge3/lib/python3.9/site-packages/pip/_vendor/requests/sessions.py", line 622, in send
    r = adapter.send(request, **kwargs)
  File "/Users/tanhaikang/miniforge3/lib/python3.9/site-packages/pip/_vendor/cachecontrol/adapter.py", line 53, in send
    resp = super(CacheControlAdapter, self).send(request, **kw)
  File "/Users/tanhaikang/miniforge3/lib/python3.9/site-packages/pip/_vendor/requests/adapters.py", line 435, in send
    resp = conn.urlopen(
  File "/Users/tanhaikang/miniforge3/lib/python3.9/site-packages/pip/_vendor/urllib3/connectionpool.py", line 597, in urlopen
    httplib_response = self._make_request(conn, method, url,
  File "/Users/tanhaikang/miniforge3/lib/python3.9/site-packages/pip/_vendor/urllib3/connectionpool.py", line 343, in _make_request
    self._validate_conn(conn)
  File "/Users/tanhaikang/miniforge3/lib/python3.9/site-packages/pip/_vendor/urllib3/connectionpool.py", line 849, in _validate_conn
    conn.connect()
  File "/Users/tanhaikang/miniforge3/lib/python3.9/site-packages/pip/_vendor/urllib3/connection.py", line 342, in connect
    self.ssl_context = create_urllib3_context(
  File "/Users/tanhaikang/miniforge3/lib/python3.9/site-packages/pip/_vendor/urllib3/util/ssl_.py", line 297, in create_urllib3_context
    context.verify_mode = cert_reqs
  File "/Users/tanhaikang/miniforge3/lib/python3.9/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.py", line 401, in verify_mode
    self._ctx.set_verify(
  File "/Users/tanhaikang/miniforge3/lib/python3.9/site-packages/OpenSSL/SSL.py", line 1084, in set_verify
    self._verify_helper = _VerifyHelper(callback)
  File "/Users/tanhaikang/miniforge3/lib/python3.9/site-packages/OpenSSL/SSL.py", line 357, in __init__
    self.callback = _ffi.callback(
MemoryError: Cannot allocate write+execute memory for ffi.callback(). You might be running on a system that prevents this. For more information, see https://cffi.readthedocs.io/en/latest/using.html#callbacks

The code I used to install librosa is simple like this:

pip install librosa

Is this a system-specific thing related to M1 chip? If so, is there way to fix it?

This is my first time to ask in the forum so please let me know if I missed something. Any help is appreciated!

how many packages are already installed in that venv? (what is the output of pip freeze ?)

I had the same error (with a different package though) and got rid of it by making a new virtual environment.

Edit: I hope you already fixed this problem way earlier:)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM