To overcome the limitations of pickle, I switched to multiprocessing_on_dill.
This started to generate an error:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\ProgramData\Anaconda3\lib\multiprocessing\spawn.py", line 107, in spawn_main
exitcode = _main(fd)
File "C:\ProgramData\Anaconda3\lib\multiprocessing\spawn.py", line 117, in _main
self = reduction.pickle.load(from_parent)
ModuleNotFoundError: No module named '__builtin__'
Is there a way to overcome it?
Surprisingly, it still references C:\ProgramData\Anaconda3\lib\multiprocessing\.
While multiprocessing_on_dill has its own folder C:\ProgramData\Anaconda3\Lib\site-packages\multiprocessing_on_dill with the same set of files.
I'd suggest you use multiprocess instead of multiprocessing_on_dill... the former is better supported, and maintained by the dill author (me). It looks like multiprocess_on_dill is looking for __builtin__, which is where the builtin functions lived in python 2... in python 3, they are in builtins
>$ python
Python 2.7.16 (default, Apr 1 2019, 14:50:56)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import __builtin__
>>>
>$ python
Python 3.6.8 (default, Dec 30 2018, 13:04:41)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import __builtin__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named '__builtin__'
>>> import builtins
>>>
So, I think it's either you are running python 3, and using the python 2 version of the code -- or the module doesn't fully support python 3.
Related
The problem occurred: ImportError: libhdf5.so.101: cannot open shared object file: No such file or directory,when I install pygrib on linux(centOS6) by Anaconda
Python 3.5.2 |Anaconda custom (64-bit)| (default, Jul 2 2016, 17:53:06)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygrib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: libhdf5.so.101: cannot open shared object file: No such file or directory
>>> exit()
================================================================
[root#localhost ll]# locate libhdf5.so.101
locate: can not stat () `/var/lib/mlocate/mlocate.db': No such file or directory
Please help me,thank you!
I am trying to import socket and I get the following error:
$ python
Python 2.7.16 |Anaconda, Inc.| (default, Mar 14 2019, 16:24:02)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "socket.py", line 68, in <module>
from _ssl import \
ImportError: cannot import name RAND_egd
I thought that perhaps my Anaconda installation was corrupted so I uninstalled and reinstalled Anaconda but the error persists.
I had tried what the other posts suggested except for editing socket.py due to Macos System Integrity Protection. My guess is that the problem lies elsewhere as I doubt that everyone has had to edit the file.
How can I find the source of the problem?
Why python can't get evironment variable after export?
How to fix this?
λ: export AUTOTEST=/home/anton/eltx/scripts/gitlab/
~
λ: python
Python 2.7.12 (default, Dec 4 2017, 14:50:18)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.environ['AUTOTEST']
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/UserDict.py", line 40, in __getitem__
raise KeyError(key)
KeyError: 'AUTOTEST'
>>>
>>> os.environ.get('AUTOTEST', 'none_value')
'none_value'
>>>
I found the mistake. There was an alias for running python
On Macos, I have set DYLD_LIBRARY_PATH this way:
export DYLD_LIBRARY_PATH=/Applications/PicoScope6.app/Contents/Resources/lib
If I run those two lines in IPython, it works :
from ctypes import cdll
cdll.LoadLibrary("libps2000a.dylib")
but I run them in the standard python interpreter, I get :
$ /usr/bin/python
Python 2.7.10 (default, Feb 7 2017, 00:08:15)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from ctypes import cdll
>>> cdll.LoadLibrary("libps2000a.dylib")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 443, in LoadLibrary
return self._dlltype(name)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 365, in __init__
self._handle = _dlopen(self._name, mode)
OSError: dlopen(libps2000a.dylib, 6): image not found
EDIT1 : I think it has something to with the Python provided by Apple because with /usr/local/bin/python2 (provided by the brew utility), it works :
$ /usr/local/bin/python2
Python 2.7.13 (default, Jul 18 2017, 09:17:00)
[GCC 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.42)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from ctypes import cdll
>>> cdll.LoadLibrary("libps2000a.dylib")
<CDLL 'libps2000a.dylib', handle 7f8838d01f80 at 10b438f50>
EDIT2 : I have the same pb. with the DYLD_LIBRARY_PATH variable as with the LD_LIBRARY_PATH variable
What can I do to "tell" the "Apple Python" to "see" the DYLD_LIBRARY_PATH ?
On MacOS X it is DYLD_LIBRARY_PATH not LD_LIBRARY_PATH.
See the man page for dyld for details on environment variables you can set which affect the dynamic linker.
When I import the igraph package in my project, I get an AttributeError. This only happens in the project directory:
[12:34][~]$ python2
Python 2.7.1 (r271:86832, Apr 15 2011, 12:09:10)
[GCC 4.5.2 20110127 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import igraph
>>>
[12:34][~]$ cd projectdir/
[12:34][projectdir]$ python2
Python 2.7.1 (r271:86832, Apr 15 2011, 12:09:10)
[GCC 4.5.2 20110127 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import igraph
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/site-packages/igraph/__init__.py", line 42, in <module>
import gzip
File "/usr/lib/python2.7/gzip.py", line 36, in <module>
class GzipFile(io.BufferedIOBase):
AttributeError: 'module' object has no attribute 'BufferedIOBase'
>>>
There is no file igraph.py in the project directory:
[12:34][projectdir]$ ls -alR | grep igraph | wc -l
0
And there are no circular imports.
How can I solve this error?
Most likely, there is a module io in ~/projectdir or one of the paths the project configures. The gzip module imported by igraph starts with
import io
and expect the built-in io module, not your project's one. Look for an io directory, or io.py or io.pyc. It can also help to scrutinize sys.path for any other directories (maybe outside of ~/projectdir) that might contain modules named io.