posit-dev / posit-dev/positron

Positron's Python (seems) do not respect Conda environment variables when calling other CLI tools using Python

Open
#7,138 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area: console area: kallichore enhancement lang: python support
Dominant language
TypeScript
Stars
4.3k
Forks
184
Avg merge
1d 11h
Merged PRs (30d)
206

Description

System details:

Positron and OS details:

Positron Version: 2025.04.0 (Universal) build 109
Code - OSS Version: 1.97.0
Commit: 56a6c89ad24fbdeaa417ec9c03d05dbd9196c953
Date: 2025-03-17T11:31:23.496Z
Electron: 32.2.7
Chromium: 128.0.6613.186
Node.js: 20.18.1
V8: 12.8.374.38-electron.0
OS: Darwin arm64 24.0.0

Interpreter details:

Python 3.10.16 (Conda)

Describe the issue:

It seems that Positron's Python does not respect some of Conda's environment variables, especially when the tool needs to call external command-line utilities. As shown in the image, Positron's Console fails to execute the following code because it cannot find the closestBed tool (a CLI tool). However, when running which in the Terminal, the tool is correctly installed.

Image

When running which in the Terminal, the tool is correctly installed.

Image

In terminal's ipython, all things are right.

Image

Steps to reproduce the issue:

conda create -n scPagwas_env python=3.10
conda install -c bioconda bedtools
pip install scanpy numpy pandas scikit-learn pybedtools dask statsmodels scipy joblib

Needed toy data can be downloaded in https://github.com/ZhimingYe/scPagwas_py/tree/656cc9e602fb31a02a514c03ff584e9853c87987/data

from pybedtools import BedTool
import pandas as pd
import numpy as np
marg=10000
gwas_data = pd.read_csv('/home/yezhiming/Desktop/scppy/scPagwas_py-main/data/GWAS_summ_example.txt', sep=' ')
block_annotation = pd.read_csv("/home/yezhiming/Desktop/scppy/scPagwas_py-main/data/block_annotation.csv")
gwas_data['pos_start'] = gwas_data['pos']
gwas_data['pos_end'] = gwas_data['pos']
#gwas_bed = BedTool.from_dataframe(gwas_data[['chrom', 'pos_start', 'pos_end', 'rsid']]).sort()
gwas_bed = BedTool.from_dataframe(gwas_data[['chrom', 'pos_start', 'pos_end', 'rsid']].sort_values(['chrom', 'pos_start']))
block_annotation['start'] = block_annotation['start'] + 1 - marg
block_annotation['start'] = block_annotation['start'].apply(lambda x: max(x, 0))
block_annotation['end'] = block_annotation['end'] + marg
block_sorted = block_annotation[['chrom', 'start', 'end', 'label']].sort_values(by=['chrom', 'start', 'end'])
block_bed = BedTool.from_dataframe(block_sorted)
nearest = gwas_bed.closest(block_bed, d=True)

Expected or desired behavior:

Were there any error messages in the UI, Output panel, or Developer Tools console?

It reports it can't find the installed tool

NotImplementedError: "closestBed" does not appear to be installed or on the path, so this method is disabled.  Please install a more recent version of BEDTools and re-import to use this method.
Cell In[15], line 1
----> 1 nearest = gwas_bed.closest(block_bed, d=True)
Hide Traceback
File [~/miniconda3/envs/scPagwas_env/lib/python3.10/site-packages/pybedtools/bedtool.py:454](vscode-file://vscode-app/Applications/Positron.app/Contents/Resources/app/out/vs/code/electron-sandbox/workbench/workbench.html#), in _log_to_history.<locals>.decorated(self, *args, **kwargs)
    450 def decorated(self, *args, **kwargs):
    451 
    452     # this calls the actual method in the first place; *result* is
    453     # whatever you get back
--> 454     result = method(self, *args, **kwargs)
    456     # add appropriate tags
    457     parent_tag = self._tag

File [~/miniconda3/envs/scPagwas_env/lib/python3.10/site-packages/pybedtools/bedtool.py:250](vscode-file://vscode-app/Applications/Positron.app/Contents/Resources/app/out/vs/code/electron-sandbox/workbench/workbench.html#), in _wraps.<locals>.decorator.<locals>.not_implemented_func(*args, **kwargs)
    249 def not_implemented_func(*args, **kwargs):
--> 250     raise NotImplementedError(help_str)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the failure in the Positron Console with the provided Conda environment and compare the Python process environment with Terminal and terminal ipython. Trace how Positron launches its Python interpreter and external CLI tools; done when the installed closestBed tool is discoverable from the reproduced workflow.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
developer-experience
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.