I am trying to use mlpack in python scripts. I just installed the mlpack package from source into my directory /home/glassjawed/local/ and
glassjawed#Y9Acer:~$ ls local/lib | grep mlpack
libmlpack.so
libmlpack.so.3
libmlpack.so.3.0
glassjawed#Y9Acer:~$ ls local/include/mlpack/bindings/python
get_arma_type.hpp print_defn.hpp
get_cython_type.hpp print_doc_functions.hpp
get_numpy_type_char.hpp print_doc_functions_impl.hpp
get_numpy_type.hpp print_doc.hpp
get_param.hpp print_input_processing.hpp
get_printable_param.hpp print_output_processing.hpp
get_python_type.hpp print_pyx.hpp
import_decl.hpp py_option.hpp
mlpack strip_type.hpp
print_class_defn.hpp
So mlpack is clearly installed. HOWEVER, I can't seem to run this in python because I get a module not found error.
glassjawed#Y9Acer:~$ python
Python 3.6.7 | packaged by conda-forge | (default, Nov 21 2018, 03:09:43)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>> import mlpack
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'mlpack'
Why is this happening and how can I fix this? I tried everything.
`
Related
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?
'winreg' module is not found python 3.6.7. I am not facing this problem in Python 3.4.
Is any third-party app in 'winreg' that I can use same code or how can I solve this.
jaki#jaki-notebook:~$ python3 -V
Python 3.6.7
jaki#jaki-notebook:~$ python3
Python 3.6.7 (default, Oct 22 2018, 11:32:17)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from winreg import *
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'winreg'
>>>
ModuleNotFoundError: No module named 'winreg'
It is not work on linux because this package expose functions of the Windows registry API to Python
Read this documentation on python offical website
I developed a Python package using Python 2.7 and 3.4, and now I'm trying to test it for 2.6 compatibility. So in Anaconda, I made a new conda environment for Python 2.6:
conda create -n python2.6 python=2.6.9 numpy scipy
But now, when I try to import some stuff from scipy:
$ python
Python 2.6.9 |Continuum Analytics, Inc.| (unknown, Jan 10 2014, 13:33:57)
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import scipy.sparse
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/jsleinon/anaconda/envs/python2.6/lib/python2.6/site-packages/scipy/sparse/__init__.py", line 212, in <module>
from .csr import *
File "/Users/jsleinon/anaconda/envs/python2.6/lib/python2.6/site-packages/scipy/sparse/csr.py", line 13, in <module>
from ._sparsetools import csr_tocsc, csr_tobsr, csr_count_blocks, \
ImportError: dlopen(/Users/jsleinon/anaconda/envs/python2.6/lib/python2.6/site-packages/scipy/sparse/_sparsetools.so, 2): Symbol not found: __ZNSaIcEC1Ev
Referenced from: /Users/jsleinon/anaconda/envs/python2.6/lib/python2.6/site-packages/scipy/sparse/_sparsetools.so
Expected in: dynamic lookup
Does anybody know a fix or a workaround? I'm using Mac OS X 10.9. The import works fine on 2.7 and 3.4.
I have installed python-2.7.5-5ubuntu3 and matplotlib-1.3.1-1ubuntu5 from the ubuntu 14.04 repository via apt-get. Trying to import the library in python 2.7 raises the following import error:
harold#ubuntu:~$ python
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/share/pyshared/matplotlib/__init__.py", line 157, in <module>
from matplotlib.compat import subprocess
ImportError: No module named compat
>>>
I checked the directory /usr/share/pyshared/matplotlib and, indeed, cannot find any package called compat.
Any idea what is broken on my system?
Thanks!
I have found same problem on Ubuntu 16 & 14.
Possible source of the problem is damaged instance of matplotlib. Damaged instance overlaps working instance of matplotlib.
Please try to remove broken instance of matplotlib to solve the issue.
Firstly I have looked matplotlib instances:
find / |grep matplotlib | grep __init__\.py$ |more
Secondly I have deleted this folder:
find /usr/share/pyshared/matplotlib -delete
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.