Trying to use the rpy2.ipython (formerly 'rmagic') extension of IPython, to get interactive R (%R line magic and %%R cell magic functions), I get the following errors...
louis ~ $ python
Python 3.5.1 |Anaconda 2.4.0 (64-bit)| (default, Dec 7 2015, 11:16:01)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import rpy2.ipython
Traceback (most recent call last):
File "/home/louis/anaconda3/lib/python3.5/site-packages/pandas/__init__.py", line 7, in <module>
from pandas import hashtable, tslib, lib
File "pandas/src/numpy.pxd", line 157, in init pandas.hashtable (pandas/hashtable.c:38262)
File "/home/louis/anaconda3/lib/python3.5/site-packages/numpy/__init__.py", line 180, in <module>
from . import add_newdocs
File "/home/louis/anaconda3/lib/python3.5/site-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/home/louis/anaconda3/lib/python3.5/site-packages/numpy/lib/__init__.py", line 18, in <module>
from .polynomial import *
File "/home/louis/anaconda3/lib/python3.5/site-packages/numpy/lib/polynomial.py", line 20, in <module>
from numpy.linalg import eigvals, lstsq, inv
File "/home/louis/anaconda3/lib/python3.5/site-packages/numpy/linalg/__init__.py", line 51, in <module>
from .linalg import *
File "/home/louis/anaconda3/lib/python3.5/site-packages/numpy/linalg/linalg.py", line 29, in <module>
from numpy.linalg import lapack_lite, _umath_linalg
ImportError: /home/louis/anaconda3/lib/python3.5/site-packages/numpy/linalg/lapack_lite.cpython-35m-x86_64-linux-gnu.so: undefined symbol: zgelsd_
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/louis/anaconda3/lib/python3.5/site-packages/rpy2/ipython/rmagic.py", line 59, in <module>
from rpy2.robjects import pandas2ri as baseconversion
File "/home/louis/anaconda3/lib/python3.5/site-packages/rpy2/robjects/pandas2ri.py", line 6, in <module>
from pandas.core.frame import DataFrame as PandasDataFrame
File "/home/louis/anaconda3/lib/python3.5/site-packages/pandas/__init__.py", line 13, in <module>
"extensions first.".format(module))
ImportError: C extension: /home/louis/anaconda3/lib/python3.5/site-packages/numpy/linalg/lapack_lite.cpython-35m-x86_64-linux-gnu.so: undefined symbol: zgelsd_ not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --inplace' to build the C extensions first.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/louis/anaconda3/lib/python3.5/site-packages/rpy2/ipython/__init__.py", line 1, in <module>
from .rmagic import load_ipython_extension
File "/home/louis/anaconda3/lib/python3.5/site-packages/rpy2/ipython/rmagic.py", line 63, in <module>
from rpy2.robjects import numpy2ri as baseconversion
File "/home/louis/anaconda3/lib/python3.5/site-packages/rpy2/robjects/numpy2ri.py", line 6, in <module>
import numpy
File "/home/louis/anaconda3/lib/python3.5/site-packages/numpy/__init__.py", line 180, in <module>
from . import add_newdocs
File "/home/louis/anaconda3/lib/python3.5/site-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/home/louis/anaconda3/lib/python3.5/site-packages/numpy/lib/__init__.py", line 18, in <module>
from .polynomial import *
File "/home/louis/anaconda3/lib/python3.5/site-packages/numpy/lib/polynomial.py", line 13, in <module>
import numpy.core.numeric as NX
AttributeError: module 'numpy' has no attribute 'core'
I've always ignored the fact that Anaconda3 seems to have been built on RHEL (I'm on Linux Mint, which is based on Ubuntu), but I'm wondering now if this might be the cause of the problem here - "C extensions not built" for my machine?
Since it's in the conda virtual environment, I'm not sure how I can fix this.
Should I attempt to python setup.py build_ext --inplace within ~/anaconda3/lib/python3.5/site-packages/pandas ?
When I step through the above imports, of e.g. :
from numpy.linalg import lapack_lite, _umath_linalg
there's no error, so I'm not certain there are actually unbuilt files, perhaps it's just some masking of one variable by another (as in this question with similar error message but different traceback, i.e. an error in rpy2).
import numpy.core (etc.) without first trying to load rpy2.ipython works fine
Summary of pip show :
---
Metadata-Version: 2.0
Name: rpy2
Version: 2.7.5
---
Metadata-Version: 1.1
Name: numpy
Version: 1.10.1
---
Metadata-Version: 1.1
Name: pandas
Version: 0.17.0
---
Metadata-Version: 2.0
Name: ipython
Version: 4.0.1
(all locations /home/louis/anaconda3/lib/python3.5/site-packages)
System info from cat /proc/version and lsb_release -a :
Linux version 3.13.0-35-generic (buildd#panlong) (gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1) ) #62-Ubuntu SMP Fri Aug 15 01:58:42 UTC 2014
LSB Version: core-2.0-amd64:core-2.0-noarch:core-3.0-amd64:core-3.0-noarch:core-3.1-amd64:core-3.1-noarch:core-3.2-amd64:core-3.2-noarch:core-4.0-amd64:core-4.0-noarch:core-4.1-amd64:core-4.1-noarch
Description: Linux Mint 17 Qiana
I am suspecting an incompatibility between versions of the LAPACK library: the one picked at runtime on your system, the one numpy was built with, and the one R was built with.
Installing numpy, R, and rpy2 from source in your virtual environment should solve the issue. An alternative would be to notify the maintainers of the anaconda packages involved and see it they confirm that numpy and R packaged by anaconda use the same LAPACK.
Related
I'm trying to install statsmodels in Oracle Machine Learning in Conda enviroment.
My conda version is:
%conda
info
active environment : None
shell level : 0
user config file : /u01/.condarc
populated config files : /usr/share/conda/condarc.d/defaults.yaml
/u01/.condarc
conda version : 4.6.14
conda-build version : not installed
python version : 3.6.8.final.0
base environment : /usr (read only)
channel URLs : https://repo.anaconda.com/pkgs/main/linux-64
https://repo.anaconda.com/pkgs/main/noarch
https://repo.anaconda.com/pkgs/free/linux-64
https://repo.anaconda.com/pkgs/free/noarch
https://repo.anaconda.com/pkgs/r/linux-64
https://repo.anaconda.com/pkgs/r/noarch
package cache : /u01/.conda/pkgs
/var/cache/conda/pkgs
envs directories : /u01/.conda/envs
/usr/envs
platform : linux-64
user-agent : conda/4.6.14 requests/2.27.1 CPython/3.6.8 Linux/5.4.17-2136.314.6.3.el7uek.x86_64 oracle/7.9 glibc/2.17
UID:GID : 65000:65000
netrc file : None
offline mode : False
I created the conda enviroment with the next command:
%conda
create -n arima_enviroment python=3.9 xz sqlite libuuid statsmodels numpy
I activated the enviroment with:
%conda
activate arima_enviroment
Test the enviroment with:
%python
import sys
import platform
print("sys.version:", sys.version)
print("sys.version_info:", sys.version_info)
print("platform.python_version:", platform.python_version())
sys.version: 3.9.12 (main, Jun 1 2022, 11:38:51) [GCC 7.5.0]
sys.version_info: sys.version_info(major=3, minor=9, micro=12, releaselevel='final', serial=0)
platform.python_version: 3.9.12
Then I execute the next command for import the ARIMA model.
%python
from statsmodels.tsa.arima_model import arima
But give me the next error:
Fail to execute line 2: from statsmodels.tsa.arima_model import arima
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/numpy/core/__init__.py", line 23, in <module>
from . import multiarray
File "/usr/local/lib/python3.10/site-packages/numpy/core/multiarray.py", line 10, in <module>
from . import overrides
File "/usr/local/lib/python3.10/site-packages/numpy/core/overrides.py", line 6, in <module>
from numpy.core._multiarray_umath import (
ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/tmp/1675189382222-0/zeppelin_python.py", line 206, in <module>
exec(code, _zcUserQueryNameSpace)
File "<stdin>", line 2, in <module>
File "/u01/.conda/active_env/lib/python3.9/site-packages/statsmodels/tsa/__init__.py", line 1, in <module>
from statsmodels.tools._testing import PytestTester
File "/u01/.conda/active_env/lib/python3.9/site-packages/statsmodels/tools/__init__.py", line 1, in <module>
from .tools import add_constant, categorical
File "/u01/.conda/active_env/lib/python3.9/site-packages/statsmodels/tools/tools.py", line 4, in <module>
import numpy as np
File "/usr/local/lib/python3.10/site-packages/numpy/__init__.py", line 144, in <module>
from . import core
File "/usr/local/lib/python3.10/site-packages/numpy/core/__init__.py", line 49, in <module>
raise ImportError(msg)
ImportError:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
* The Python version is: Python3.9 from "/u01/.conda/active_env/bin/python3"
* The NumPy version is: "1.22.1"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: No module named 'numpy.core._multiarray_umath'
Why conda is using Numpy in Python 3.10 folder and not the Numpy version installed in Python 3.9? How can repair it?
System information
Linux Ubuntu 16.04
TensorFlow version: tensorflow-gpu 1.5
Python version: 2.7
Installed using virtualenv: pip
CUDA/cuDNN version: CUDA9.0 & CUDNN7.0
Enviroment
Using anaconda to create a virtual environment named tf.
Error Msg
(tf) ➜ ~ python
Python 2.7.18 |Anaconda, Inc.| (default, Jun 4 2021, 14:47:46)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/xander/anaconda3/envs/tf/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/home/xander/anaconda3/envs/tf/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 52, in <module>
from tensorflow.core.framework.graph_pb2 import *
File "/home/xander/anaconda3/envs/tf/lib/python2.7/site-packages/tensorflow/core/framework/graph_pb2.py", line 6, in <module>
from google.protobuf import descriptor as _descriptor
File "/home/xander/anaconda3/envs/tf/lib/python2.7/site-packages/google/protobuf/descriptor.py", line 113
class DescriptorBase(metaclass=DescriptorMetaclass):
^
SyntaxError: invalid syntax
>>> import tensorflow as tf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/xander/anaconda3/envs/tf/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/home/xander/anaconda3/envs/tf/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
ImportError: cannot import name pywrap_tensorflow
As mentioned in this link, You're running the script in the same directory as TensorFlow. Try to move it out and you should be fine.
For example, Open the Linux command line and execute the script that you've just copied to desktop
Restarting the conda (using miniconda + conda-forge channel) works for me. But I don't know why, though...
I created an environment (radIOenv) in Anaconda.
And I typed python -m pip install git+https://github.com/analysiscenter/radio.git.
When i type import radio or from radio import CTImagesBatch I get the following error : ModuleNotFoundError: No module named 'blosc.blosc_extension'
How can I solve this problem ?
Here is the full output :
(radIOenv) C:\Users\user>python -m pip install git+https://github.com/analysiscenter/radio.git
Collecting git+https://github.com/analysiscenter/radio.git
Cloning https://github.com/analysiscenter/radio.git to c:\users\user\appdata\local\temp\pip-req-build-4ii04ktu
Requirement already satisfied (use --upgrade to upgrade): radio==0.1.0 from git+https://github.com/analysiscenter/radio.git in c:\users\user\anaconda3\envs\radioenv\lib\site-packages
Requirement already satisfied: numpy>=1.10 in c:\users\user\anaconda3\envs\radioenv\lib\site-packages (from radio==0.1.0) (1.16.2)
Requirement already satisfied: pandas>=0.21.0 in c:\users\user\anaconda3\envs\radioenv\lib\site-packages (from radio==0.1.0) (0.24.1)
...
Successfully built radio
(radIOenv) C:\Users\user>python
Python 3.7.1 | packaged by conda-forge | (default, Feb 26 2019, 04:46:14) [MSC v.1900 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import radio
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\user\Anaconda3\envs\radIOenv\lib\site-packages\radio\__init__.py", line 5, in <module>
from .preprocessing import *
File "C:\Users\user\Anaconda3\envs\radIOenv\lib\site-packages\radio\preprocessing\__init__.py", line 3, in <module>
from .ct_batch import CTImagesBatch
File "C:\Users\user\Anaconda3\envs\radIOenv\lib\site-packages\radio\preprocessing\ct_batch.py", line 15, in <module>
import blosc
File "C:\Users\user\Anaconda3\envs\radIOenv\lib\site-packages\blosc\__init__.py", line 13, in <module>
from blosc.blosc_extension import (
ModuleNotFoundError: No module named 'blosc.blosc_extension'
>>> from radio import CTImagesBatch
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\user\Anaconda3\envs\radIOenv\lib\site-packages\radio\__init__.py", line 5, in <module>
from .preprocessing import *
File "C:\Users\user\Anaconda3\envs\radIOenv\lib\site-packages\radio\preprocessing\__init__.py", line 3, in <module>
from .ct_batch import CTImagesBatch
File "C:\Users\user\Anaconda3\envs\radIOenv\lib\site-packages\radio\preprocessing\ct_batch.py", line 15, in <module>
import blosc
File "C:\Users\user\Anaconda3\envs\radIOenv\lib\site-packages\blosc\__init__.py", line 13, in <module>
from blosc.blosc_extension import (
ModuleNotFoundError: No module named 'blosc.blosc_extension'
I've had an issue in Anaconda before where I've accidentally installed the C version of Blosc rather than the Python version. I doubt this is your issue but the Python version is installed with conda install -c conda-forge python-blosc
I know tensorflow-gpu==1.12 needs CUDA 9.0 or lesser but is there any possibility where I can install Tensorflow on CUDA 10.0? May be via source or using Bazel?
UPDATE: I tried downloading from Github and installing via Bazel but I get the following Error.
Python 3.7.1 (default, Oct 23 2018, 19:19:42)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
Traceback (most recent call last):
File "/some-folder/tensorflow-1.12.0/tensorflow/python/platform/self_check.py", line 25, in <module>
from tensorflow.python.platform import build_info
ImportError: cannot import name 'build_info' from 'tensorflow.python.platform' (unknown location)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/some-folder/tensorflow-1.12.0/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "/some-folder/tensorflow-1.12.0/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/some-folder/tensorflow-1.12.0/tensorflow/python/pywrap_tensorflow.py", line 25, in <module>
from tensorflow.python.platform import self_check
File "/some-folder/tensorflow-1.12.0/tensorflow/python/platform/self_check.py", line 27, in <module>
raise ImportError("Could not import tensorflow. Do not import tensorflow "
ImportError: Could not import tensorflow. Do not import tensorflow from its source directory; change directory to outside the TensorFlow source tree, and relaunch your Python interpreter from there.
tensorflow doesn't support python 3.7 version.
Requires Python 3.4, 3.5, or 3.6
see below
https://www.tensorflow.org/install/pip
We need to just come out of the Source Directory and run the python file. If you are running a file with python filename.py command you need to shift the file outside the source directory.
When you use import tensorflow from the source directory it will import the folder tensorflow and not the actual tensorflow library
I tried compiling tensorflow from sources (master) and follow the tensorflow instructions using python3 instead of python2 (and pip defaults to pip3). I can achieve all steps until testing the first model.
I noticed that the problem can be minimally reproduced by doing a simple import tensorflow. The error is as follows:
$ python3
Python 3.5.2 (default, Jul 5 2016, 12:43:10)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcublas.so locally
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcudnn.so locally
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcufft.so locally
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcurand.so locally
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/dist-packages/tensorflow/__init__.py", line 23, in <module>
from tensorflow.python import *
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/__init__.py", line 65, in <module>
import tensorflow.contrib as contrib
File "/usr/local/lib/python3.5/dist-packages/tensorflow/contrib/__init__.py", line 30, in <module>
from tensorflow.contrib import learn
File "/usr/local/lib/python3.5/dist-packages/tensorflow/contrib/learn/__init__.py", line 72, in <module>
from tensorflow.contrib.learn.python.learn import *
File "/usr/local/lib/python3.5/dist-packages/tensorflow/contrib/learn/python/__init__.py", line 23, in <module>
from tensorflow.contrib.learn.python.learn import *
File "/usr/local/lib/python3.5/dist-packages/tensorflow/contrib/learn/python/learn/__init__.py", line 26, in <module>
from tensorflow.contrib.learn.python.learn import estimators
File "/usr/local/lib/python3.5/dist-packages/tensorflow/contrib/learn/python/learn/estimators/__init__.py", line 23, in <module>
from tensorflow.contrib.learn.python.learn.estimators.autoencoder import TensorFlowDNNAutoencoder
File "/usr/local/lib/python3.5/dist-packages/tensorflow/contrib/learn/python/learn/estimators/autoencoder.py", line 25, in <module>
from tensorflow.contrib.learn.python.learn.estimators.base import TensorFlowBaseTransformer
File "/usr/local/lib/python3.5/dist-packages/tensorflow/contrib/learn/python/learn/estimators/base.py", line 34, in <module>
from tensorflow.contrib.learn.python.learn.estimators import estimator
File "/usr/local/lib/python3.5/dist-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py", line 39, in <module>
from tensorflow.contrib.learn.python.learn.learn_io import data_feeder
File "/usr/local/lib/python3.5/dist-packages/tensorflow/contrib/learn/python/learn/learn_io/__init__.py", line 22, in <module>
from tensorflow.contrib.learn.python.learn.learn_io.dask_io import extract_dask_data
File "/usr/local/lib/python3.5/dist-packages/tensorflow/contrib/learn/python/learn/learn_io/dask_io.py", line 26, in <module>
import dask.dataframe as dd
File "/usr/local/lib/python3.5/dist-packages/dask/__init__.py", line 7, in <module>
from .delayed import do, delayed, value
File "/usr/local/lib/python3.5/dist-packages/dask/delayed.py", line 12, in <module>
from . import base
File "/usr/local/lib/python3.5/dist-packages/dask/base.py", line 287, in <module>
import pandas as pd
File "/usr/local/lib/python3.5/dist-packages/pandas/__init__.py", line 22, in <module>
from pandas.compat.numpy import *
File "/usr/local/lib/python3.5/dist-packages/pandas/compat/__init__.py", line 350, in <module>
from dateutil import parser as _date_parser
File "/usr/local/lib/python3.5/dist-packages/dateutil/parser.py", line 158
l.append("%s=%s" % (attr, `value`))
^
SyntaxError: invalid syntax
Other questions related to similar syntax problems are related to older versions of protobuf, however my version is 3
$ pip3 show protobuf
---
Metadata-Version: 2.0
Name: protobuf
Version: 3.0.0b2
Summary: Protocol Buffers
Home-page: https://developers.google.com/protocol-buffers/
Author: protobuf#googlegroups.com
Author-email: protobuf#googlegroups.com
Installer: pip
License: New BSD License
Location: /usr/local/lib/python3.5/dist-packages
Requires: six, setuptools
Classifiers:
Programming Language :: Python
Programming Language :: Python :: 2
Programming Language :: Python :: 2.6
Programming Language :: Python :: 2.7
Programming Language :: Python :: 3
Programming Language :: Python :: 3.3
Programming Language :: Python :: 3.4
How can I solve this problem?
It looks like the installed dateutil package (which TensorFlow depends on via dask and pandas) is incompatible with Python 3, using backticks as a synonym for repr(), which was removed in 3.0. The particular line from dateutil/parser.py where the error occurs was updated for Python 3 in 2011.
Try running the following command to upgrade dateutil:
$ pip3 install python-dateutil --upgrade