Installed cairosvg and cairocffi but gives error on import - python

When I try to install cairosvg it says requirement satisfied.
Requirement already satisfied: cairosvg in
c:\users\kshitij\appdata\local\programs\python\python35\lib\site-packages
Requirement already satisfied: cairocffi in
c:\users\kshitij\appdata\local\programs\python\python35\lib\site-packages
(from cairosvg)
Requirement already satisfied: lxml in
c:\users\kshitij\appdata\local\programs\python\python35\lib\site-packages
(from cairosvg)
Requirement already satisfied: cssselect in
c:\users\kshitij\appdata\local\programs\python\python35\lib\site-packages
(from cairosvg)
Requirement already satisfied: pillow in
c:\users\kshitij\appdata\local\programs\python\python35\lib\site-packages
(from cairosvg)
Requirement already satisfied: tinycss in
c:\users\kshitij\appdata\local\programs\python\python35\lib\site-packages
(from cairosvg)
Requirement already satisfied: cffi>=0.6 in
c:\users\kshitij\appdata\local\programs\python\python35\lib\site-packages
(from cairocffi->cairosvg)
Requirement already satisfied: olefile in
c:\users\kshitij\appdata\local\programs\python\python35\lib\site-packages
(from pillow->cairosvg)
Requirement already satisfied: pycparser in
c:\users\kshitij\appdata\local\programs\python\python35\lib\site-packages
(from cffi>=0.6->cairocffi->cairosvg)
But when I try to import it in IDLE, it gives the following error:
import cairosvg
File "C:\Users\Kshitij\AppData\Local\Programs\Python\Python35\lib\site-
packages\cairosvg\__init__.py", line 29, in <module>
from . import surface
File "C:\Users\Kshitij\AppData\Local\Programs\Python\Python35\lib\site-
packages\cairosvg\surface.py", line 24, in <module>
import cairocffi as cairo
File "C:\Users\Kshitij\AppData\Local\Programs\Python\Python35\lib\site-
packages\cairocffi\__init__.py", line 41, in <module>
cairo = dlopen(ffi, *CAIRO_NAMES)
File "C:\Users\Kshitij\AppData\Local\Programs\Python\Python35\lib\site-
packages\cairocffi\__init__.py", line 34, in dlopen
return ffi.dlopen(names[0]) # pragma: no cover
File "C:\Users\Kshitij\AppData\Local\Programs\Python\Python35\lib\site-
packages\cffi\api.py", line 140, in dlopen
lib, function_cache = _make_ffi_library(self, name, flags)
File "C:\Users\Kshitij\AppData\Local\Programs\Python\Python35\lib\site-
packages\cffi\api.py", line 786, in _make_ffi_library
backendlib = _load_backend_lib(backend, libname, flags)
File "C:\Users\Kshitij\AppData\Local\Programs\Python\Python35\lib\site-
packages\cffi\api.py", line 781, in _load_backend_lib
raise OSError(msg)
OSError: cannot load library libcairo.so.2: error 0x7e. Additionally,
ctypes.util.find_library() did not manage to locate a library called
'libcairo.so.2'
This might be because ofcairocffi as it is also giving the following error on import:
import cairocffi
File "C:\Users\Kshitij\AppData\Local\Programs\Python\Python35\lib\site-
packages\cairocffi\__init__.py", line 41, in <module>
cairo = dlopen(ffi, 'cairo', 'cairo-2')
File "C:\Users\Kshitij\AppData\Local\Programs\Python\Python35\lib\site-
packages\cairocffi\__init__.py", line 38, in dlopen
raise OSError("dlopen() failed to load a library: %s" % ' / '.join(names))
OSError: dlopen() failed to load a library: cairo / cairo-2
I have a 64-bit windows based architecture with python 3.5 and have installed cairocffi-0.8.0 which installed without a problem.

I solved this problem using UniConverter2.0.
My environments is
Python 3.7
Windows 10 x64
Install uniconvertor-2.0rc4-win64_headless.msi,
Find the "dll" sub-directory under the UniConverter installation path.(In my case, C:\Program Files\UniConvertor-2.0rc4\dlls)
Add this "dll" path to the system path.
Close VSCode(or other editor) and reopen the project.
Try to run your code again.
Enjoy!

Related

Module 'Tabula' not found in python spyder

I tried to run this code:
from tabula import read_pdf
df = read_pdf("../pdf/Documentacao.pdf")
print(df)
And got this:
runfile('C:/Users/Henri/git/Git/PDS1/dev/lib/planilhas01.py', wdir='C:/Users/Henri/git/Git/PDS1/dev/lib')
Traceback (most recent call last):
File "<ipython-input-4-e12a8a26bbfa>", line 1, in <module>
runfile('C:/Users/Henri/git/Git/PDS1/dev/lib/planilhas01.py', wdir='C:/Users/Henri/git/Git/PDS1/dev/lib')
File "C:\Users\Henri\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile
execfile(filename, namespace)
File "C:\Users\Henri\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/Henri/git/Git/PDS1/dev/lib/planilhas01.py", line 1, in <module>
from tabula import read_pdf
ModuleNotFoundError: No module named 'tabula'
This is what my anaconda says:
(base) C:\Users\Henri>pip install tabula-py
Requirement already satisfied: tabula-py in c:\users\henri\miniconda3\lib\site-packages (1.4.1)
Requirement already satisfied: pandas in c:\users\henri\miniconda3\lib\site-packages (from tabula-py) (0.25.1)
Requirement already satisfied: distro in c:\users\henri\miniconda3\lib\site-packages (from tabula-py) (1.4.0)
Requirement already satisfied: numpy in c:\users\henri\miniconda3\lib\site-packages (from tabula-py) (1.17.2)
Requirement already satisfied: python-dateutil>=2.6.1 in c:\users\henri\miniconda3\lib\site-packages (from pandas->tabula-py) (2.8.0)
Requirement already satisfied: pytz>=2017.2 in c:\users\henri\miniconda3\lib\site-packages (from pandas->tabula-py) (2019.3)
Requirement already satisfied: six>=1.5 in c:\users\henri\miniconda3\lib\site-packages (from python-dateutil>=2.6.1->pandas->tabula-py) (1.12.0)
I think is something about directories, but what ??
(base) C:\Users\Henri>pip install tabula-py
Requirement already satisfied: tabula-py in c:\users\henri\miniconda3\lib\site-packages (1.4.1)
I think is installed, just you need to make sure which Python environment yre installing it because maybe is installed in python3 directory, not python2.

Issue with Installing Tensorflow

I have an issue with the installation of Tensorflow
I just completed installing Tensorflow with
$ pip install --user --upgrade tensorflow
and these are the last lines I get after this installation
Successfully built absl-py gast
Installing collected packages: wheel, six, grpcio, absl-py, numpy, gast, astor, tensorflow, h5py, werkzeug, se tuptools
Successfully installed absl-py-0.7.1 astor-0.8.0 gast-0.2.2 grpcio-1.21.1 h5py-2.9.0 numpy-1.16.4 setuptools-4 1.0.1 six-1.12.0 tensorflow-1.13.1 werkzeug-0.15.4 wheel-0.33.4 `````
and then when I enter the following command:
$ pip install --upgrade tensorflow
I do get a bunch of requirement already up-to-date as per the below .
Requirement already up-to-date: tensorflow in c:\users\xxx\appdata\roaming\python\python36\site-packages
Requirement already up-to-date: tensorflow-estimator<1.14.0rc0,>=1.13.0 in c:\programdata\anaconda3\lib\site-p ackages (from tensorflow)
Requirement already up-to-date: numpy>=1.13.3 in c:\users\xxx\appdata\roaming\python\python36\site-packag es (from tensorflow)
Requirement already up-to-date: gast>=0.2.0 in c:\users\xxx\appdata\roaming\python\python36\site-packages (from tensorflow)
Requirement already up-to-date: six>=1.10.0 in c:\users\xxx\appdata\roaming\python\python36\site-packages (from tensorflow)
Requirement already up-to-date: keras-preprocessing>=1.0.5 in c:\programdata\anaconda3\lib\site-packages (from tensorflow)
Requirement already up-to-date: tensorboard<1.14.0,>=1.13.0 in c:\programdata\anaconda3\lib\site-packages (fro m tensorflow)
Requirement already up-to-date: astor>=0.6.0 in c:\users\xxxx\appdata\roaming\python\python36\site-package s (from tensorflow)
Requirement already up-to-date: termcolor>=1.1.0 in c:\programdata\anaconda3\lib\site-packages (from tensorflo w)
Requirement already up-to-date: wheel>=0.26 in c:\users\xxxx\appdata\roaming\python\python36\site-packages (from tensorflow)
Requirement already up-to-date: keras-applications>=1.0.6 in c:\programdata\anaconda3\lib\site-packages (from tensorflow)
Requirement already up-to-date: grpcio>=1.8.6 in c:\users\xxxx\appdata\roaming\python\python36\site-packag es (from tensorflow)
Requirement already up-to-date: protobuf>=3.6.1 in c:\programdata\anaconda3\lib\site-packages (from tensorflow )
Which I interpret as everything is installed and upgraded ( am I wrong here ? )
Now my issue is that when I try to import Tensorflow let say in Jupyter notebook , I get the following error message
ImportError: Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "C:\ProgramData\Anaconda3\lib\imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "C:\ProgramData\Anaconda3\lib\imp.py", line 343, in load_dynamic
return _load(spec)
ImportError: DLL load failed: The specified module could not be found.
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/errors
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
Any idea what could be the reason and what i need to change to get tensorflow up and running ?
Thanks guys in advance for any help with the above issue .
I've solved this problem by downgrading tensorflow to version 2.0 using this command:
pip install tensorflow==2.0
and then use like this :
from tensorflow.keras.applications import vgg19
from tensorflow.keras.models import load_model
I hope it helps.

Cannot use pyinstaller because of cffi.api.CDefError

Can anyone have a look what goes wrong with my pyinstaller?
I also tried to convert a .py file to .exe file, but the same error was generated
Update. 12/15. BTW, I have installed both python 2.7 and python 3 on my computer, would that be the problem?
However, I have tried install pyinstaller under C:\Python27\Scripts to try to avoid the conflict between 2 pythons. (I am not sure if this could still cause the problem but I just try to list all the details I know for the question.)
New update. 12/16. I have tried to move my target file (to convert) to the script folder, where pyinstaller is installed, the file will be converted successfully. But the script folder will be messed up because multiple folders and files will be generated.
I have added the problem that generated from cmd below :)
C:\Python27\Scripts>pip install pyinstaller
Collecting pyinstaller
Requirement already satisfied: pefile>=2017.8.1 in c:\python27\lib\site-packages (from pyinstaller) (2018.8.8)
Requirement already satisfied: pywin32-ctypes in c:\python27\lib\site-packages (from pyinstaller) (0.2.0)
Requirement already satisfied: setuptools in c:\python27\lib\site-packages (from pyinstaller) (28.8.0)
Requirement already satisfied: altgraph in c:\python27\lib\site-packages (from pyinstaller) (0.16.1)
Requirement already satisfied: macholib>=1.8 in c:\python27\lib\site-packages (from pyinstaller) (1.11)
Requirement already satisfied: dis3 in c:\python27\lib\site-packages (from pyinstaller) (0.1.2)
Requirement already satisfied: future in c:\python27\lib\site-packages (from pefile>=2017.8.1->pyinstaller) (0.17.1)
Installing collected packages: pyinstaller
Successfully installed pyinstaller-3.4
C:\Python27\Scripts>pyinstaller
Traceback (most recent call last):
File "c:\python27\lib\runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "c:\python27\lib\runpy.py", line 72, in _run_code
exec code in run_globals
File "C:\Python27\Scripts\pyinstaller.exe\__main__.py", line 5, in <module>
File "c:\python27\lib\site-packages\PyInstaller\__init__.py", line 16, in <module>
from . import compat
File "c:\python27\lib\site-packages\PyInstaller\compat.py", line 212, in <module>
from win32ctypes.pywin32 import pywintypes # noqa: F401
File "c:\python27\lib\site-packages\win32ctypes\pywin32\__init__.py", line 11, in <module>
from win32ctypes.pywin32 import win32api
File "c:\python27\lib\site-packages\win32ctypes\pywin32\win32api.py", line 12, in <module>
from win32ctypes.core import (
File "c:\python27\lib\site-packages\win32ctypes\core\__init__.py", line 36, in load_module
module = importlib.import_module(self.redirect_module)
File "c:\python27\lib\importlib\__init__.py", line 37, in import_module
__import__(name)
File "c:\python27\lib\site-packages\win32ctypes\core\cffi\_dll.py", line 19, in <module>
""")
File "c:\python27\lib\site-packages\cffi\api.py", line 107, in cdef
self._parser.parse(csource, override=override, packed=packed)
File "c:\python27\lib\site-packages\cffi\cparser.py", line 167, in parse
self._internal_parse(csource)
File "c:\python27\lib\site-packages\cffi\cparser.py", line 173, in _internal_parse
ast, macros, csource = self._parse(csource)
File "c:\python27\lib\site-packages\cffi\cparser.py", line 130, in _parse
self.convert_pycparser_error(e, csource)
File "c:\python27\lib\site-packages\cffi\cparser.py", line 159, in convert_pycparser_error
raise api.CDefError(msg)
cffi.api.CDefError: cannot parse "HMODULE WINAPI LoadLibraryExW(LPCTSTR lpFileName, HANDLE hFile, DWORD dwFlags);"
:16:16: before: LoadLibraryExW
Try to upgrade the cffi by using below command:
pip install --upgrade cffi

AttributeError: module 'pkg_resources' has no attribute 'safe_name' django channels redis

I'm trying to install channels_redis and got following error.
pip install channels_redis
Collecting channels_redis
Using cached https://files.pythonhosted.org/packages/63/ae/adea3b1913aebb84ec6b6f3c30ba81b8bef79f99b51c7240810284152df4/channels_redis-2.2.1-py2.py3-none-any.whl
Requirement already satisfied: channels~=2.0 in ./env/lib/python3.6/site-packages (from channels_redis) (2.1.1)
Requirement already satisfied: asgiref~=2.1 in ./env/lib/python3.6/site-packages (from channels_redis) (2.3.2)
Collecting msgpack~=0.5.0 (from channels_redis)
Using cached https://files.pythonhosted.org/packages/22/4e/dcf124fd97e5f5611123d6ad9f40ffd6eb979d1efdc1049e28a795672fcd/msgpack-0.5.6-cp36-cp36m-manylinux1_x86_64.whl
Collecting aioredis~=1.0 (from channels_redis)
Using cached https://files.pythonhosted.org/packages/83/4f/fb41fd054522b2f15cf8c9a0b119096a3f2e4db41c9cd7c114da8de742b1/aioredis-1.1.0-py3-none-any.whl
Requirement already satisfied: daphne~=2.1 in ./env/lib/python3.6/site-packages (from channels~=2.0->channels_redis) (2.1.2)
Requirement already satisfied: Django>=1.11 in ./env/lib/python3.6/site-packages (from channels~=2.0->channels_redis) (2.0.6)
Requirement already satisfied: async-timeout<4.0,>=2.0 in ./env/lib/python3.6/site-packages (from asgiref~=2.1->channels_redis) (2.0.1)
Collecting hiredis (from aioredis~=1.0->channels_redis)
Using cached https://files.pythonhosted.org/packages/1b/98/4766d85124b785ff1989ee1c79631a1b6ecfcb444ff39999a87877b2027e/hiredis-0.2.0.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-aqp5bl02/hiredis/setup.py", line 81, in <module>
'Topic :: Software Development',
File "/usr/lib/python3.6/distutils/core.py", line 108, in setup
_setup_distribution = dist = klass(attrs)
File "/home/danil/projects/python/collann/env/lib/python3.6/site-packages/setuptools/dist.py", line 364, in __init__
self.patch_missing_pkg_info(attrs)
File "/home/danil/projects/python/collann/env/lib/python3.6/site-packages/setuptools/dist.py", line 346, in patch_missing_pkg_info
key = pkg_resources.safe_name(str(attrs['name'])).lower()
AttributeError: module 'pkg_resources' has no attribute 'safe_name'
---------------
This answer doesn't work for me
pip --version
pip 10.0.1 from project/env/lib/python3.6/site-packages/pip (python 3.6)
only full removing of environment helped.
deactivate
rm -rf env/
virtualenv env -p python3
. env/bin/activate
pip install -r requirements.txt
pip install channels_redis

Unable to install python module paramiko successfully on mac

1)Installed paramiko on mac, but getting some different errors.
pip install paramiko
Requirement already satisfied: paramiko in /Library/Python/2.7/site-packages
Requirement already satisfied: pynacl>=1.0.1 in /Library/Python/2.7/site-packages (from paramiko)
Requirement already satisfied: pyasn1>=0.1.7 in /Library/Python/2.7/site-packages (from paramiko)
Requirement already satisfied: bcrypt>=3.1.3 in /Library/Python/2.7/site-packages (from paramiko)
Requirement already satisfied: cryptography>=1.1 in /Library/Python/2.7/site-packages (from paramiko)
Requirement already satisfied: six in ./2.7/Extras/lib/python (from pynacl>=1.0.1->paramiko)
Requirement already satisfied: cffi>=1.4.1 in /Library/Python/2.7/site-packages (from pynacl>=1.0.1->paramiko)
Requirement already satisfied: idna>=2.1 in /Library/Python/2.7/site-packages (from cryptography>=1.1->paramiko)
Requirement already satisfied: ipaddress in /Library/Python/2.7/site-packages (from cryptography>=1.1->paramiko)
Requirement already satisfied: asn1crypto>=0.21.0 in /Library/Python/2.7/site-packages (from cryptography>=1.1->paramiko)
Requirement already satisfied: enum34 in /Library/Python/2.7/site-packages (from cryptography>=1.1->paramiko)
Requirement already satisfied: pycparser in /Library/Python/2.7/site-packages (from cffi>=1.4.1->pynacl>=1.0.1->paramiko)
Open the terminal, type python. Now in python prompt, import paramiko
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/paramiko/__init__.py", line 31, in <module>
from paramiko.transport import SecurityOptions, Transport
File "/Library/Python/2.7/site-packages/paramiko/transport.py", line 57, in <module>
from paramiko.ed25519key import Ed25519Key
File "/Library/Python/2.7/site-packages/paramiko/ed25519key.py", line 22, in <module>
import nacl.signing
File "/Library/Python/2.7/site-packages/nacl/signing.py", line 19, in <module>
import nacl.bindings
File "/Library/Python/2.7/site-packages/nacl/bindings/__init__.py", line 17, in <module>
from nacl.bindings.crypto_box import (
File "/Library/Python/2.7/site-packages/nacl/bindings/crypto_box.py", line 18, in <module>
from nacl._sodium import ffi, lib
ImportError: dlopen(/Library/Python/2.7/site-packages/nacl/_sodium.so, 2): Symbol not found: _crypto_box
Referenced from: /Library/Python/2.7/site-packages/nacl/_sodium.so
Expected in: flat namespace
in /Library/Python/2.7/site-packages/nacl/_sodium.so
2) After trying some different options, tried sudo -H pip install paramiko and import paramiko from python prompt didn't result into any error.
But when executed paramiko login snippet, resulted into an error Client.py and transport.py & module error certificate transparency

Categories

Resources