cvxopt errors out when multiplying a scalar to a matrix - python

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.
>>> from cvxopt import matrix
>>> 2 * matrix(1.0, (1, 4))
Intel MKL FATAL ERROR: Cannot load libmkl_avx.so or libmkl_def.so
When running the above scripts I get an Intel MKL Fatal Error. The test that is mentioned in issues with similar error passed. The test is
python -c 'import sklearn.linear_model.tests.test_randomized_l1'
I ran python with LD_DEBUG=symbols and see the below error in the logs
/opt/anaconda3/lib/python3.5/site-packages/cvxopt/../../../libmkl_avx.so: error: symbol lookup error: undefined symbol: mkl_sparse_optimize_bsr_trsm_i8 (fatal)
Does anyone know how to fix this? I am interested in retaining the mkl option and not the nomkl one
NOTE mkl is installed and at newest version and so is scikit-learn

I ran into this while running the examples on http://scikit-learn.org/stable/modules/linear_model.html. Apparently a bunch of libraries are not being loaded automatically. Here are the manual loads I'm using so far, others will probably be needed depending on what you are doing. For me it did fix the one test case in the question.
CONDA_LIB=$CONDA_PREFIX/../../lib
LIBS=$CONDA_LIB/libmkl_intel_thread.so:$CONDA_LIB/libmkl_avx.so:$CONDA_LIB/libmkl_core.so:$CONDA_LIB/libiomp5.so:/lib/libgomp.so
LD_PRELOAD=$LIBS python

The mkl package is probably missing in your anaconda installation.
a) You could try to upgrade anaconda completely:
conda upgrade anaconda
b) Alternatively you could explicitly install mkl:
conda install mkl
I have not checked a), but used b). In this case you might need to upgrade also sklearn module:
conda upgrade scikit-learn

Related

altair python package gives "Illegal instruction" on Raspberry PI

In my RaspberryPI ZERO W I got strange error when trying to import altair module in python script.
pi#raspberrypi:~ $ python3
Python 3.7.3 (default, Jul 25 2020, 13:03:44)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import altair
Illegal instruction
pi#raspberrypi:~ $ pip3 freeze
altair==4.2.0
Does anybody have an idea if there is a version, which works on RaspberryPi? Or any other idea why it is happening?
Illegal Instruction means that you are importing a C extension that is compiled incorrectly for the system you are using. Altair itself doesn't have any C extensions, but it depends on a number of libraries that do include C extensions, which you can see in its requirements.txt file:
entrypoints
jinja2
jsonschema>=3.0
numpy
pandas>=0.18
toolz
I would suggest trying to import each of these libraries to narrow-down which package is incorrectly installed, and then search for information on how to correctly install the problematic package on RaspberryPi ZERO.

libtorch and pytorch cannot be installed simultaneously?

I am learning to develop with PyTorch as well as LibTorch. I have the following line in my ~/.bashrc for dynamic linking of libtorch libraries:
# libtorch linking path
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/user/.dev_libraries/libtorch/lib/
However, when this path is in LD_LIBRARY_PATH, importing torch in Python reports segmentation fault:
user#host:~$ $LD_LIBRARY_PATH
bash: /home/user/packages/embree-2.16.0.x86_64.linux/lib:/home/user/packages/embree-2.16.0.x86_64.linux/lib::/usr/local/lib/:/usr/local/cuda-11.1/lib64:/usr/local/lib/:/usr/local/cuda-11.1/lib64:/home/user/.dev_libraries/libtorch-cpu/libtorch/lib/: No such file or directory
user#host:~$ python
Python 3.8.10 (default, Jun 2 2021, 10:49:15)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
Segmentation fault (core dumped)
user#host:~$
As soon as I remove that path from the environment variable LD_LIBRARY_PATH, torch can be correctly imported in Python.
I am guessing the cause is that some shared libraries of PyTorch having the same names as the ones in LibTorch. Does this mean PyTorch and LibTorch cannot be installed simultaneously, or is my environment setting incorrect? I'd prefer not to reset LD_LIBRARY_PATH every time I switch between the two.
System specs:
Ubuntu 20.04 + CUDA 11.1 + python 3.8.10 + GCC 9.3.0
pytorch 1.9.0+cu111
libtorch is downloaded from here: https://download.pytorch.org/libtorch/nightly/cpu/libtorch-shared-with-deps-latest.zip
I faced the same problem too.
You can type
import torch
print(torch.__version__)
to see the version of torch, and use the same version of libtorch, that would solve the problem probably.

Conda install package ModuleNotFoundError: No module named 'conda'

I installed Conda using the scripts from bootstrap-conda.sh and install-conda-env.sh
Conda was installed successfully. When I install the first package,
e.g., conda install --yes lxml=4.3.0
it worked fine. The log can be found here. But when I tried to install the second package,
e.g., 'conda install --yes numpy=1.15.4'
it throws this error:
Traceback (most recent call last):
File "/opt/conda/default/bin/conda", line 12, in <module>
from conda.cli import main
ModuleNotFoundError: No module named 'conda'
Tried every possible solution I could find, it did not help.
Before package installation, when I type python, it takes me to Python 3.6.7
Python 3.6.7 | packaged by conda-forge | (default, Feb 28 2019, 09:07:38)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
python default import path:
/opt/conda/default/lib/python36.zip
/opt/conda/default/lib/python3.6
/opt/conda/default/lib/python3.6/lib-dynload
/opt/conda/default/lib/python3.6/site-packages
/usr/lib/spark/python
After package installation, when I type python, it takes me to Python 3.7.3
Python 3.7.3 (default, Mar 27 2019, 22:11:17)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
python default import path:
/opt/conda/default/lib/python37.zip
/opt/conda/default/lib/python3.7
/opt/conda/default/lib/python3.7/lib-dynload
/opt/conda/default/lib/python3.7/site-packages
I re-installed Conda. The same problem still persists.
Conda Version:
conda --version
conda 4.6.14
When I install the first package, the following log caught my attention. It upgraded python from 3.6 to 3.7. I am not sure if this is what causes the problem.
The following packages will be UPDATED:
certifi conda-forge::certifi-2019.3.9-py36_0 --> pkgs/main::certifi-2019.6.16-py37_0
libedit 3.1.20170329-h6b74fdf_2 --> 3.1.20181209-hc058e9b_0
ncurses 6.1-hf484d3e_0 --> 6.1-he6710b0_1
openssl conda-forge::openssl-1.1.1b-h14c3975_1 --> pkgs/main::openssl-1.1.1c-h7b6447c_1
pip 10.0.1-py36_0 --> 19.1.1-py37_0
python conda-forge::python-3.6.7-h381d211_10~ --> pkgs/main::python-3.7.3-h0371630_0
readline 7.0-ha6073c6_4 --> 7.0-h7b6447c_5
setuptools 39.2.0-py36_0 --> 41.0.1-py37_0
wheel 0.31.1-py36_0 --> 0.33.4-py37_0
zlib 1.2.11-ha838bed_2 --> 1.2.11-h7b6447c_3
You should create a dedicated environment for your lxml and numpy. That will keep the prerequisites for conda and for your code separate, which brings benefits in the long run.
About two weeks ago, conda started to aggressively update Python, and probably other packages too. You can try to prevent that by passing python=3.6 with every install command, or by pinning the Python version. This answer might help:
https://stackoverflow.com/a/48733093/5629418
Like you assumed, upgrading Python version is what making you an issue. If you try to downgrade it, the same thing can happen in some cases. This means that Conda will be broken if you do not explicitly say to keep existing Python version (not always, but in some cases). In your case you should do following:
conda install --yes lxml=4.3.0 python=3.6.7
conda install --yes numpy=1.15.4 python=3.6.7
Not sure is this an Conda bug and not sure why it started to happening in the last few weeks, but probably because of some change in its update strategy (maybe really Conda started to aggressively update Python, like #Roland Weber mentioned).

Importing python module in R

I am trying to import a python module in R using the reticulate package. The module can be found here. I cloned the repository and ran python setup.py install which ran successfully. If I open a python shell, I'm able to import debot. However, when I try to import it in RStudio, I get the following error:
dbot=import("debot")
Error in py_module_import(module, convert = convert) :
ImportError: No module named debot
I am on macOS Sierra version 10.12.6 and installed python 3.6 through Anaconda. I have also tried giving the path to python as:
path_to_python <- "/anaconda/bin/python3.6"
use_python(path_to_python)
When I run python from a terminal, I get:
Python 3.6.1 |Anaconda 4.4.0 (x86_64)| (default, May 11 2017, 13:04:09)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Not sure if the path to python is correct.
Ok, did some more digging around and discovered that reticulate still refers to my older python path for python 2.7 which came as default with my Macbook. When I run py_config(), this is what I get:
python: /usr/bin/python
libpython: /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config/libpython2.7.dylib
pythonhome: /System/Library/Frameworks/Python.framework/Versions/2.7:/System/Library/Frameworks/Python.framework/Versions/2.7
version: 2.7.10 (default, Feb 7 2017, 00:08:15) [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)]
No matter what I try but I can't get reticulate to look at the correct path where the module has been installed using the use_python() function. I do believe this is an issue with reticulate. Any ideas what my next steps should be?
After reading this I finally figured out. I think before calling any other function from the reticulate package, it is imperative to specify the path to python to use. Hence the order I am following now is:
library(reticulate)
path_to_python <- "/anaconda/bin/python"
use_python(path_to_python)

No module named igraph - Error

I am using anaconda on mac-osx and have installed python-igraph. Currently not being able to import igraph.
Below is the error shown:
Python 2.7.12 |Anaconda 4.1.1 (x86_64)|
import igraph ----
ImportError: No module named igraph
It is present in this path - /Users/pc_name/anaconda/lib/python2.7/site-packages and I find only python_igraph-0.7.1.post6-py2.7.egg-info file.
I tried many things possible which are available on the other questions here at stack overflow. How can I solve this problem?
I used the following command and it worked for me in Python 3.7
pip install python-igraph
The detail about the package and its installation can be found
https://igraph.org/python/
You haven't mentioned how you installed python-igraph so it's hard to say anything. But I'm pretty sure that this package works nicely.
1)While in the python-igraph-master directory on my computer run the following:
conda install -c marufr python-igraph
2)In a new terminal window kick start python:
$python
Python 2.7.13 |Anaconda 4.3.1 (x86_64)| (default, Dec 20 2016, 23:05:08)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import igraph
>>>
I hope this helps

Categories

Resources