Error creating virtualenv

Getting the following error on trellis init. Any thoughts on how to solve this?

`Initializing project…

⠙ Creating virtualenvError: [Errno 2] No such file or directory: ‘/Users/joe/Sites/scout-branding/la-bikini/trellis/.trellis/virtualenv/bin/python3’
[✘] Error creating virtualenv`

It’s quite difficult to help without any sort of details about your environment or your project.

Are you able to reproduce this issue on a fresh Trellis installation? If yes, can you provide basic details about your env such as your operating system and the versions of software that’s required by Trellis?

Just tested and trellis new xxx works fine with virtualenv spinning up correctly.

[✓] Created virtualenv (/Users/joe/Sites/scout-branding/test/

Seems like it’s an issue with all of my existing trellis sites. My environment is (let me know if I should post more):

MacOS 12.4
Python 3.8.9

I noticed when I run pip -V, it returns zsh: no such file or directory: /usr/local/bin/pip3 but running pip3 -V returns correctly.

This issue started when I tried to deploy a new build I have. Then, I removed/reinstalled my Homebrew Python/brew-pip installs but then realized that it’s running on the MAc OS installed version. Really think that something is incorrect with my Python install although not sure how to fix it…

Just curious… Does deleting the .trellis directory and re-running trellis init do anything different?

I tried that and no. Going to figure this out tomorrow and I’ll post what the problem was.

:thinking: I’m surprised what @joshf suggested didn’t work. If you re-install Python it probably could break existing virtualenv’s that were created before and the solution in that case is to re-create them. But that still depends on having Python 3 installed properly.

Here is the error I am getting. Could this be from a problem with my Python install?

Running command => ansible-playbook deploy.yml -e env=staging exec: "ansible-playbook": executable file not found in $PATH

That error could happen if the virtualenv wasn’t created successfully. Can you run the following commands in a new terminal and reply with the output please?

  1. which python3
  2. python3 --version

Sorry for the delayed reply…

Python 3.8.9

Here is what I get running trellis init and I have verified that the file does indeed exist:

`Initializing project…

⠙ Creating virtualenvError: [Errno 2] No such file or directory: ‘/Users/joe/Sites/bridgeworth-new/trellis/.trellis/virtualenv/bin/python3’
[✘] Error creating virtualenv
exit status 1

Project initialization failed due to the error above.

trellis-cli tried to create a virtual environment but failed.
=> /usr/bin/python3 -m venv

Without virtualenv, a Python virtual environment cannot be created and the required dependencies (eg: Ansible) can’t be installed either.`

Here is what I get running trellis init and I have verified that the file does indeed exist:

Can you delete the entire .trellis directory in that project and try that again? This path: /Users/joe/Sites/bridgeworth-new/trellis/.trellis

I tried that before on Josh’s recommendation with same result. Beginning to think it is something with my Python installation because my old projects running Trellis are all having the same issue.

That’s very weird because it’s trying to run python3 from within the virtualenv that doesn’t yet exist? :thinking:

Can you run these two commands within that new project directory? And post results here please.

  1. echo $PATH
  2. trellis exec echo $PATH

Just checking, but the path returned in that error is the project path you’re in right?


Running trellis exec echo $PATH returns the above error when running trellis init and then the $PATH as reflected above.

Yes, the path is correct in each project. To reitterate, NONE of my Trellis projects will run now and have the same behavior as above.

I’m pretty confused and stumped by this. There’s two important things in the error message you got.

  1. the error has the path /Users/joe/Sites/bridgeworth-new/trellis/.trellis/virtualenv/bin/python3
  2. the error message lower down says it tried this command: /usr/bin/python3 -m venv

I can’t think of a situation where those would differ.

That last command is actually captured first here:

trellis-cli looks for python3 in your PATH and returns that if found. In this case, we know it found your system python3 at /usr/bin/python3.

The actual error you’re seeing is coming from here. When Go tries to run the command, it fails because it doesn’t exist. But what’s confusing is right before it uses the same Installed method which was used earlier. Yet apparently it’s returning a different value now and one that doesn’t even exist?

At this point the virtualenv is not created or activated, so that’s why I’m confused how the same method used to detect the python3 command could return two different values and one of them doesn’t event exist.

The only other thing I can think to check is your shell config. Are you using Bash or Zsh? Can you post any mentions of trellis-cli from them? Either ~/.bash_profile or ~/.zshrc (or another file depending on your setup).

I’m using Zsh and there are NO mentions of trellis-cli. I tried to add eval "$(trellis shell-init zsh)" although it didn’t help.

Maybe I should try a reinstall of Trellis-cli? Maybe more (ie. Python, etc.)?

Couldn’t hurt I guess so worth a try!

Looks like my Python install was broken somehow. Reinstalled and everything is running as usual…thx for the help.

Awesome, glad to hear :smile: