I am trying to install and import this python module in the same file. I am adding the directory where I want networkX to be installed in PYTHONUSERBASE, and I even prepend it to the PATH.
#install and import networkx
os.environ['PYTHONUSERBASE'] = "some_other_directory/python_packages"
executeCommand('python3 -m pip install --user networkx[default]')
sys.path.insert(0, os.environ['PYTHONUSERBASE'])
importlib.invalidate_caches()
import networkx
However, I get this error:
Traceback (most recent call last):
File "file_that_runs_the_code.py", line 35, in <module>
import networkx
ModuleNotFoundError: No module named 'networkx'
Any help would be appreciated.