source python script in R

I'm trying to import a python script via reticulate package into R (shiny app) :

# Define any Python packages needed for the app here:
PYTHON_DEPENDENCIES = c('pip', 'numpy')

virtualenv_dir = Sys.getenv('VIRTUALENV_NAME')
python_path = '/opt/python/3.10.2/bin/python3.10'
  # Create virtual env and install dependencies
  reticulate::virtualenv_create(envname = virtualenv_dir, python = python_path)
  reticulate::virtualenv_install(virtualenv_dir, packages = PYTHON_DEPENDENCIES, ignore_installed=TRUE)
  reticulate::use_virtualenv(virtualenv_dir, required = T)

  # Import python functions to R

But then Running the last line source_python will return the error :

# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<

    Traceback (most recent call last):
      File "/opt/python/miniconda/lib/python3.9/site-packages/conda/", line 1080, in __call__
        return func(*args, **kwargs)
      File "/opt/python/miniconda/lib/python3.9/site-packages/conda/cli/", line 84, in _main
        exit_code = do_call(args, p)
      File "/opt/python/miniconda/lib/python3.9/site-packages/conda/cli/", line 83, in do_call
        return getattr(module, func_name)(args, parser)
      File "/opt/python/miniconda/lib/python3.9/site-packages/conda/cli/", line 25, in execute
        script_caller, command_args = wrap_subprocess_call(on_win, context.root_prefix, prefix,
      File "/opt/python/miniconda/lib/python3.9/site-packages/conda/", line 403, in wrap_subprocess_call
        with Utf8NamedTemporaryFile(mode='w', prefix=tmp_prefix, delete=False) as fh:
      File "/opt/python/miniconda/lib/python3.9/site-packages/conda/auxlib/", line 88, in Utf8NamedTemporaryFile
        return NamedTemporaryFile(
      File "/opt/python/miniconda/lib/python3.9/", line 541, in NamedTemporaryFile
        (fd, name) = _mkstemp_inner(dir, prefix, suffix, flags, output_type)
      File "/opt/python/miniconda/lib/python3.9/", line 251, in _mkstemp_inner
        fd =, flags, 0o600)
    PermissionError: [Errno 13] Permission denied: '/opt/python/3.10.2/.tmpn2kwx5t2'

`$ /opt/python/miniconda/bin/conda run --prefix /opt/python/3.10.2 --no-capture-output python -c import os; print(os.environ['PATH'])`

  environment variables:
                 CIO_TEST=<not set>
           CURL_CA_BUNDLE=<not set>
       REQUESTS_CA_BUNDLE=<not set>
            SSL_CERT_FILE=<not set>

     active environment : /opt/python/3.10.2
    active env location : /opt/python/3.10.2
       user config file : /home/a2bgf93/.condarc
 populated config files : 
          conda version : 4.11.0
    conda-build version : not installed
         python version :
       virtual packages : __linux=5.13.0=0
       base environment : /opt/python/miniconda  (read only)
      conda av data dir : /opt/python/miniconda/etc/conda
  conda av metadata url : None
           channel URLs :
          package cache : /opt/python/miniconda/pkgs
       envs directories : /home/a2bgf93/.conda/envs
               platform : linux-64
             user-agent : conda/4.11.0 requests/2.27.1 CPython/3.9.7 Linux/5.13.0-1017-azure ubuntu/20.04.3 glibc/2.31
                UID:GID : 1962704655:1102800513
             netrc file : None
           offline mode : False

An unexpected error has occurred. Conda has prepared the above report.

Error in Sys.setenv(PATH = new_path) : wrong length for argument
In addition: Warning message:
In system2(conda, c("run", in_env, run_args, shQuote(cmd), args),  :
  running command ''/opt/python/miniconda/bin/conda' run --prefix '/opt/python/3.10.2' --no-capture-output 'python' -c "import os; print(os.environ['PATH'])"' had status 1

And the permission denied on the python folder, I don't really know where it comes from ! :

:/opt/python# ls -la
total 73888
drwxr-xr-x  7 root root       97 Mar  8 14:08 .
drwxr-xr-x  9 root root       99 Apr  4 21:17 ..
drwxr-xr-x  9 root root      108 Mar  8 13:55 2.7.16
drwxr-xr-x 13 root root      195 Mar 15 17:37 3.10.2
drwxr-xr-x 12 root root      184 Mar 15 17:27 3.7.7
drwxr-xr-x 12 root root      184 Mar 15 17:33 3.9.0
drwxr-xr-x 16 root root      256 Mar  8 13:19 miniconda
-rwxr-xr-x  1 root root 75660608 Mar  8 13:18

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.