Score:0

How do i run a python script from a windows partition using the python interpreter from anaconda in ubuntu?

cn flag

As the question suggests i have a dual boot set up with python scripts stored in my windows partition.

I have ubuntu installed on a separate HDD and can successfully run python files that are stored within its own HDD.

The following script is saved as a copy in both the windows partition AND the ubuntu partition:

from bs4 import BeautifulSoup as bs4
import os
from tqdm import tqdm
import sys

print(sys.executable)
print(sys.path)

print('it worked')

Using two instances of VSCode using the ubuntu OS, I have the following results from trying to run the script from each file path:

path to file in windows partition:

/bin/python3 "/media/saleem/84E859C6E859B760/Users/sim77/Dropbox/Literature Searcher/Scripts/new.py"
(base) saleem@saleem-desktop:/media/saleem/84E859C6E859B760/Users/sim77/Dropbox/Literature Searcher/Scripts$ /bin/python3 "/media/saleem/84E859C6E859B760/Users/sim77/Dropbox/Literature Searcher/Scripts/new.py"
Traceback (most recent call last):
  File "/media/saleem/84E859C6E859B760/Users/sim77/Dropbox/Literature Searcher/Scripts/new.py", line 1, in <module>
    from bs4 import BeautifulSoup as bs4
ModuleNotFoundError: No module named 'bs4'

path to file in ubuntu partition:

(base) saleem@saleem-desktop:~$ source /home/saleem/anaconda3/bin/activate
(base) saleem@saleem-desktop:~$ conda activate base
(base) saleem@saleem-desktop:~$ /home/saleem/anaconda3/bin/python /home/saleem/Documents/new.py
/home/saleem/anaconda3/bin/python
['/home/saleem/Documents', '/home/saleem/anaconda3/lib/python38.zip', '/home/saleem/anaconda3/lib/python3.8', '/home/saleem/anaconda3/lib/python3.8/lib-dynload', '/home/saleem/anaconda3/lib/python3.8/site-packages', '/home/saleem/anaconda3/lib/python3.8/site-packages/locket-0.2.1-py3.8.egg']
it worked

From what i can see, when using the file from the windows partition, a different interpreter is being used. I am simply trying to use the same interpreter that works when using the latter path, but by accessing files from the first path.

Is there a way to do this efficiently?

kanehekili avatar
zw flag
I'm not sure I understand your question. What VSCode and what is "windows path" ?
Saleem Khan avatar
cn flag
the path to the file in the windows partition.
Score:0
cn flag

It was as simply a case of changing the interpreter path via the gui. I was simply thrown off by having changed OS systems for the first time.

clicking on the interpreter in the blue section and selecting solved this

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.