Thursday 11 March 2021

Issues with importing modules on mac (Big Sur), and sys.executable and location of package not matching up?

I have an issue in which I'll install a package (like tensorflow or dpu_utils), and it will end up in a different location than sys.executable. For instance, when I run pip show dpu_utils on my terminal, I get the following information:

Name: dpu-utils
Version: 0.2.20
Summary: Python utilities used by Deep Procedural Intelligence
Home-page: https://github.com/microsoft/dpu-utils
Author: Deep Procedural Intelligence
Author-email: None
License: MIT
Location: /usr/local/lib/python3.9/site-packages
Requires: docopt, tqdm, sentencepiece, azure-storage, numpy, SetSimilaritySearch
Required-by: 

When I run python, import dpu_utils, import sys, and then sys.executable, I get the following:

python
Python 3.7.3 (default, Dec 13 2019, 19:58:14) 
[Clang 11.0.0 (clang-1100.0.33.17)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import dpu_utils
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'dpu_utils'
>>> import sys
>>> sys.executable
'/Library/Developer/CommandLineTools/usr/bin/python3'
>>> exit()

As you can see, the issue arises because my sys.executable does not match up with the location of where the package is actually being installed. Is there a way to set the sys.executable such that it matches to /usr/local/lib/python3.9/site-packages? I am very confused on how to do this since updating to Big Sur on my Mac. I tried to edit the PATH variable in .zshrc, but no such luck. If anyone could give me a step by step of how to edit my environment variables so my programs find the package materials where they are actually getting installed, it would be incredibly helpful. Thank you.



from Issues with importing modules on mac (Big Sur), and sys.executable and location of package not matching up?

No comments:

Post a Comment