Why is venv python directory not found?

56 views Asked by At

I am following instructions to run code in my mac computer from this codebase: https://github.com/obaghirli/syn10-diffusion

In step 1, I entered the syn10-diffusion directory and ran following steps inside that directory.

In step 2, when I ran python3.8 -m venv venv, I got an error zsh: command not found: python3.8. Then, I ran vim /usr/local/bin/, and found python3 and python3.9 in this file. So, I ran python3 -m venv venvas python3.8 was not in the file. It gave no error. Thus, I continued with next commands.

Then, I ran all commands till step 4. To follow step 5, I need to be in the directory of venv/lib/python3.8/site-packages and create a file there. As I did not use python3.8 in step 2, I ran venv/lib/python3/site-packages. I am getting this error cd: no such file or directory: venv/lib/python3/site-packages. I tried running this command from both of the syn10-diffusion and home directory.

Any suggestions on what can I do?

I also tried running cd venv/lib/python3.8/site-packages. It gave a similar error cd: no such file or directory: venv/lib/python3.8/site-packages.

3

There are 3 answers

1
king juno On

You could try creating a virtual env using python3.9 and see if you can install all the requirements without any issues. If that doesnt work, you should install python3.8 in your Mac. For that you can do any of the following:

0
tripleee On

If your Python version is 3.9 then (I hope obviously) the directory name inside your virtual environment will be venv/lib/python3.9/site-packages as you could easily find out yourself with ls or using your shell's tab completion.

Depending on the project you are trying to implement, it may or may not work exactly as with Python 3.8. Both 3.8 and 3.9 are supported and stable versions at this point in time (though 3.8 reaches end of life in October of 2024. Of course this doesn't mean it will stop working then, just that it will no longer receive security updates etc).

What's available in /usr/local/bin is completely system-dependent (as in, out of the box, this directory will be empty) and we can't really know how Python 3.9 got installed on your system. On MacOS Sonoma, /usr/bin/python3 is Python 3.9.6 so you will face similar issues if you try to use that instead of whatever someone (if not you yourself) installed somehow and forgot to document.

The name /usr/local/bin/python3.9 vaguely suggests that your installation was created by Homebrew, but it will by no means be the only one which uses this convention, just the most popular one. Again, what exactly to expect depends on how exactly your local Python version was installed. If /usr/local/bin/python3.9 is actually a symbolic link to ../Cellar/[email protected]/... then that's a more definitive indication that it's a Homebrew installation.

0
manisha On

Before doing cd venv/lib/python3.8/site-packages, check which python interpreter is installed in your virtual env by doing a simple: ls venv/lib and then replace python3.8 in cd venv/lib/python3.8/site-packages with the python version you have or try cd venv/lib then tab into the python directory and site-packages.