The Handle is invalid error using source_python() from R Reticulate package

I've saved two files in the same folder. One is an R Script containing the reticulate function source_python(), the other file is the Python Script I want to source.

When I run the R script I get an error message which can be specifically attributed to import bcpandas. If I comment this line out - then it sources pandas, glob, os, pyodbc, numpy, subprocess just fine.

From what I've read - it could be that this is a problem with where my packages are saved. I used the default destination for saving my python packages when downloading using the function py_install(“bcpandas”)

...\r-miniconda\envs\r-reticulate\Lib\site-packages

I used the same function, without arguments this morning to download numpy py_install(“numpy”) - I've checked and numpy sits in this folder, alongside bcpandas.

Any ideas where I could be going wrong or what I could investigate next to try and solve the issue?

Thanks in advance :slight_smile:

R Script which calls Python Script using source_python from the reticulate package

library(reticulate)

Script_Dir <- gsub("/","\\\\",dirname(rstudioapi::getActiveDocumentContext()$path))
setwd(Script_Dir)

source_python("Upload_to_SQL.py")

Upload_to_SQL.py

import pandas
import glob
import os 
import pyodbc 
import numpy 
import subprocess
import bcpandas

Error Message from import bcpandas

Error in py_run_file_impl(file, local, convert) :
OSError: [WinError 6] The handle is invalid