I'm trying to import modules ending in cpython-39-darwin.so and python doesn't recognize them. When I remove cpython-39-darwin and just leave .so, my program can recognize them, but then it raises an error about 'incompatible architecture'. I noticed this issue when trying to import open3d, but it's happening with other libraries too.
I have a new MacBook (M1 Pro) and I'm wondering if this has anything to do with the issue.
import open3d
ModuleNotFoundError Traceback (most recent call last)
Input In [26], in <cell line: 1>()
----> 1 import open3d
File ~/opt/anaconda3/lib/python3.9/site-packages/open3d/init.py:90, in <module>
84 warnings.warn(
85 "Open3D was built with CUDA support, but Open3D CUDA Python "
86 "binding library not found! Falling back to the CPU Python "
87 "binding library.", ImportWarning)
89 ifDEVICE_API == 'cpu':
---> 90 from open3d.cpu.pybind import (camera, data, geometry, io, pipelines,
91 utility, t)
92 from open3d.cpu import pybind
94 import open3d.core
ModuleNotFoundError: No module named 'open3d.cpu.pybind'
The file itself is in /open3d/cpu/pybind.cpython-39-darwin.so. When I change it to /open3d/cpu/pybind.so, it recognizes the file, but now I get the following error:
ImportError
...
(mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/local/lib/pybind.so' (no such file), '/usr/lib/pybind.so' (no such file)
Related
I am writing a workflow in Jupyter that uses some C code which has already been compiled to a .so file (for Linux, where everything works fine) and a .pyd file (for Windows, which I am using). The import tree is a little complicated, so bear with me. The error message hopefully explains it:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-9-cabd8b5ab266> in <module>
12 import plotly.graph_objects as go
13
---> 14 from lase_analysis import load_lasefile, load_timeseries
C:/Users/Owner/.../v2\lase_analysis\__init__.py in <module>
2 from .spectrum import Spectrum
3 from .threshold import Threshold
----> 4 from .lasemap import LaseMap
5 from .laseseries import LaseSeries
6 from .readermatl import ReaderMATL
C:/Users/Owner/.../v2\lase_analysis\lasemap.py in <module>
14 from .filelase import FileLase
15 from .spectrum import Spectrum, PeakFitOpt
---> 16 from .utils.c_funcs import clst_dist
17
18
ImportError: DLL load failed while importing c_funcs: The specified module could not be found.
Basically, in the Jupyter session, I am importing __init__.py from the folder lase_analysis (the first arrow in the error message), which imports a class LaseMap from the file lasemap.py. Then, this lasemap.py file tries to open a C function clst_dist from the file c_funcs.pyd, which is located in a folder called utils which is in this same folder lase_analysis that all of the previously mentioned Python files are located in. However, I still get the error that the .dll file (which should be equivalent to a .pyd file here) cannot be found.
Any help would be appreciated, and my apologies if this was a bit hard to follow.
I have Anaconda3. When I use its interpreter from Pycharm or directly from the folder to import numpy I get the following error:
ImportError Traceback (most recent call last)
~\Anaconda\lib\site-packages\numpy\core\__init__.py in <module>
16 try:
---> 17 from . import multiarray
18 except ImportError as exc:
~\Anaconda\lib\site-packages\numpy\core\multiarray.py in <module>
13
---> 14 from . import overrides
15 from . import _multiarray_umath
~\Anaconda\lib\site-packages\numpy\core\overrides.py in <module>
6
----> 7 from numpy.core._multiarray_umath import (
8 add_docstring, implement_array_function, _get_implementing_args)
ImportError: DLL load failed: The specified module could not be found.
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
<ipython-input-1-d4cdadb62aa7> in <module>
----> 1 import numpy
~\Anaconda\lib\site-packages\numpy\__init__.py in <module>
140 from . import _distributor_init
141
--> 142 from . import core
143 from .core import *
144 from . import compat
~\Anaconda\lib\site-packages\numpy\core\__init__.py in <module>
45 """ % (sys.version_info[0], sys.version_info[1], sys.executable,
46 __version__, exc)
---> 47 raise ImportError(msg)
48 finally:
49 for envkey in env_added:
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.7 from "C:\Users\noamw\Anaconda\python.exe",
and that you have no directories in your PATH or PYTHONPATH that can
interfere with the Python and numpy version "1.17.4" 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: DLL load failed: The specified module could not be found.
However, when I use it from ipython after activating my environment, using conda, it works just fine. It's really frustrating that I can't create a Pycharm project like this.
Would really appreciate any help
Thanks
Setting your environment as the interpreter for PyCharm should work. Got to Preferences --> Project --> Project Interpreter. In the drop down menu select your conda environment. Set it to something like: ~/Anaconda3/envs/myenvname/bin/python
It is a bummer that Pycharm has not looked into this issue and has not come up with a solution for it.
Most solutions I found suggest removing numpy and reinstalling it using pip install numpy, which basically defeats the purpose of having a conda environment and getting its benefits like conda revisions; not to mention the bad practice of using both pip and conda in the same environment.
Until Pycharm gets to the bottom of this, you can get around this issue following this:
Activate your environment in command prompt.
Use set command to print all environment variables.
Copy the PATH environment variable.
Add it to the environment variables of your Run/Debug configurations.
While trying to import scipy, I'm getting the following error :
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-7-4dc45f4c0083> in <module>()
----> 1 import scipy
C:\Users\admin\Anaconda2\lib\site-packages\scipy\__init__.py in <module>()
74
75 # Allow distributors to run custom init code
---> 76 from . import _distributor_init
77
78 __all__ += _num.__all__
ImportError: cannot import name _distributor_init
I have tried re-installing from pip by force reinstall, it says that scipy is up-to-date but then, loading it gives the above error. How do I resolve it? I'm using Python 2.x version.
I was getting the same error while using cx_freeze, i managed to make it work by simply commenting this line in the init.py of scipy (---> 76 from . import _distributor_init).
From what i read there: [Numpy-discussion] Hook in init.py to let distributors patch numpy
it simply enables more customization of checks, that i didn't need.
Scipy seems to work just fine without it.
Fyi I installed scipy without using anaconda, and i use python 3.6.
Hope this helps.
I use cx_Freeze and package have this error. I add this code to solve this problem:
self.build_exe_options = {
'includes': "scipy._distributor_init"
}
just upgrade your sklearn, upgrade everything and u will be fine
I am having trouble importing tika in a python file. I have spent a lot of time googling and been unable to find anything. Here is the iPython command: import tika, and subsequent stack trace.
It occurs to me that there could be a problem with a module on which tika is dependent, such as requests, or urllib3. However, when I try to install those with pip, it says requirement already satisfied. I have also double checked the PYTHONHOME director, and I'm 99% sure it's correct.
$ ipython
Python 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 17:54:52) [MSC v.1900 32 bit (Intel)]
Type "copyright", "credits" or "license" for more information.
IPython 4.2.1 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
WARNING: Readline services not available or not loaded.
WARNING: Proper color support under MS Windows requires the pyreadline library.
You can find it at:
http://ipython.org/pyreadline.html
Defaulting color scheme to 'NoColor'
In [1]: import tika
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
C:\cygwin64\lib\python3.6\site-packages\requests\packages\__init__.py in <module>()
26 try:
---> 27 from . import urllib3
28 except ImportError:
ImportError: cannot import name 'urllib3'
During handling of the above exception, another exception occurred:
ValueError Traceback (most recent call last)
<ipython-input-1-9f3de0ba3e70> in <module>()
----> 1 import tika
C:\cygwin64\lib\python3.6\site-packages\tika\tika.py in <module>()
18
19 try:
---> 20 __import__('pkg_resources').declare_namespace(__name__)
21 except ImportError:
22 from pkgutil import extend_path
C:\cygwin64\lib\python3.6\site-packages\pkg_resources\__init__.py in declare_namespace(packageName)
2161 # Ensure all the parent's path items are reflected in the child,
2162 # if they apply
-> 2163 _handle_ns(packageName, path_item)
2164
2165 finally:
C:\cygwin64\lib\python3.6\site-packages\pkg_resources\__init__.py in _handle_ns(packageName, path_item)
2096 path = module.__path__
2097 path.append(subpath)
-> 2098 loader.load_module(packageName)
2099 _rebuild_mod_path(path, packageName, module)
2100 return subpath
C:\cygwin64\lib\python3.6\site-packages\tika\tika.py in <module>()
89 open = codecs.open
90
---> 91 import requests
92 import socket
93 import tempfile
C:\cygwin64\lib\python3.6\site-packages\requests\__init__.py in <module>()
50 # Attempt to enable urllib3's SNI support, if possible
51 try:
---> 52 from .packages.urllib3.contrib import pyopenssl
53 pyopenssl.inject_into_urllib3()
54 except ImportError:
C:\cygwin64\lib\python3.6\site-packages\requests\packages\__init__.py in <module>()
27 from . import urllib3
28 except ImportError:
---> 29 import urllib3
30 sys.modules['%s.urllib3' % __name__] = urllib3
31
C:\cygwin64\lib\python3.6\site-packages\urllib3\__init__.py in <module>()
6 import warnings
7
----> 8 from .connectionpool import (
9 HTTPConnectionPool,
10 HTTPSConnectionPool,
C:\cygwin64\lib\python3.6\site-packages\urllib3\connectionpool.py in <module>()
9
10
---> 11 from .exceptions import (
12 ClosedPoolError,
13 ProtocolError,
C:\cygwin64\lib\python3.6\site-packages\urllib3\exceptions.py in <module>()
1 from __future__ import absolute_import
----> 2 from .packages.six.moves.http_client import (
3 IncompleteRead as httplib_IncompleteRead
4 )
5 # Base Exceptions
ValueError: source code string cannot contain null bytes
In case anyone else is looking at this, here is how I finally solved my issue.
I had been mistakenly assuming that the python-tika module was a fully packaged, ready to run version of tika. In fact, you need to download the java tika server from Apache, and it must be running when you use python-tika (you can easily just run the server on localhost).
The Python-tika module then allows you to make requests to this server from your python code. I probably should have known this but for some reason I didn't pick it up in the documentation.
Are you sure you have that module installed?
If not, just go to the Command Prompt and type pip install tika
I think here is a good approach for installing tika on the Windows:
First, install java SE from this link:
https://www.oracle.com/ca-en/java/technologies/javase-downloads.html
Second, install a specific version of tika:
pip install tika==1.23
Third, download and run the tika server and tika app files from apache:
https://archive.apache.org/dist/tika/tika-server-1.23.jar
https://archive.apache.org/dist/tika/tika-app-1.23.jar
it should be fine, and you should be able to run tika in your application.
I am trying to install a python module called tables, which depends on HDF5. I have installed HDF5 using pkgsrc, so the libraries and headers are in /usr/pkg/lib and /usr/pkg/include, respectively. This is on a Mac (OS 10.9.4).
I am able to install the tables module using pip only if I first export HDF5_DIR=/usr/pkg. That's not a problem in and of itself, but after pip says it has successfully installed tables, I still can't import the module and the error message seems to indicate that it can't find a library related to HDF5. Please see the error message below. I'm guessing that the hint in the error is 2): Symbol not found: _H5E_CALLBACK_g
In [1]: import tables
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-389ecae14f10> in <module>()
----> 1 import tables
/Users/gregory/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/tables/__init__.py in <module>()
80
81 # Necessary imports to get versions stored on the cython extension
---> 82 from tables.utilsextension import (
83 get_pytables_version, get_hdf5_version, blosc_compressor_list,
84 blosc_compcode_to_compname_ as blosc_compcode_to_compname,
ImportError: dlopen(/Users/gregory/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/tables/utilsextension.so, 2): Symbol not found: _H5E_CALLBACK_g
Referenced from: /Users/gregory/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/tables/utilsextension.so
Expected in: flat namespace
in /Users/gregory/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/tables/utilsextension.so