Python Forum
How to enable Matplotlib within virtual environment?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to enable Matplotlib within virtual environment?
#1
Cross posted from Linux Mint forum. So far I am unable to get Matplotlib to function inside the virtual environment; LMDE 6, AMD64.

Let's suppose there is the file '~/path/file.py', and there is the virtual environment 'vEnv'. The contents of file.py is:

import matplotlib.pyplot as plt
import numpy as np

# Data for plotting
t = np.arange(0.0, 2.0, 0.01)
s = 1 + np.sin(2 * np.pi * t)

fig, ax = plt.subplots()
ax.plot(t, s)

ax.set(xlabel='time (s)', ylabel='voltage (mV)',
       title='About as simple as it gets, folks')
ax.grid()

fig.savefig("test.png")
plt.show()
At Linux terminal there be a command, it gives error output:

Output:
(vEnv) user@host:~$ python3 -i ~/path/file.py
Error:
qt.qpa.plugin: From 6.5.0, xcb-cursor0 or libxcb-cursor0 is needed to load the Qt xcb platform plugin. qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found. This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem. Available platform plugins are: vnc, vkkhrdisplay, wayland, offscreen, minimalegl, eglfs, linuxfb, xcb, minimal, wayland-egl. Aborted (core dumped)
Here is a summary of the virtual environment:

Output:
(vEnv) user@host:~$ python3 -m pip list -v Package Version Location Installer ------------------ ----------- -------------------------------------------- --------- certifi 2024.8.30 /home/user/vEnv/lib/python3.11/site-packages pip charset-normalizer 3.3.2 /home/user/vEnv/lib/python3.11/site-packages pip contourpy 1.3.0 /home/user/vEnv/lib/python3.11/site-packages pip cycler 0.12.1 /home/user/vEnv/lib/python3.11/site-packages pip fonttools 4.53.1 /home/user/vEnv/lib/python3.11/site-packages pip idna 3.10 /home/user/vEnv/lib/python3.11/site-packages pip kiwisolver 1.4.7 /home/user/vEnv/lib/python3.11/site-packages pip lorem 0.1.1 /home/user/vEnv/lib/python3.11/site-packages pip matplotlib 3.9.2 /home/user/vEnv/lib/python3.11/site-packages pip meson 1.5.0 /home/user/vEnv/lib/python3.11/site-packages pip mpmath 1.3.0 /home/user/vEnv/lib/python3.11/site-packages pip numpy 2.1.0 /home/user/vEnv/lib/python3.11/site-packages pip packaging 24.1 /home/user/vEnv/lib/python3.11/site-packages pip pandas 2.2.3 /home/user/vEnv/lib/python3.11/site-packages pip pillow 10.4.0 /home/user/vEnv/lib/python3.11/site-packages pip pip 23.0.1 /home/user/vEnv/lib/python3.11/site-packages pip platformdirs 4.3.6 /home/user/vEnv/lib/python3.11/site-packages pip pooch 1.8.2 /home/user/vEnv/lib/python3.11/site-packages pip pyparsing 3.1.4 /home/user/vEnv/lib/python3.11/site-packages pip PyQt6 6.7.1 /home/user/vEnv/lib/python3.11/site-packages pip PyQt6-Qt6 6.7.3 /home/user/vEnv/lib/python3.11/site-packages pip PyQt6_sip 13.8.0 /home/user/vEnv/lib/python3.11/site-packages pip python-dateutil 2.9.0.post0 /home/user/vEnv/lib/python3.11/site-packages pip pytz 2024.2 /home/user/vEnv/lib/python3.11/site-packages pip pyvista 0.44.1 /home/user/vEnv/lib/python3.11/site-packages pip requests 2.32.3 /home/user/vEnv/lib/python3.11/site-packages pip scooby 0.10.0 /home/user/vEnv/lib/python3.11/site-packages pip setuptools 66.1.1 /home/user/vEnv/lib/python3.11/site-packages pip six 1.16.0 /home/user/vEnv/lib/python3.11/site-packages pip sympy 1.13.3 /home/user/vEnv/lib/python3.11/site-packages pip typing_extensions 4.12.2 /home/user/vEnv/lib/python3.11/site-packages pip tzdata 2024.2 /home/user/vEnv/lib/python3.11/site-packages pip urllib3 2.2.3 /home/user/vEnv/lib/python3.11/site-packages pip vtk 9.3.1 /home/user/vEnv/lib/python3.11/site-packages pip
My question is: what is a good and simple way to get Matplotlib functionality within said virtual environment?
Reply
#2
How can I diagnose the specific error message I receive when trying to execute the script in the terminal, and what common issues should I look for?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  I cannot create a virtual environment on visual studio code using python Willem_Aucamp316 2 3,457 Nov-27-2024, 02:20 PM
Last Post: menator01
  Need help setting up trusted root ca in virtual environment dstempfley 0 1,245 May-31-2024, 03:14 PM
Last Post: dstempfley
  Help with creating folder and "virtual environment" AudunNilsen 1 1,019 Mar-21-2024, 04:41 AM
Last Post: deanhystad
  Installing python packages in a virtual environment Led_Zeppelin 1 1,628 Aug-15-2023, 08:18 PM
Last Post: deanhystad
  Problem with virtual environment standenman 2 2,220 Feb-23-2023, 07:09 PM
Last Post: standenman
Question Virtual Environment (using VS Code) Ashcora 4 69,525 Feb-15-2023, 07:17 PM
Last Post: snippsat
  How do I link the virtual environment of that project to the 3.9.2 version of python? Bryant11 1 2,288 Feb-26-2022, 11:15 AM
Last Post: Larz60+
  Project structure with a virtual environment gdbengo 1 2,236 Jan-26-2022, 03:22 PM
Last Post: snippsat
  Virtual environment path? Led_Zeppelin 1 3,026 Jul-22-2021, 01:40 PM
Last Post: snippsat
  virtual environment heye 4 3,441 Jul-04-2021, 06:47 AM
Last Post: ndc85430

Forum Jump:

User Panel Messages

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