I'm suddenly unable to import pytorch geometric and I cannot figure out why. I've added a screenshot of the packages in my conda environment and the error message that I get when I try to import torch_geometric.
import torch
import torch.nn.functional as F
from torch_geometric.nn import GCNConv
Error message:
OSError: dlopen(/Users/anstercharles/opt/anaconda3/lib/python3.8/site-packages/torch_sparse/_convert_cpu.so, 6): Symbol not found: __ZN2at8internal13_parallel_runExxxRKNSt3__18functionIFvxxmEEE
Referenced from: /Users/anstercharles/opt/anaconda3/lib/python3.8/site-packages/torch_sparse/_convert_cpu.so
Expected in: /Users/anstercharles/opt/anaconda3/lib/python3.8/site-packages/torch/lib/libtorch_cpu.dylib
in /Users/anstercharles/opt/anaconda3/lib/python3.8/site-packages/torch_sparse/_convert_cpu.so
Running:
conda list pytorch
Gives me:
Name
Version
Build
Channel
pytorch
1.9.0
cpu_py38h490fcb8_1
conda-forge
pytorch-cluster
1.5.9
py38_torch_1.9.0_cpu
rusty1s
pytorch-geometric
1.7.2
py38_torch_1.9.0_cpu
rusty1s
pytorch-scatter
2.0.8
py38_torch_1.9.0_cpu
rusty1s
pytorch-sparse
0.6.11
py38_torch_1.9.0_cpu
rusty1s
pytorch-spline-conv
1.2.1
py38_torch_1.9.0_cpu
rusty1s
Additional Details
OS: MacOS Mojave
Anaconda 3
Python 3.8
I can replicate the error. The documentation in the README, to use
conda install pytorch-geometric -c rusty1s -c conda-forge
does not match the order that is actually used in the build, which has the channel order:
-c defaults -c pytorch -c conda-forge -c rusty1s
Workaround
I find it works using:
conda create -n foo -c defaults -c pytorch -c conda-forge -c rusty1s pytorch-geometric
following #merv answer, I resolved it by changing my python version from 3.8 to 3.9
I created another environment as follows: (M1 Mac Big Sur)
python : 3.9.7
pytorch : 1.9.1
pytorch-geometric : 2.0.1
Related
I've been trying to install the Pytorch module for my Ubuntu 16.04 LTS through conda. I used conda install pytorch torchvision cpuonly -c pytorch to install it (non CUDA version). However when I type import torch on the Python shell, this is what I see -
ImportError: /home/student/anaconda2/lib/python2.7/site-packages/torch/_C.so: object file has no loadable segments
I have verified that Pytorch was installed using conda list
I had the same issue on Ubuntu 18.04 for conda env with python 3.8. The problem I think is for the incomplete torch installation. So I did pip install from wheel instead of conda install. You may follow as below (assuming you have cuda11 installed):
create conda env
conda create --name=myenv python=3.8
conda activate myenv
Install torch from wheel
pip install torch==1.7.0+cu110 torchvision==0.8.1+cu110 torchaudio===0.7.0 -f https://download.pytorch.org/whl/torch_stable.html
Please note I had to install torchvision==0.8.1+cu110 as reported here
I have tried to install both CPU and GPU version of TensorFlow according to the manual from here https://docs.anaconda.com/anaconda/user-guide/tasks/tensorflow/ and all was ok:
(tf-gpu) C:\Users\Kosh>conda create -n tf tensorflow Collecting
package metadata (current_repodata.json): done Solving environment:
done
==> WARNING: A newer version of conda exists. <== current version: 4.7.12 latest version: 4.8.3
Please update conda by running
$ conda update -n base -c defaults conda
Package Plan
environment location: C:\Anaconda3\envs\tf
added / updated specs:
- tensorflow
The following packages will be downloaded:
package | build
---------------------------|-----------------
_tflow_select-2.2.0 | eigen 3 KB
tensorflow-2.1.0 |eigen_py37hd727fc0_0 4 KB
tensorflow-base-2.1.0 |eigen_py37h49b2757_0 35.4 MB
------------------------------------------------------------
Total: 35.4 MB
The following NEW packages will be INSTALLED:
_tflow_select pkgs/main/win-64::_tflow_select-2.2.0-eigen
absl-py pkgs/main/win-64::absl-py-0.9.0-py37_0 asn1crypto
pkgs/main/win-64::asn1crypto-1.3.0-py37_0 astor
pkgs/main/win-64::astor-0.8.0-py37_0 blas
pkgs/main/win-64::blas-1.0-mkl blinker
pkgs/main/win-64::blinker-1.4-py37_0 ca-certificates
pkgs/main/win-64::ca-certificates-2020.1.1-0 cachetools
pkgs/main/noarch::cachetools-3.1.1-py_0 certifi
pkgs/main/win-64::certifi-2020.4.5.1-py37_0 cffi
pkgs/main/win-64::cffi-1.14.0-py37h7a1dbc1_0 chardet
pkgs/main/win-64::chardet-3.0.4-py37_1003 click
pkgs/main/noarch::click-7.1.1-py_0 cryptography
pkgs/main/win-64::cryptography-2.8-py37h7a1dbc1_0 gast
pkgs/main/win-64::gast-0.2.2-py37_0 google-auth
pkgs/main/noarch::google-auth-1.13.1-py_0 google-auth-oauth~
pkgs/main/noarch::google-auth-oauthlib-0.4.1-py_2 google-pasta
pkgs/main/noarch::google-pasta-0.2.0-py_0 grpcio
pkgs/main/win-64::grpcio-1.27.2-py37h351948d_0 h5py
pkgs/main/win-64::h5py-2.10.0-py37h5e291fa_0 hdf5
pkgs/main/win-64::hdf5-1.10.4-h7ebc959_0 icc_rt
pkgs/main/win-64::icc_rt-2019.0.0-h0cc432a_1 idna
pkgs/main/noarch::idna-2.9-py_1 intel-openmp
pkgs/main/win-64::intel-openmp-2020.0-166 keras-applications
pkgs/main/noarch::keras-applications-1.0.8-py_0 keras-preprocessi~
pkgs/main/noarch::keras-preprocessing-1.1.0-py_1 libprotobuf
pkgs/main/win-64::libprotobuf-3.11.4-h7bd577a_0 markdown
pkgs/main/win-64::markdown-3.1.1-py37_0 mkl
pkgs/main/win-64::mkl-2020.0-166 mkl-service
pkgs/main/win-64::mkl-service-2.3.0-py37hb782905_0 mkl_fft
pkgs/main/win-64::mkl_fft-1.0.15-py37h14836fe_0 mkl_random
pkgs/main/win-64::mkl_random-1.1.0-py37h675688f_0 numpy
pkgs/main/win-64::numpy-1.18.1-py37h93ca92e_0 numpy-base
pkgs/main/win-64::numpy-base-1.18.1-py37hc3f5095_1 oauthlib
pkgs/main/noarch::oauthlib-3.1.0-py_0 openssl
pkgs/main/win-64::openssl-1.1.1f-he774522_0 opt_einsum
pkgs/main/noarch::opt_einsum-3.1.0-py_0 pip
pkgs/main/win-64::pip-20.0.2-py37_1 protobuf
pkgs/main/win-64::protobuf-3.11.4-py37h33f27b4_0 pyasn1
pkgs/main/noarch::pyasn1-0.4.8-py_0 pyasn1-modules
pkgs/main/noarch::pyasn1-modules-0.2.7-py_0 pycparser
pkgs/main/noarch::pycparser-2.20-py_0 pyjwt
pkgs/main/win-64::pyjwt-1.7.1-py37_0 pyopenssl
pkgs/main/win-64::pyopenssl-19.1.0-py37_0 pyreadline
pkgs/main/win-64::pyreadline-2.1-py37_1 pysocks
pkgs/main/win-64::pysocks-1.7.1-py37_0 python
pkgs/main/win-64::python-3.7.7-h60c2a47_0_cpython requests
pkgs/main/win-64::requests-2.23.0-py37_0 requests-oauthlib
pkgs/main/noarch::requests-oauthlib-1.3.0-py_0 rsa
pkgs/main/noarch::rsa-4.0-py_0 scipy
pkgs/main/win-64::scipy-1.4.1-py37h9439919_0 setuptools
pkgs/main/win-64::setuptools-46.1.3-py37_0 six
pkgs/main/win-64::six-1.14.0-py37_0 sqlite
pkgs/main/win-64::sqlite-3.31.1-he774522_0 tensorboard
pkgs/main/noarch::tensorboard-2.1.0-py3_0 tensorflow
pkgs/main/win-64::tensorflow-2.1.0-eigen_py37hd727fc0_0
tensorflow-base
pkgs/main/win-64::tensorflow-base-2.1.0-eigen_py37h49b2757_0
tensorflow-estima~
pkgs/main/noarch::tensorflow-estimator-2.1.0-pyhd54b08b_0 termcolor
pkgs/main/win-64::termcolor-1.1.0-py37_1 urllib3
pkgs/main/win-64::urllib3-1.25.8-py37_0 vc
pkgs/main/win-64::vc-14.1-h0510ff6_4 vs2015_runtime
pkgs/main/win-64::vs2015_runtime-14.16.27012-hf0eaf9b_1 werkzeug
pkgs/main/win-64::werkzeug-0.14.1-py37_0 wheel
pkgs/main/win-64::wheel-0.34.2-py37_0 win_inet_pton
pkgs/main/win-64::win_inet_pton-1.1.0-py37_0 wincertstore
pkgs/main/win-64::wincertstore-0.2-py37_0 wrapt
pkgs/main/win-64::wrapt-1.12.1-py37he774522_1 zlib
pkgs/main/win-64::zlib-1.2.11-h62dcd97_3
Proceed ([y]/n)? y
Downloading and Extracting Packages
_tflow_select-2.2.0 | 3 KB | ############################################################################ | 100% tensorflow-2.1.0 | 4 KB |
###################################################################### | 100% tensorflow-base-2.1. | 35.4 MB |
###################################################################### | 100% Preparing transaction: done Verifying transaction: done
Executing transaction: done
#
To activate this environment, use
#
$ conda activate tf
#
To deactivate an active environment, use
#
$ conda deactivate
(tf-gpu) C:\Users\Kosh> (tf-gpu) C:\Users\Kosh> (tf-gpu)
C:\Users\Kosh>conda activate tf-2 Could not find conda environment:
tf-2 You can list all discoverable environments with conda info
--envs.
(tf-gpu) C:\Users\Kosh>conda activate tf
but when I try to import it in Spyder or in Python I get the same result:
import tensorflow as tf
Traceback (most recent call last):
File "<ipython-input-1-64156d691fe5>", line 1, in <module>
import tensorflow as tf
ModuleNotFoundError: No module named 'tensorflow'
Can somebody help me with this?
I have the same problem using Python 3.7 and Tensorflow 2.1.
I created the environment tf-2 using conda create -n tf-2 tensorflow pandas.
There is no error using command prompt, but Spyder didn't find the Tensorflow library.
I verified that the IPython window was showing Python 3.6.9 (base version), while the command prompt was returning 3.7 to this command:
python -c "import platform; print(platform.python_version())"
The reason were:
the new environment didn't have Spyder installed;
conda install Tensorflow 1.13 by default.
Then, I removed the environment tf2 and recreated it including the Python version and Spyder:
conda create -n tf2 python=3.6 spyder
Then, I installed tensorflow by pip.
conda activate tf2
pip install tensorflow
It worked for me:
Run the anaconda prompt as administrator.(right click-> run as administrator).
pip uninstall tensorflow.
Close anaconda prompt.
Again run anaconda prompt as administrator.
type:
conda install tensorflow
It will ask for some y / n
Type y.
Now after all done, change your python interpreter's environment to anaconda environment where you installed tensorflow.
After that tensorflow imported successfully!
installed pytorch with conda :
(base) (3.8.0/envs/my_virtual_env-3.8.0) marco#pc:~/facenet_pytorch/examples$ conda install
pytorch torchvision cpuonly -c pytorch
Collecting package metadata (current_repodata.json): done
Solving environment: done
# All requested packages already installed.
I updated conda:
(base) (3.8.0/envs/my_virtual_env-3.8.0) marco#pc:~/facenet_pytorch/examples$ conda update
conda
Collecting package metadata (current_repodata.json): done
Solving environment: done
# All requested packages already installed.
Installed mkl=2019 :
(base) (3.8.0/envs/my_virtual_env-3.8.0) marco#pc:~/facenet_pytorch/examples$ conda install
mkl=2019
Collecting package metadata (current_repodata.json): done
Solving environment: done
# All requested packages already installed.
(base) (3.8.0/envs/my_virtual_env-3.8.0) marco#pc:~/facenet_pytorch/examples$ conda list | grep
torch
cpuonly 1.0 0 pytorch
facenet-pytorch 0.1.0 pypi_0 pypi
pytorch 1.3.0 py3.7_cpu_0 [cpuonly] pytorch
torchfile 0.1.0 pypi_0 pypi
torchvision 0.4.1 py37_cpu [cpuonly] pytorch
But it still says "no module torch" :
(base) (3.8.0/envs/my_virtual_env-3.8.0) marco#pc:~/facenet_pytorch/examples$ python3
Python 3.8.0 (default, Oct 30 2019, 16:20:23)
[GCC 7.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'torch'
>>>
I discovered that the problem appears only with python 3.8.0 version
(base) marco#pc:~/facenet_pytorch$ python3
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.
>>> import torch
>>>
Ubuntu 18.04.02 Server Edition
Or, may be, it's just a matter of python environments, as you said.
But I do not understand why just activating conda environment, with "conda activate", it doesn't work
Marco
First create a Conda environment using:
conda create -n pytorch_env python=3 ( you can create with any python version )
Activate the environment using:
conda activate pytorch_env
Now install PyTorch using:
conda install pytorch-cpu torchvision -c pytorch
Go to python shell and import using the command:
import torch
Thanks all for your kind answers.
I solved the problem
- first, "downgrading" python from 3.8.0 to 3.7.3 because I checked in PyTorch's chat environment that PyTorch is not yet compatible with python 3.8.0
- and then, after removing everything already installed, installing the latest version of PyTorch via cunda, as you kindly explained
Pytorch can be installed via pip and conda. For that, you need to create a separate conda environment. Thus, it will not corrupt the base environment.
Steps to create a new conda environment as follows:
conda create -n conda_pytorch python=3.6
source activate conda_pytorch
Follow the below command to install pytorch via pip:
pip install torch==1.3.1+cpu torchvision==0.4.2+cpu -f https://download.pytorch.org/whl/torch_stable.html
Pytorch installation via conda:
conda install pytorch torchvision cpuonly -c pytorch
Verify the pytorch installation in the python shell using:
import torch
xgboost imported successfully, but I'm not able to import XGBClassifier.
Check whether xgboost is properly installed or not.
To install xgboost in anaconda distribution, you can run the following command in anaconda command-line console.
conda install -c conda-forge xgboost=0.6a2or 'conda install -c anaconda py-xgboost'
It will work fine after the installation.
After having upgraded my environment's python to Python 3.61, I attempted to install pytorch using this command:
conda install -c peterjc123 pytorch
However I got this error:
Fetching package metadata .............
Solving package specifications: .
UnsatisfiableError: The following specifications were found to be in conflict:
-pytorch
-pyqt
I also used the commands
conda install -c peterjc123 pytorch cuda90
conda install -c peterjc123 pytorch cuda80
But the result is still the same. Anyone got a clue how to solve this?
The problem was solved after downgrading from Python 3.6.2 to Python 3.5.1 after running:
conda install -c anaconda python=3.5.1
After running this command, run:
conda install -c peterjc123 pytorch
Pytorch should install as per normal. A similar issue occurs for openCV as well
An alternative way to install pytorch using anaconda is
conda create -n py_env python=3.5
source activate py_env
conda install pytorch-cpu torchvision -c pytorch
Go to python shell and import using the command
import torch
Hope this helps.