Graph-tool installed, Import.all does not work - python-3.x

I have installed graph-tool:
brew --prefix graph-tool
'/usr/local/opt/graph-tool
but when trying to import it:
Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 12:04:33)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from graph_tool.all import *
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'graph_tool'
:(
Does anyone have a solution for this?
Thanks

Homebrew installs the library using its own Python interpreter, which has its module path somewhere in /usr/local/opt/. You are using the anaconda Python interpreter, which knows nothing about homebrew-installed modules. The solution here is simply to use homebrew's Python interpreter, not anaconda's.

Related

Why i can't import torch?

I downloaded and installed CUDA10.0 pyhton3.6 pytorch1.2. , also loaded cuda/cuda-10.0-x86_6 envirnment.
Commands like below
module load cuda/cuda-10.0-x86_64
# CUDA 10.0
conda install pytorch==1.2.0 torchvision==0.4.0 cudatoolkit=10.0 -c pytorch
Because it needs to be installed on a NO-NETWOEK centOs server! Therefore, all pakages need be downloaded in advance and run command like below.
conda install --offline pytorch-1.2.0-cuda100py36h938c94c_0.tar.bz2
......
The error occured below.
Python 3.6.0 |Anaconda 4.3.0 (64-bit)| (default, Dec 23 2016, 12:22:00)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/data/users/CHDHPC/2020224009/anaconda3/lib/python3.6/site-packages/torch/__init__.py", line 81, in <module>
from torch._C import *
ImportError: libmkl_gnu_thread.so: cannot open shared object file: No such file or directory
I have no idea to solve it! Anyone can help me! Thank you!!
Finally I fixed this issue by changing Python version to 3.6.2 and re-installing the cuda and cudnn.
Pecfect!

Trouble with installing libffi-dev for Python 3.7

When trying to install pgadmin4 in desktop mode on my Ubuntu system, I received a ModuleNotFoundError for _ctypes.
I did some research and found that _ctypes requires the libffi-dev package to be installed. However it seems that libffi-dev and thus _ctypes was installed for Python 2.7, when I run import ctypes it seems to work:
$ python2
Python 2.7.15+ (default, Nov 27 2018, 23:36:35)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctypes
>>>
When I try to do the same for Python 3.7, it doesn't work:
$ python
Python 3.7.3 (default, Jun 21 2019, 12:46:58)
[GCC 7.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctypes
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.7/ctypes/__init__.py", line 7, in <module>
from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'
How could I add the module _ctypes to my Python 3.7 configuration?
If you install python from source file, you have to install some required packages manually as mentioned in https://superuser.com/questions/1412975/how-to-build-and-install-python-3-7-x-from-source-on-debian-9-8.
Actually you are supposed to see some errors after make due to libffinot found as shown in the screenshot below. However, you can still run make install despite the error. When you open python after the installation and import the module, it then gives you such error.
To solve this problem, you can install the dependent package i.e libffi or libffi-devel(redhat) prior to ./configure, make and make install as mentioned in:
Package libffi was not found in the pkg-config search path REDHAT6.5 and
https://bugs.python.org/issue31652.

ModuleNotFoundError: No module named 'allennlp.common'

I am getting this error while importing allennlp,
from allennlp.common.util import sanitize
ModuleNotFoundError: No module named 'allennlp.common'
(venv-kbs) administrator#NLR:~/aman/Project$ python
Python 3.6.3 (default, Oct 6 2017, 00:00:00)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import allennlp
>>> from allennlp.common.util import sanitize
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'allennlp.common'
My allennlp version is 0.2.1 and even trying to update to 0.4.1 it gives the same error.
TIA
Do check python version, Allennlp keeps pushing updates on regular period and thing works according to Python as well as Pytorch version.

python pillow DLL load failed

I'm using Python 3.6.4 with pillow 5.0.0, through Anaconda.
Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 10:22:32) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from PIL import Image
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "F:\Anaconda2\envs\py3\lib\site-packages\PIL\Image.py", line 58, in <module>
from . import _imaging as core
ImportError: DLL load failed: The specified module could not be found.
Probably the same as this question. But that was 10 months ago and the answer says it was fixed with Python 3.6.1.
If you're using the Anaconda distribution, try removing it with Conda:
conda uninstall pillow
and installing it using pip:
pip install pillow
You can test that it's working:
python -c "from PIL import Image"

Tkinter found on Python 3 but not on Python2.7

I am on CentOs7. I installed tk, tk-devel, tkinter through yum. I can import tkinter in Python 3, but not in Python 2.7. Any ideas?
Success in Python 3 (Anaconda):
Python 3.6.3 |Anaconda custom (64-bit)| (default, Oct 13 2017, 12:02:49)
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tkinter
>>>
But fail on Python 2.7 (CentOS default):
Python 2.7.5 (default, Aug 4 2017, 00:39:18)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import Tkinter
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python2.7/lib-tk/Tkinter.py", line 39, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: libTix.so: cannot open shared object file: No such file or directory
I read some answers said
If it fails with "No module named _tkinter", your Python configuration needs to be modified to include this module (which is an extension module implemented in C). Do not edit Modules/Setup (it is out of date). You may have to install Tcl and Tk (when using RPM, install the -devel RPMs as well) and/or edit the setup.py script to point to the right locations where Tcl/Tk is installed. If you install Tcl/Tk in the default locations, simply rerunning "make" should build the _tkinter extension.
I have reinstalled tk, tk-devel and tkinter through yum, but the problem is same.
How can I configure it to work on Python 2.7?
For python 3 use:
import tkinter
For python 2 use:
import Tkinter
If these do not work install with, for python 3:
sudo apt-get install python3-tk
or, for python 2:
sudo apt-get install python-tk
you can find more details here
For python2.7 try
import Tkinter
With a capital T. It should already be pre-installed in default centos 7 python setup, if not do yum install tkinter

Resources