Python Forum
Installing pygal under Ubuntu 18.04
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Installing pygal under Ubuntu 18.04
#11
I installed:
"python3-cairosvg", "lxml", "tinycss" and "cssselect" without any problem:

Output:
yonnel@yonnel-Z97X-Gaming-7:~$ sudo apt install python3-cairosvg [sudo] Mot de passe de yonnel : Lecture des listes de paquets... Fait Construction de l'arbre des dépendances Lecture des informations d'état... Fait Les paquets suivants ont été installés automatiquement et ne sont plus nécessaires : kde-cli-tools kde-cli-tools-data libfakekey0 libkf5kcmutils-data libkf5kcmutils5 libkf5kiofilewidgets5 libkf5su-bin libkf5su-data libkf5su5 libqt5quickcontrols2-5 libqt5quicktemplates2-5 libqt5quickwidgets5 qml-module-qtquick-controls2 qml-module-qtquick-templates2 sshfs Veuillez utiliser « sudo apt autoremove » pour les supprimer. Les paquets supplémentaires suivants seront installés : python3-bs4 python3-cairocffi python3-cffi python3-html5lib python3-lxml python3-ply python3-pycparser python3-webencodings python3-xcffib Paquets suggérés : python-cairocffi-doc python3-dev python3-genshi python3-lxml-dbg python-lxml-doc python-ply-doc Les NOUVEAUX paquets suivants seront installés : python3-bs4 python3-cairocffi python3-cairosvg python3-cffi python3-html5lib python3-lxml python3-ply python3-pycparser python3-webencodings python3-xcffib 0 mis à jour, 10 nouvellement installés, 0 à enlever et 16 non mis à jour. Il est nécessaire de prendre 1,583 ko dans les archives. Après cette opération, 7,607 ko d'espace disque supplémentaires seront utilisés. Souhaitez-vous continuer ? [O/n] o Réception de:1 http://ni.archive.ubuntu.com/ubuntu bionic/main amd64 python3-bs4 all 4.6.0-1 [67.8 kB] Réception de:2 http://ni.archive.ubuntu.com/ubuntu bionic/main amd64 python3-ply all 3.11-1 [46.6 kB] Réception de:3 http://ni.archive.ubuntu.com/ubuntu bionic/universe amd64 python3-pycparser all 2.18-2 [67.7 kB] Réception de:4 http://ni.archive.ubuntu.com/ubuntu bionic/universe amd64 python3-cffi all 1.11.5-1 [67.4 kB] Réception de:5 http://ni.archive.ubuntu.com/ubuntu bionic/universe amd64 python3-cairocffi all 0.8.0-0ubuntu2 [62.7 kB] Réception de:6 http://ni.archive.ubuntu.com/ubuntu bionic/main amd64 python3-lxml amd64 4.2.1-1 [1,090 kB] Réception de:7 http://ni.archive.ubuntu.com/ubuntu bionic/universe amd64 python3-cairosvg all 1.0.20-1 [27.1 kB] Réception de:8 http://ni.archive.ubuntu.com/ubuntu bionic/main amd64 python3-webencodings all 0.5-2 [10.4 kB] Réception de:9 http://ni.archive.ubuntu.com/ubuntu bionic/main amd64 python3-html5lib all 0.999999999-1 [81.9 kB] Réception de:10 http://ni.archive.ubuntu.com/ubuntu bionic/universe amd64 python3-xcffib amd64 0.5.1-1build3 [61.6 kB] 1,583 ko réceptionnés en 3s (571 ko/s) Sélection du paquet python3-bs4 précédemment désélectionné. (Lecture de la base de données... 199512 fichiers et répertoires déjà installés.) Préparation du dépaquetage de .../0-python3-bs4_4.6.0-1_all.deb ... Dépaquetage de python3-bs4 (4.6.0-1) ... Sélection du paquet python3-ply précédemment désélectionné. Préparation du dépaquetage de .../1-python3-ply_3.11-1_all.deb ... Dépaquetage de python3-ply (3.11-1) ... Sélection du paquet python3-pycparser précédemment désélectionné. Préparation du dépaquetage de .../2-python3-pycparser_2.18-2_all.deb ... Dépaquetage de python3-pycparser (2.18-2) ... Sélection du paquet python3-cffi précédemment désélectionné. Préparation du dépaquetage de .../3-python3-cffi_1.11.5-1_all.deb ... Dépaquetage de python3-cffi (1.11.5-1) ... Sélection du paquet python3-cairocffi précédemment désélectionné. Préparation du dépaquetage de .../4-python3-cairocffi_0.8.0-0ubuntu2_all.deb ... Dépaquetage de python3-cairocffi (0.8.0-0ubuntu2) ... Sélection du paquet python3-lxml:amd64 précédemment désélectionné. Préparation du dépaquetage de .../5-python3-lxml_4.2.1-1_amd64.deb ... Dépaquetage de python3-lxml:amd64 (4.2.1-1) ... Sélection du paquet python3-cairosvg précédemment désélectionné. Préparation du dépaquetage de .../6-python3-cairosvg_1.0.20-1_all.deb ... Dépaquetage de python3-cairosvg (1.0.20-1) ... Sélection du paquet python3-webencodings précédemment désélectionné. Préparation du dépaquetage de .../7-python3-webencodings_0.5-2_all.deb ... Dépaquetage de python3-webencodings (0.5-2) ... Sélection du paquet python3-html5lib précédemment désélectionné. Préparation du dépaquetage de .../8-python3-html5lib_0.999999999-1_all.deb ... Dépaquetage de python3-html5lib (0.999999999-1) ... Sélection du paquet python3-xcffib précédemment désélectionné. Préparation du dépaquetage de .../9-python3-xcffib_0.5.1-1build3_amd64.deb ... Dépaquetage de python3-xcffib (0.5.1-1build3) ... Paramétrage de python3-webencodings (0.5-2) ... Paramétrage de python3-lxml:amd64 (4.2.1-1) ... Paramétrage de python3-bs4 (4.6.0-1) ... Paramétrage de python3-html5lib (0.999999999-1) ... Paramétrage de python3-xcffib (0.5.1-1build3) ... Traitement des actions différées (« triggers ») pour man-db (2.8.3-2) ... Paramétrage de python3-ply (3.11-1) ... Paramétrage de python3-pycparser (2.18-2) ... Paramétrage de python3-cffi (1.11.5-1) ... Paramétrage de python3-cairocffi (0.8.0-0ubuntu2) ... Paramétrage de python3-cairosvg (1.0.20-1) ... yonnel@yonnel-Z97X-Gaming-7:~$ pip3 install --user lxml La commande « pip3 » n'a pas été trouvée, mais peut être installée avec : sudo apt install python3-pip yonnel@yonnel-Z97X-Gaming-7:~$ sudo apt install python3-pip Lecture des listes de paquets... Fait Construction de l'arbre des dépendances Lecture des informations d'état... Fait Les paquets suivants ont été installés automatiquement et ne sont plus nécessaires : kde-cli-tools kde-cli-tools-data libfakekey0 libkf5kcmutils-data libkf5kcmutils5 libkf5kiofilewidgets5 libkf5su-bin libkf5su-data libkf5su5 libqt5quickcontrols2-5 libqt5quicktemplates2-5 libqt5quickwidgets5 qml-module-qtquick-controls2 qml-module-qtquick-templates2 sshfs Veuillez utiliser « sudo apt autoremove » pour les supprimer. Les paquets supplémentaires suivants seront installés : dh-python libpython3-dev libpython3.6-dev python3-dev python3-distutils python3-lib2to3 python3-setuptools python3-wheel python3.6-dev Paquets suggérés : python-setuptools-doc Les NOUVEAUX paquets suivants seront installés : dh-python libpython3-dev libpython3.6-dev python3-dev python3-distutils python3-lib2to3 python3-pip python3-setuptools python3-wheel python3.6-dev 0 mis à jour, 10 nouvellement installés, 0 à enlever et 16 non mis à jour. Il est nécessaire de prendre 3,712 ko dans les archives. Après cette opération, 21.1 Mo d'espace disque supplémentaires seront utilisés. Souhaitez-vous continuer ? [O/n] o Réception de:1 http://ni.archive.ubuntu.com/ubuntu bionic/main amd64 python3-lib2to3 all 3.6.5-3 [76.6 kB] Réception de:2 http://ni.archive.ubuntu.com/ubuntu bionic/main amd64 python3-distutils all 3.6.5-3 [141 kB] Réception de:3 http://ni.archive.ubuntu.com/ubuntu bionic/main amd64 dh-python all 3.20180325ubuntu2 [89.2 kB] Réception de:4 http://ni.archive.ubuntu.com/ubuntu bionic/main amd64 libpython3.6-dev amd64 3.6.5-3 [2,487 kB] Réception de:5 http://ni.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libpython3-dev amd64 3.6.5-3ubuntu1 [7,300 B] Réception de:6 http://ni.archive.ubuntu.com/ubuntu bionic/main amd64 python3.6-dev amd64 3.6.5-3 [512 kB] Réception de:7 http://ni.archive.ubuntu.com/ubuntu bionic-updates/main amd64 python3-dev amd64 3.6.5-3ubuntu1 [1,292 B] Réception de:8 http://ni.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 python3-pip all 9.0.1-2.3~ubuntu1 [114 kB] Réception de:9 http://ni.archive.ubuntu.com/ubuntu bionic/main amd64 python3-setuptools all 39.0.1-2 [248 kB] Réception de:10 http://ni.archive.ubuntu.com/ubuntu bionic/universe amd64 python3-wheel all 0.30.0-0.2 [36.5 kB] 3,712 ko réceptionnés en 5s (691 ko/s) Sélection du paquet python3-lib2to3 précédemment désélectionné. (Lecture de la base de données... 199961 fichiers et répertoires déjà installés.) Préparation du dépaquetage de .../0-python3-lib2to3_3.6.5-3_all.deb ... Dépaquetage de python3-lib2to3 (3.6.5-3) ... Sélection du paquet python3-distutils précédemment désélectionné. Préparation du dépaquetage de .../1-python3-distutils_3.6.5-3_all.deb ... Dépaquetage de python3-distutils (3.6.5-3) ... Sélection du paquet dh-python précédemment désélectionné. Préparation du dépaquetage de .../2-dh-python_3.20180325ubuntu2_all.deb ... Dépaquetage de dh-python (3.20180325ubuntu2) ... Sélection du paquet libpython3.6-dev:amd64 précédemment désélectionné. Préparation du dépaquetage de .../3-libpython3.6-dev_3.6.5-3_amd64.deb ... Dépaquetage de libpython3.6-dev:amd64 (3.6.5-3) ... Sélection du paquet libpython3-dev:amd64 précédemment désélectionné. Préparation du dépaquetage de .../4-libpython3-dev_3.6.5-3ubuntu1_amd64.deb ... Dépaquetage de libpython3-dev:amd64 (3.6.5-3ubuntu1) ... Sélection du paquet python3.6-dev précédemment désélectionné. Préparation du dépaquetage de .../5-python3.6-dev_3.6.5-3_amd64.deb ... Dépaquetage de python3.6-dev (3.6.5-3) ... Sélection du paquet python3-dev précédemment désélectionné. Préparation du dépaquetage de .../6-python3-dev_3.6.5-3ubuntu1_amd64.deb ... Dépaquetage de python3-dev (3.6.5-3ubuntu1) ... Sélection du paquet python3-pip précédemment désélectionné. Préparation du dépaquetage de .../7-python3-pip_9.0.1-2.3~ubuntu1_all.deb ... Dépaquetage de python3-pip (9.0.1-2.3~ubuntu1) ... Sélection du paquet python3-setuptools précédemment désélectionné. Préparation du dépaquetage de .../8-python3-setuptools_39.0.1-2_all.deb ... Dépaquetage de python3-setuptools (39.0.1-2) ... Sélection du paquet python3-wheel précédemment désélectionné. Préparation du dépaquetage de .../9-python3-wheel_0.30.0-0.2_all.deb ... Dépaquetage de python3-wheel (0.30.0-0.2) ... Paramétrage de python3-wheel (0.30.0-0.2) ... Paramétrage de libpython3.6-dev:amd64 (3.6.5-3) ... Traitement des actions différées (« triggers ») pour man-db (2.8.3-2) ... Paramétrage de python3.6-dev (3.6.5-3) ... Paramétrage de python3-lib2to3 (3.6.5-3) ... Paramétrage de python3-distutils (3.6.5-3) ... Paramétrage de libpython3-dev:amd64 (3.6.5-3ubuntu1) ... Paramétrage de python3-pip (9.0.1-2.3~ubuntu1) ... Paramétrage de python3-setuptools (39.0.1-2) ... Paramétrage de dh-python (3.20180325ubuntu2) ... Paramétrage de python3-dev (3.6.5-3ubuntu1) ... yonnel@yonnel-Z97X-Gaming-7:~$ pip3 install --user lxml Collecting lxml Downloading https://files.pythonhosted.org/packages/d1/81/5a3e70c8adc20fb295a2f4c9fdf09af8295c7a00ccec6ee3d31084cbf272/lxml-4.2.3-cp36-cp36m-manylinux1_x86_64.whl (5.9MB) 100% |████████████████████████████████| 5.9MB 249kB/s Installing collected packages: lxml Successfully installed lxml-4.2.3 yonnel@yonnel-Z97X-Gaming-7:~$ pip3 install --user tinycss Collecting tinycss Downloading https://files.pythonhosted.org/packages/05/59/af583fff6236c7d2f94f8175c40ce501dcefb8d1b42e4bb7a2622dff689e/tinycss-0.4.tar.gz (87kB) 100% |████████████████████████████████| 92kB 544kB/s Building wheels for collected packages: tinycss Running setup.py bdist_wheel for tinycss ... done Stored in directory: /home/yonnel/.cache/pip/wheels/1b/26/08/7390b2e6d5eb3403ef35647f09576459ca567d00ac725307d5 Successfully built tinycss Installing collected packages: tinycss Successfully installed tinycss-0.4 yonnel@yonnel-Z97X-Gaming-7:~$ pip3 install --user cssselect Collecting cssselect Downloading https://files.pythonhosted.org/packages/7b/44/25b7283e50585f0b4156960691d951b05d061abf4a714078393e51929b30/cssselect-1.0.3-py2.py3-none-any.whl Installing collected packages: cssselect Successfully installed cssselect-1.0.3 yonnel@yonnel-Z97X-Gaming-7:~$
I replaced the line
pie_chart.render()
with
pie_chart.render_png('foo.png')
And I replaced "Bar" with "Pie".

# Installer pygal d'abord

import pygal

# http://blog.codeeval.com/codeevalblog/2014
# most popular coding languages according to @codeeval
# python for the win! w00t!

data = [
  ["Python", 30.3],
  ["Java", 22.2],
  ["C++", 13],
  ["Ruby", 10.6],
  ["Javascript", 5.2],
  ["C#", 5],
  ["C", 4.1],
  ["PHP", 3.3],
  ["Perl", 1.6],
  ["Go", 1.5],
  ["Haskell", 1.2],
  ["Scala", 1],
  ["Objective-C", 0.4],
  ["Clojure", 0.2],
  ["Bash", 0.1],
  ["Lua", 0.04],
  ["TCL", 0.03]
]
    

# Make a Pygal chart
pie_chart = pygal.Pie()

# add a title
pie_chart.title = "CodeEval Most Popular Coding Languages of 2014"

# add the data
for label, data_points in data:
    pie_chart.add(label, data_points)

# Render the chart    
pie_chart.render_png('foo.png')
When I do that :
Output:
python3 foobarbaz.py && xdg-open foo.png
I get that:
Error:
yonnel@yonnel-Z97X-Gaming-7:/media/yonnel/SSD-1T/yonnel/Dropbox/00- DIY/11- Python/02- Essais/Essais Pygal$ python3 foobarbaz.py && xdg-open foo.png Traceback (most recent call last): File "foobarbaz.py", line 41, in <module> pie_chart.render_png('foo.png') File "/usr/lib/python3/dist-packages/pygal/graph/base.py", line 73, in __getattribute__ return super(BaseGraph, self).__getattribute__(name) AttributeError: 'Pie' object has no attribute 'render_png'
I looked for a file foo.png specially associated with Python, but I did not find anything.
I replaced it with a .png (python's logo) to see, and running the program only displays the .png file, but not the graph...

I thought it was easy to make a graph... Sad
Reply
#12
Sorry, it is render_to_png instead of render_png
Quote:I thought it was easy to make a graph...
It is easy. You only need to install the required libraries and learn a bit of their APIs.
Reply
#13
You can click on >code on top line forum.
Then push Run button and then you get the chart Wink

As mention is render_to_png
You need CairoSVG to write directly to png.
Reply
#14
Hi

I put "render_to_png" instead of "render_png"
I installed CairoSVG :
https://cairosvg.org/ --> pip3 install cairosvg

Output:
yonnel@yonnel-Z97X-Gaming-7:~$ pip3 install cairosvg Collecting cairosvg Downloading https://files.pythonhosted.org/packages/db/8c/eb114f08b0db43ec05c946e33d1a180819f34c185f05223407ac9a6fce90/CairoSVG-2.1.3-py3-none-any.whl (101kB) 100% |████████████████████████████████| 102kB 539kB/s Collecting defusedxml (from cairosvg) Downloading https://files.pythonhosted.org/packages/87/1c/17f3e3935a913dfe2a5ca85fa5ccbef366bfd82eb318b1f75dadbf0affca/defusedxml-0.5.0-py2.py3-none-any.whl Collecting cairocffi (from cairosvg) Downloading https://files.pythonhosted.org/packages/7a/2f/78179fea3413322fd20be407897738e5569e876e7cb6e4647a79b1ffd8dd/cairocffi-0.8.1.tar.gz (79kB) 100% |████████████████████████████████| 81kB 879kB/s Collecting tinycss2 (from cairosvg) Downloading https://files.pythonhosted.org/packages/88/95/0ec73db7fc638ec000e662936ffe1a4e1eaa22f2861c8de18b1597c42584/tinycss2-0.6.1-py2.py3-none-any.whl (61kB) 100% |████████████████████████████████| 71kB 863kB/s Collecting pillow (from cairosvg) Downloading https://files.pythonhosted.org/packages/d1/24/f53ff6b61b3d728b90934bddb4f03f8ab584a7f49299bf3bde56e2952612/Pillow-5.2.0-cp36-cp36m-manylinux1_x86_64.whl (2.0MB) 100% |████████████████████████████████| 2.0MB 471kB/s Collecting cssselect2 (from cairosvg) Downloading https://files.pythonhosted.org/packages/12/e2/91fcd4cd32545beec6e11628d64d3e20f11b5a95dd1ccf3216fd69f176b7/cssselect2-0.2.1-py2.py3-none-any.whl Collecting cffi>=1.1.0 (from cairocffi->cairosvg) Downloading https://files.pythonhosted.org/packages/6d/c0/47db8f624f3e4e2f3f27be03a93379d1ba16a1450a7b1aacfa0366e2c0dd/cffi-1.11.5-cp36-cp36m-manylinux1_x86_64.whl (421kB) 100% |████████████████████████████████| 430kB 837kB/s Collecting webencodings>=0.4 (from tinycss2->cairosvg) Downloading https://files.pythonhosted.org/packages/f4/24/2a3e3df732393fed8b3ebf2ec078f05546de641fe1b667ee316ec1dcf3b7/webencodings-0.5.1-py2.py3-none-any.whl Collecting pycparser (from cffi>=1.1.0->cairocffi->cairosvg) Downloading https://files.pythonhosted.org/packages/8c/2d/aad7f16146f4197a11f8e91fb81df177adcc2073d36a17b1491fd09df6ed/pycparser-2.18.tar.gz (245kB) 100% |████████████████████████████████| 256kB 880kB/s Building wheels for collected packages: cairocffi, pycparser Running setup.py bdist_wheel for cairocffi ... done Stored in directory: /home/yonnel/.cache/pip/wheels/1f/f5/ea/087a29f65225d037e27e329c7e7d7807cc49be81a54418e3f4 Running setup.py bdist_wheel for pycparser ... done Stored in directory: /home/yonnel/.cache/pip/wheels/c0/a1/27/5ba234bd77ea5a290cbf6d675259ec52293193467a12ef1f46 Successfully built cairocffi pycparser Installing collected packages: defusedxml, pycparser, cffi, cairocffi, webencodings, tinycss2, pillow, cssselect2, cairosvg Successfully installed cairocffi-0.8.1 cairosvg-2.1.3 cffi-1.11.5 cssselect2-0.2.1 defusedxml-0.5.0 pillow-5.2.0 pycparser-2.18 tinycss2-0.6.1 webencodings-0.5.1
The complet scrip is:

import pygal
 
# http://blog.codeeval.com/codeevalblog/2014
# most popular coding languages according to @codeeval
# python for the win! w00t!
 
data = [
  ["Python", 30.3],
  ["Java", 22.2],
  ["C++", 13],
  ["Ruby", 10.6],
  ["Javascript", 5.2],
  ["C#", 5],
  ["C", 4.1],
  ["PHP", 3.3],
  ["Perl", 1.6],
  ["Go", 1.5],
  ["Haskell", 1.2],
  ["Scala", 1],
  ["Objective-C", 0.4],
  ["Clojure", 0.2],
  ["Bash", 0.1],
  ["Lua", 0.04],
  ["TCL", 0.03]
]
# Make a Pygal chart
pie_chart = pygal.Pie()
 
# add a title
pie_chart.title = "CodeEval Most Popular Coding Languages of 2014"
 
# add the data
for label, data_points in data:
    pie_chart.add(label, data_points)
 
# Render the chart    
pie_chart.render_to_png('foo.png')
But now I have a new error message:

Error:
Python 3.7.0b3 (default, Mar 30 2018, 04:35:22) [GCC 7.3.0] on linux Type "copyright", "credits" or "license()" for more information. >>> RESTART: /media/yonnel/SSD-1T/yonnel/Dropbox/00- DIY/11- Python/02- Essais/Essais Pygal/foobarbaz.py Traceback (most recent call last): File "/usr/lib/python3/dist-packages/cairosvg/surface/__init__.py", line 25, in <module> import cairocffi as cairo File "/usr/lib/python3/dist-packages/cairocffi/__init__.py", line 18, in <module> from ._ffi import ffi File "/usr/lib/python3/dist-packages/cairocffi/_ffi.py", line 2, in <module> import _cffi_backend ModuleNotFoundError: No module named '_cffi_backend' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/media/yonnel/SSD-1T/yonnel/Dropbox/00- DIY/11- Python/02- Essais/Essais Pygal/foobarbaz.py", line 37, in <module> pie_chart.render_to_png('foo.png') File "/usr/lib/python3/dist-packages/pygal/graph/public.py", line 118, in render_to_png import cairosvg File "/usr/lib/python3/dist-packages/cairosvg/__init__.py", line 27, in <module> from . import surface File "/usr/lib/python3/dist-packages/cairosvg/surface/__init__.py", line 30, in <module> import cairo # pycairo File "/usr/lib/python3/dist-packages/cairo/__init__.py", line 1, in <module> from ._cairo import * # noqa: F401,F403 ModuleNotFoundError: No module named 'cairo._cairo' >>>
Reply
#15
In my version of ubuntu, there are 3 packages python3-cffi, python3-cairocffi, and python3-cffi-backend. You can check this with the command apt search cffi or dpkg -l *cffi*. Install them and retry.
Reply
#16
Hi

Here is the output
Output:
yonnel@yonnel-Z97X-Gaming-7:~$ apt search cffi En train de trier... Fait Recherche en texte intégral... Fait cl-cffi/bionic,bionic 1:0.19.0-1 all The Common Foreign Function Interface for Common Lisp cl-plus-ssl/bionic,bionic 20170630-1build1 all Common Lisp interface to OpenSSL python-cairocffi/bionic,bionic 0.8.0-0ubuntu2 all cffi-based cairo bindings for Python python-cairocffi-doc/bionic,bionic 0.8.0-0ubuntu2 all cffi-based cairo bindings for Python - Documentation python-cffi/bionic,bionic 1.11.5-1 all Foreign Function Interface for Python calling C code python-cffi-backend/bionic,now 1.11.5-1 amd64 [installé, automatique] Foreign Function Interface for Python calling C code - backend python-cffi-backend-dbg/bionic 1.11.5-1 amd64 Foreign Function Interface for Python calling C code (Debug version) python-gphoto2cffi/bionic 0.3~a1-1build1 amd64 GPhoto2 bindings with simpler API python-xcffib/bionic 0.5.1-1build3 amd64 This package is a Python binding for XCB (Python 2) python3-cairocffi/bionic,bionic,now 0.8.0-0ubuntu2 all [installé, automatique] cffi-based cairo bindings for Python (Python3) python3-cffi/bionic,bionic,now 1.11.5-1 all [installé, automatique] Foreign Function Interface for Python 3 calling C code python3-cffi-backend/bionic,now 1.11.5-1 amd64 [installé] Foreign Function Interface for Python 3 calling C code - runtime python3-cffi-backend-dbg/bionic 1.11.5-1 amd64 Foreign Function Interface for Python 3 calling C code (Debug version) python3-gphoto2cffi/bionic 0.3~a1-1build1 amd64 GPhoto2 bindings with simpler API python3-xcffib/bionic,now 0.5.1-1build3 amd64 [installé, automatique] This package is a Python binding for XCB (Python 3) yonnel@yonnel-Z97X-Gaming-7:~$
It's seem's to be ok! Undecided But it don't works...
I'm using a fresh installed Ubuntu 18.04.1
Reply
#17
Did you install the packages?
Output:
sudo apt install python3-cffi python3-cairocffi python3-cffi-backend
Reply
#18
No... It was already installed according to the bash...

I tried to reinstall them:

Output:
yonnel@yonnel-Z97X-Gaming-7:~$ sudo apt install python3-cffi python3-cairocffi python3-cffi-backend [sudo] Mot de passe de yonnel : Lecture des listes de paquets... Fait Construction de l'arbre des dépendances Lecture des informations d'état... Fait python3-cffi-backend est déjà la version la plus récente (1.11.5-1). python3-cairocffi est déjà la version la plus récente (0.8.0-0ubuntu2). python3-cairocffi passé en « installé manuellement ». python3-cffi est déjà la version la plus récente (1.11.5-1). python3-cffi passé en « installé manuellement ». Les paquets suivants ont été installés automatiquement et ne sont plus nécessaires : kde-cli-tools kde-cli-tools-data libfakekey0 libkf5kcmutils-data libkf5kcmutils5 libkf5kiofilewidgets5 libkf5su-bin libkf5su-data libkf5su5 libqt5quickcontrols2-5 libqt5quicktemplates2-5 libqt5quickwidgets5 linux-headers-4.15.0-20 linux-headers-4.15.0-20-generic linux-image-4.15.0-20-generic linux-modules-4.15.0-20-generic linux-modules-extra-4.15.0-20-generic qml-module-qtquick-controls2 qml-module-qtquick-templates2 sshfs Veuillez utiliser « sudo apt autoremove » pour les supprimer. 0 mis à jour, 0 nouvellement installés, 0 à enlever et 10 non mis à jour. yonnel@yonnel-Z97X-Gaming-7:~$
--> 0 updated, 0 newly installed, 0 to remove and 10 not updated.

Why do I have to adapt the python script when it worked perfectly in >code?
Reply
#19
You can try an install from pip (often a more recent version of the modules)
Output:
sudo apt remove python3-cffi sudo python3 -m pip install cffi
(Aug-07-2018, 12:36 PM)ybeco Wrote: Why do I have to adapt the python script when it worked perfectly in >code?

You don't have to adapt the python script, you only need the correct third-party libraries installed on your system.
Reply
#20
I don't understand why there is this message, while it asks me root password...

But it says that "cffi" is OK in python 3.6
Output:
yonnel@yonnel-Z97X-Gaming-7:~$ sudo python3 -m pip install cffi [sudo] Mot de passe de yonnel : The directory '/home/yonnel/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. The directory '/home/yonnel/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. Requirement already satisfied: cffi in ./.local/lib/python3.6/site-packages Requirement already satisfied: pycparser in ./.local/lib/python3.6/site-packages (from cffi) yonnel@yonnel-Z97X-Gaming-7:~$
When I run "foobarbaz.py" with python 3.7 IDLE, I still have the same error message...

But when I run "foobarbaz.py" with python 3.6 in Bash terminal, It's working ! It dont shaw anything, but it makes a "foo.png" file with the chart Smile

--> Is it posible to change the version of Python that the IDLE is runing?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Pygal: Displaying information for each data point KirkmanJ 0 1,855 Jul-29-2019, 01:10 PM
Last Post: KirkmanJ
  Ubuntu: Error installing watson-developer-cloud Python module gio123 3 4,409 Mar-15-2018, 09:39 PM
Last Post: gio123

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020