Home > Back-end >  VS Code update broke dependencies
VS Code update broke dependencies

Time:02-10

Last Thursday my VS Code auto updated.

The day after that one of my Python Scripts, which had been thoroughly tested and runs in production, stopped working.

It started complaining about a type error:

Exception has occurred: TypeError (note: full exception trace is shown but execution is paused at: ) read_sql() got an unexpected keyword argument 'dtype'

for this this piece of code:

dtype_df= {}
dtype_df['some_field_1'] = np.dtype('U8')
...
dtype_df['some_field_n'] = np.dtype('U70')

df = pd.read_sql(sql = query, con = some_credentials(), dtype = dtype_df)

I did my research and I found out that this issue is related to using the dtype parameter with an older version of pandas.
That didn't make sense because the code worked up until that VS Code update.
Nonetheless, I checked my Pandas version on VS Code and it met the requirements (1.3.0):

pip show pandas

Name: pandas Version: 1.3.4 Summary: Powerful data structures for data analysis, time series, and statistics Home-page: https://pandas.pydata.org Author: The Pandas Development Team Author-email: [email protected] License: BSD-3-Clause Location: c:\users*******\appdata\local\programs\python\python39\lib\site-packages Requires: numpy, python-dateutil, pytz Required-by:

That is when I realized the issue should be related to VS Code. I also tried running it with a different Python interpreter 3.9.5 -> 3.10.1 but ran into different issues.
For that newer interpreter some dependencies were missing and that made sense for me.

I tried some stuff that I found here (https://github.com/microsoft/vscode/issues/97851) and here (VS 2012 Update 3 broke my VS).
That also did not work.

So, I am not hoping for a magical fix for this case, though if someone knows a different way to solve this issue, I am all ears.
Instead, I would like some feedback on what I think could help in this case:

  • Creating a virtual environment (currently I don't have one set up) and reinstalling all libraries OR
  • Uninstalling everything and reinstall again (all extensions and setup everything)

Which alternative would you recommend?

If am missing some key part for this question, please do tell me and I'll adjust it accordingly.

CodePudding user response:

Maybe you need to take pd.read_sql_query instead of pd.read_sql, as read_sql has not dtype keyword argument.

  • Related