# Error creating virtualenv

**URL:** https://discourse.roots.io/t/error-creating-virtualenv/23539
**Category:** trellis
**Tags:** deploys, trellis, sage10
**Created:** 2022-07-11T18:17:28Z
**Posts:** 19

## Post 1 by @vandigroup — 2022-07-11T18:17:29Z

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`

---

## Post 2 by @ben — 2022-07-11T18:20:34Z

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](https://docs.roots.io/trellis/master/installation/#requirements)?

---

## Post 3 by @vandigroup — 2022-07-11T18:45:49Z

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

`[✓] Created virtualenv (/Users/joe/Sites/scout-branding/test/testsite.com/trellis/.trellis/virtualenv)`

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.

---

## Post 4 by @vandigroup — 2022-07-11T18:53:31Z

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…

---

## Post 5 by @joshf — 2022-07-15T22:53:48Z

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

---

## Post 6 by @vandigroup — 2022-07-16T20:21:10Z

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

---

## Post 7 by @swalkinshaw — 2022-07-17T17:34:38Z

: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.

---

## Post 8 by @vandigroup — 2022-07-20T20:09:10Z

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 site=xxx.com exec: "ansible-playbook": executable file not found in $PATH`

---

## Post 9 by @swalkinshaw — 2022-07-20T22:00:28Z

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`

---

## Post 10 by @vandigroup — 2022-07-22T00:15:48Z

Sorry for the delayed reply…

/usr/bin/python3  
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.`

---

## Post 11 by @swalkinshaw — 2022-07-22T14:53:42Z

> 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`

---

## Post 12 by @vandigroup — 2022-07-22T17:36:58Z

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.

---

## Post 13 by @swalkinshaw — 2022-07-22T21:25:14Z

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?

---

## Post 14 by @vandigroup — 2022-07-22T22:29:55Z

/Users/joe/.themekit:/Users/joe/.nvm/versions/node/v16.13.0/bin:/usr/local/opt/node@8/bin:”/usr/bin:/usr/local:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin”:/Users/joe/.composer/vendor/bin

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.

---

## Post 15 by @swalkinshaw — 2022-07-24T16:48:00Z

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:

> <https://github.com/roots/trellis-cli/blob/447139d1018938aebcea579064ce5fa2bc50b754/cmd/init.go#L60>

trellis-cli [looks for `python3` in your PATH and returns that if found](https://github.com/roots/trellis-cli/blob/447139d1018938aebcea579064ce5fa2bc50b754/trellis/virtualenv.go#L91-L107). In this case, we know it found your system python3 at `/usr/bin/python3`.

The actual error you’re seeing is coming from [here](https://github.com/roots/trellis-cli/blob/447139d1018938aebcea579064ce5fa2bc50b754/trellis/virtualenv.go#L60-L63). 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](https://github.com/roots/trellis-cli/blob/447139d1018938aebcea579064ce5fa2bc50b754/trellis/virtualenv.go#L51) 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).

---

## Post 16 by @vandigroup — 2022-07-24T21:38:00Z

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.)?

---

## Post 17 by @swalkinshaw — 2022-07-26T17:35:18Z

Couldn’t hurt I guess so worth a try!

---

## Post 18 by @vandigroup — 2022-07-31T19:06:31Z

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

---

## Post 19 by @swalkinshaw — 2022-08-02T18:55:43Z

Awesome, glad to hear :smile:
