ImportError: PyCapsule_Import could not import module "datetime"
See original GitHub issueReproducing code example:
import matplotlib.pyplot as plt;
Before this happened I was running a different python script, which used 89 processes. Unfortunately I cannot share that script publicly. Since then numpy crashes after import immediately.
Error message:
OpenBLAS blas_thread_init: pthread_create failed for thread 52 of 64: Resource temporarily unavailable
OpenBLAS blas_thread_init: RLIMIT_NPROC 4096 current, 1028736 max
OpenBLAS blas_thread_init: pthread_create failed for thread 53 of 64: Resource temporarily unavailable
OpenBLAS blas_thread_init: RLIMIT_NPROC 4096 current, 1028736 max
OpenBLAS blas_thread_init: pthread_create failed for thread 54 of 64: Resource temporarily unavailable
OpenBLAS blas_thread_init: RLIMIT_NPROC 4096 current, 1028736 max
OpenBLAS blas_thread_init: pthread_create failed for thread 55 of 64: Resource temporarily unavailable
OpenBLAS blas_thread_init: RLIMIT_NPROC 4096 current, 1028736 max
OpenBLAS blas_thread_init: pthread_create failed for thread 56 of 64: Resource temporarily unavailable
OpenBLAS blas_thread_init: RLIMIT_NPROC 4096 current, 1028736 max
OpenBLAS blas_thread_init: pthread_create failed for thread 57 of 64: Resource temporarily unavailable
OpenBLAS blas_thread_init: RLIMIT_NPROC 4096 current, 1028736 max
OpenBLAS blas_thread_init: pthread_create failed for thread 58 of 64: Resource temporarily unavailable
OpenBLAS blas_thread_init: RLIMIT_NPROC 4096 current, 1028736 max
OpenBLAS blas_thread_init: pthread_create failed for thread 59 of 64: Resource temporarily unavailable
OpenBLAS blas_thread_init: RLIMIT_NPROC 4096 current, 1028736 max
OpenBLAS blas_thread_init: pthread_create failed for thread 60 of 64: Resource temporarily unavailable
OpenBLAS blas_thread_init: RLIMIT_NPROC 4096 current, 1028736 max
OpenBLAS blas_thread_init: pthread_create failed for thread 61 of 64: Resource temporarily unavailable
OpenBLAS blas_thread_init: RLIMIT_NPROC 4096 current, 1028736 max
OpenBLAS blas_thread_init: pthread_create failed for thread 62 of 64: Resource temporarily unavailable
OpenBLAS blas_thread_init: RLIMIT_NPROC 4096 current, 1028736 max
OpenBLAS blas_thread_init: pthread_create failed for thread 63 of 64: Resource temporarily unavailable
OpenBLAS blas_thread_init: RLIMIT_NPROC 4096 current, 1028736 max
Traceback (most recent call last):
File "/usr/local/lib64/python3.6/site-packages/numpy/core/__init__.py", line 17, in <module>
from . import multiarray
File "/usr/local/lib64/python3.6/site-packages/numpy/core/multiarray.py", line 14, in <module>
from . import overrides
File "/usr/local/lib64/python3.6/site-packages/numpy/core/overrides.py", line 7, in <module>
from numpy.core._multiarray_umath import (
ImportError: PyCapsule_Import could not import module "datetime"
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "temp.py", line 1, in <module>
import matplotlib.pyplot as plt;
File "/usr/local/lib64/python3.6/site-packages/matplotlib/__init__.py", line 138, in <module>
from . import cbook, rcsetup
File "/usr/local/lib64/python3.6/site-packages/matplotlib/cbook/__init__.py", line 31, in <module>
import numpy as np
File "/usr/local/lib64/python3.6/site-packages/numpy/__init__.py", line 142, in <module>
from . import core
File "/usr/local/lib64/python3.6/site-packages/numpy/core/__init__.py", line 47, in <module>
raise ImportError(msg)
ImportError:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy c-extensions failed.
- Try uninstalling and reinstalling numpy.
- If you have already done that, then:
1. Check that you expected to use Python3.6 from "/usr/bin/python3",
and that you have no directories in your PATH or PYTHONPATH that can
interfere with the Python and numpy version "1.17.2" you're trying to use.
2. If (1) looks fine, you can open a new issue at
https://github.com/numpy/numpy/issues. Please include details on:
- how you installed Python
- how you installed numpy
- your operating system
- whether or not you have multiple versions of Python installed
- if you built from source, your compiler versions and ideally a build log
- If you're working with a numpy git repository, try `git clean -xdf`
(removes all files not under version control) and rebuild numpy.
Note: this error has many possible causes, so please don't comment on
an existing issue about this - open a new one instead.
Original error was: PyCapsule_Import could not import module "datetime"
zsh: segmentation fault python3 temp.py
Numpy/Python version information:
numpy-1.7.1-13.el7.x86_64
Issue Analytics
- State:
- Created 4 years ago
- Reactions:9
- Comments:15 (9 by maintainers)
Top Results From Across the Web
Python3 numpy import error PyCapsule_Import could not ...
In my case I had this problem, because my script was called math.py , which caused module import problems. Make sure your own...
Read more >arcgis to_featurelayer() crashes kernel with ImportError ...
ImportError : PyCapsule_Import could not import module "datetime" ... import pandas as pd from arcgis.gis import GIS gis = GIS(url = url, ...
Read more >PyCall PyCapsule_Import could not import module "datetime"
I have a Python virtual environment and I'd like to install PyCall to point to the environment's Python, but I get an error...
Read more >Python3 numpy import error PyCapsule_Import could not ...
I am trying to import numpy with python3 on MacOS mojave. I am getting this error. ... Error: PyCapsule_Import could not import module...
Read more >importerror: pycapsule_import could not import module ...
This might be due to a faulty python installation where datetime is somehow broken, so making sure import datetime works would be a...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I had the same problem using Jobe - a sandbox for running code. What worked was inserting these lines in the script before importing numpy.
So yeah, looks like limiting the number of thread works.
You may be saturating your machine by running many processes. Importing numpy in each process will open a thread pool with the number of threads equal to number of CPUs, so if you have 64 cpus and open 100 processes that will be thousands of threads. You might be interested in
threadpoolctlto manage the number of threads each process opens