Why aiohttp import shows below error? - python-3.5

The aiohttp module was installed successfully
But can not be imported as below info
[root#ceph_admin ~]# python3
Python 3.6.5 (default, Jul 1 2018, 23:52:30)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import aiohttp
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/site-packages/aiohttp/__init__.py", line 6, in <module>
from .client import * # noqa
File "/usr/local/lib/python3.6/site-packages/aiohttp/client.py", line 17, in <module>
from . import client_exceptions, client_reqrep
File "/usr/local/lib/python3.6/site-packages/aiohttp/client_reqrep.py", line 17, in <module>
from . import hdrs, helpers, http, multipart, payload
File "/usr/local/lib/python3.6/site-packages/aiohttp/helpers.py", line 40, in <module>
import idna_ssl
File "/usr/local/lib/python3.6/site-packages/idna_ssl.py", line 1, in <module>
import ssl
File "/usr/local/lib/python3.6/ssl.py", line 101, in <module>
import _ssl # if we can't import it, let the error propagate
ModuleNotFoundError: No module named '_ssl'

The error above is
ModuleNotFoundError: No module named '_ssl'
So the real problem is my python3 can not import the module _ssl
My python 3.5 was installed from source code. Below are the correct ways to make python 3.5 have _ssl.
1. install openssl-devel by yum(My OS is CentOS)
2. compile your python source code with command (./configure && make && make install)

Related

How to install nest in Python3 on Ubuntu 18.04

After following the Ubuntu/Debian installation instructions for the Nest simulator I can only import the nest module in python2.x, not python3.x
$ python3
Python 3.6.8 (default, Aug 20 2019, 17:12:48)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import nest
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/nest/lib/python2.7/site-packages/nest/__init__.py", line 26, in <module>
from . import ll_api # noqa
File "/nest/lib/python2.7/site-packages/nest/ll_api.py", line 72, in <module>
from . import pynestkernel as kernel # noqa
ImportError: dynamic module does not define module export function (PyInit_pynestkernel)
The default install compiles with the default Python version which is still 2 in Ubuntu.
To use Python 3, run:
cmake -Dwith-python=3 -DCMAKE_INSTALL_PREFIX:PATH=</install/path> </path/to/NEST/src>
Mentioned here in the doc.
NB: don't forget to clear the build folder to avoid issues

ImportError: Incompatible library version for PIL/pillow

I recently installed shap, which requires pillow>=4.3.0 as:
$ pip3 install shap
Installing collected packages: shap, pillow
Successfully installed pillow-6.0.0 shap-0.29.2
Running my script that uses shap, I got:
Traceback (most recent call last):
File "Runner.py", line 132, in <module>
import shap
File "/usr/local/Cellar/python3/3.6.4_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/shap/__init__.py", line 11, in <module>
from .plots.summary import summary_plot
File "/usr/local/Cellar/python3/3.6.4_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/shap/plots/summary.py", line 15, in <module>
from . import colors
File "/usr/local/Cellar/python3/3.6.4_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/shap/plots/colors.py", line 7, in <module>
import skimage.color
File "/Users/bravina/Library/Python/3.6/lib/python/site-packages/skimage/__init__.py", line 135, in <module>
from .data import data_dir
File "/Users/bravina/Library/Python/3.6/lib/python/site-packages/skimage/data/__init__.py", line 13, in <module>
from ..io import imread, use_plugin
File "/Users/bravina/Library/Python/3.6/lib/python/site-packages/skimage/io/__init__.py", line 7, in <module>
from .manage_plugins import *
File "/Users/bravina/Library/Python/3.6/lib/python/site-packages/skimage/io/manage_plugins.py", line 24, in <module>
from .collection import imread_collection_wrapper
File "/Users/bravina/Library/Python/3.6/lib/python/site-packages/skimage/io/collection.py", line 10, in <module>
from PIL import Image
File "/usr/local/Cellar/python3/3.6.4_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/PIL/Image.py", line 93, in <module>
from . import _imaging as core
ImportError: dlopen(/usr/local/Cellar/python3/3.6.4_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/PIL/_imaging.cpython-36m-darwin.so, 2): Library not loaded: #loader_path/.dylibs/libtiff.5.dylib
Referenced from: /usr/local/Cellar/python3/3.6.4_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/PIL/_imaging.cpython-36m-darwin.so
Reason: Incompatible library version: _imaging.cpython-36m-darwin.so requires version 10.0.0 or later, but libtiff.5.dylib provides version 8.0.0
Same thing if I try it directly in python3:
Python 3.6.4 (default, Jan 4 2018, 14:56:03)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin
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 "/usr/local/Cellar/python3/3.6.4_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/PIL/Image.py", line 93, in <module>
from . import _imaging as core
ImportError: dlopen(/usr/local/Cellar/python3/3.6.4_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/PIL/_imaging.cpython-36m-darwin.so, 2): Library not loaded: #loader_path/.dylibs/libtiff.5.dylib
Referenced from: /usr/local/Cellar/python3/3.6.4_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/PIL/_imaging.cpython-36m-darwin.so
Reason: Incompatible library version: _imaging.cpython-36m-darwin.so requires version 10.0.0 or later, but libtiff.5.dylib provides version 8.0.0
Any tips as how to fix this?
Well, none of the answers suggested in this related post worked for me, so I ended up completely cleaning and reinstalling python3. From there, installing the necessary packages in a virtualenv as cleanly as possible seemed to resolve the issue...

Can't import praw in Python3

I've been writing a reddit bot for a while now and recently moved it to a different system. There I've installed the same packages as on the previous system.
The bot is Python3 based so I install praw:
$ sudo pip3 install praw
[...]
Which went just fine as expected, but now when I import praw:
$ python3
Python 3.4.2 (default, Oct 8 2014, 10:45:20)
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import praw
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.4/dist-packages/praw/__init__.py", line 14, in <module>
from .reddit import Reddit # NOQA
File "/usr/local/lib/python3.4/dist-packages/praw/reddit.py", line 11, in <module>
from prawcore import (Authorizer, DeviceIDAuthorizer, ReadOnlyAuthorizer,
ImportError: No module named 'prawcore'
Even after manually adding the path to the module, I can't import praw.
>>> import sys
>>> sys.path.append('/usr/local/lib/python3.4/dist-packages/')
>>> import praw
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.4/dist-packages/praw/__init__.py", line 14, in <module>
from .reddit import Reddit # NOQA
File "/usr/local/lib/python3.4/dist-packages/praw/reddit.py", line 11, in <module>
from prawcore import (Authorizer, DeviceIDAuthorizer, ReadOnlyAuthorizer,
ImportError: No module named 'prawcore'
With python(2), it seems to be working just fine.
How can I get my system to successfully import praw?
From reddit.com/r/redditdev:
pip3 install praw --upgrade --force-reinstall
did the job. Apparently something went wrong during the initial installation.

Python 3.6.2 from urllib.request import urlopen

This is a script that I want to start to use. I have seen this as a working version on a few location. Any one has an idea why this will not execute on my mac system. I am open to all ideas to solve this issue.
from urllib.request import urlopen
html = urllib.request.urlopen("http://www.google.com")
print(html.read())
I get this as the output when executed.
Python 3.6.2 (v3.6.2:5fd33b5926, Jul 16 2017, 20:11:06)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "copyright", "credits" or "license()" for more information.
>>>
====== RESTART: /Users/John/Documents/python_function_john/scraping.py ======
Traceback (most recent call last):
File "/Users/John/Documents/python_function_john/scraping.py", line 1, in <module>
from urllib.request import urlopen
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 88, in <module>
import http.client
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 71, in <module>
import email.parser
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/email/parser.py", line 12, in <module>
from email.feedparser import FeedParser, BytesFeedParser
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/email/feedparser.py", line 27, in <module>
from email._policybase import compat32
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/email/_policybase.py", line 9, in <module>
from email.utils import _has_surrogates
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/email/utils.py", line 30, in <module>
import datetime
File "/Users/John/Documents/datetime.py", line 4
print a.time()
^
SyntaxError: invalid syntax
It is better that you install Anaconda; this application installs some Python package on your computer. Then write following line in Conda Prompt:
conda install -c conda-forge requests
After all, use Spyder application which has been installed with Anaconda.

canopy linux running error: missing libmkl_intel_lp64.so

I am a paid user and I have installed canopy on a red hat server and got the virtual environment configured. In the virtual env, python is the one contained in the environment:
(User) $ which python
~/Enthought/Canopy_64bit/User/bin/python
But when I cannot import "numpy" from python:
(User) $ python
Enthought Canopy Python 2.7.3 | 64-bit | (default, Mar 25 2013, 15:55:17)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-52)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/canopy/appdata/canopy-1.0.0.1160.rh5-x86_64/lib/python2.7/site-packages/numpy/__init__.py", line 148, in <module>
import add_newdocs
File "/usr/lib/canopy/appdata/canopy-1.0.0.1160.rh5-x86_64/lib/python2.7/site-packages/numpy/add_newdocs.py", line 9, in <module>
from numpy.lib import add_newdoc
File "/usr/lib/canopy/appdata/canopy-1.0.0.1160.rh5-x86_64/lib/python2.7/site-packages/numpy/lib/__init__.py", line 13, in <module>
from polynomial import *
File "/usr/lib/canopy/appdata/canopy-1.0.0.1160.rh5-x86_64/lib/python2.7/site-packages/numpy/lib/polynomial.py", line 17, in <module>
from numpy.linalg import eigvals, lstsq
File "/usr/lib/canopy/appdata/canopy-1.0.0.1160.rh5-x86_64/lib/python2.7/site-packages/numpy/linalg/__init__.py", line 48, in <module>
from linalg import *
File "/usr/lib/canopy/appdata/canopy-1.0.0.1160.rh5-x86_64/lib/python2.7/site-packages/numpy/linalg/linalg.py", line 23, in <module>
from numpy.linalg import lapack_lite
**ImportError: libmkl_intel_lp64.so: cannot open shared object file: No such file or directory**
I tried to update numpy with enpkg, but the above error still shows up when importing numpy.
(User) $ enpkg numpy
prefix: /home/wchen06/canopy_virtual
MKL-10.3-1.egg [fetching]
74.60 MB [.................................................................]
numpy-1.6.1-5.egg [fetching]
3.33 MB [.................................................................]
MKL-10.3-1.egg [installing]
248.04 MB [.................................................................]
numpy-1.6.1-5.egg [installing]
11.20 MB [.................................................................]
Please help.
Sorry for the late reply! This is due to a bug in Canopy 1.0.0 (beta) for Linux. For a workaround, please see https://support.enthought.com/entries/21656595-ImportError-libmkl-intel-lp64-so-cannot-open-shared-object-file

Resources