0

I have just installed the new Mint 22.2 as my old hard disk with Mint 21 seems to have some issues. I use Eric-IDE to execute my .py script.
The script is first downloading stock values from a certain date, and after that it is supposed to draw curves in the time area defined with startplot and endplot.
On my old installation it has worked without any issues, but now after using the exact same script I get this error message when reading the Plotdata. The file with Plotdate looks ok.
The lines having the issue are those:

Plotdata.to_csv(plotfil, columns=['Date', 'Close', 'High', 'Low', 'Open', 'Volume'], index=0)  
print('Here I am 1')
try:
    date, closep, highp, lowp, openp,  volume = np.loadtxt(plotfil,delimiter=',',skiprows=1, unpack=True, converters={ 0: bytespdate2num('%Y-%m-%d')})
print('Here I am 2')

The message 'Here I am 1' is printed but 'Here I am 2' is not so I expect the converter bytespdate2num is failing, but that converter is working on the old installation. The converter is this:

def bytespdate2num(fmt, encoding='utf-8'):
    def bytesconverter(b):
        s = b.decode(encoding)
        return (mdates.datestr2num(s))
    return bytesconverter

I am importing the following in the script:

import pandas as pd
import datetime
import csv
import pylab
import os
import glob
import time
import re
import yfinance as yf
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.ticker as mticker
import matplotlib.dates as mdates
from matplotlib.widgets import CheckButtons
import matplotlib

In the new Mint 22.2 it seems that matplotlib 3.6.3 is installed where I had 3.7.1 in the old Mint 21.2. I have tried to remove and reinstall matplotlib but always version 3.6.3 is downloaded.

The only output I get is this: No other errors

Here I am 1
main loop could not convert string '2023-01-02' to float64 at row 0, column 1.

The plotfile looks like this:

Date,Close,High,Low,Open,Volume
2023-01-03,108.0999984741211,118.8000030517578,104.63999938964844,118.47000122070312,231402800
2023-01-04,113.63999938964844,114.58999633789062,107.5199966430664,109.11000061035156,180389000
2023-01-05,110.33999633789062,111.75,107.16000366210938,110.51000213623048,157986300

I have installed Eric-Ide in the virtual eric_env on both installations. The Python version is 3.12.3

~/eric_env/bin/python3 -m pip install numpy

~/eric_env/bin/python3 -m pip install yfinance --upgrade --no-cache-dir

~/eric_env/bin/python3 -m pip install -U matplotlib

sudo apt-get install python3-matplotlib      #no changes

~/eric_env/bin/python3 -m pip install pandas

My question is what can be the reason for the converter to fail now.
What am I missing here?.

13
  • 1
    always put full error message (traceback) because there are other useful information. Commented Oct 31 at 21:05
  • 1
    how do you install modules - using pip or apt? What version of Python do you use - default (for Mint 22) 3.12 or other? Commented Oct 31 at 21:06
  • 1
    better create minimal working code which shows this problem - only with matplotlib and pandas (with data hardcoded as pd.DataFrame(...)) - so we could simply copy and test it on other systems. I can test it on Mint 22.1 with Python 3.9, 3.10, 3.11, 3.12, 3.13, 3.14 (at this moment with matplotlib 3.10.0 but with venv I can test with 3.6.3 and 3.7.1) Commented Oct 31 at 21:28
  • 1
    if you read data using yfinance then column Date should keep values as datetime object and then you could even try df["float_date"] = df["Date"].astype("int64") / 1e9 / 86400 without using matplotlib.dates Commented Nov 1 at 1:40
  • 1
    I just changed the converter to def bytespdate2num(fmt): def bytesconverter(fmt): return (mdates.datestr2num(fmt)) return bytesconverter and now it is working. I cannot say how it could work on my old installation Commented Nov 1 at 19:26

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.