# Problem with python in virtual environment

**URL:** <https://discuss.python.org/t/problem-with-python-in-virtual-environment/104082>\
**Category:** Python Help\
**Tags:** help\
**Created:** [October 1, 2025, 12:31pm UTC](https://discuss.python.org/t/problem-with-python-in-virtual-environment/104082 "2025-10-01T12:31:42Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![mauryasuryakant](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/mauryasuryakant/32/31356_2.png) [@mauryasuryakant](https://discuss.python.org/u/mauryasuryakant)\
**Post date:** [October 1, 2025, 12:31pm UTC](https://discuss.python.org/t/problem-with-python-in-virtual-environment/104082/1 "2025-10-01T12:31:42Z")

</div>

![Screenshot 2025-10-01 175415](https://us1.discourse-cdn.com/flex002/uploads/python1/original/3X/f/8/f88bb6c40d14a3de4c0327f5698b2da96d98693a.png)

Maybe it’s a silly mistake, but I’m new 😅

---

<div class="post-metadata">

**Author:** ![bwoodsend](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/bwoodsend/32/4027_2.png) [@bwoodsend](https://discuss.python.org/u/bwoodsend)\
**Post date:** [October 1, 2025, 1:02pm UTC](https://discuss.python.org/t/problem-with-python-in-virtual-environment/104082/2 "2025-10-01T13:02:43Z")

</div>

Not sure it’s the issue or the only issue but the obvious thing to me is that you’re using bash’s activation script in powershell. Try:

```powershell
. env\Scripts\activate.ps1

```

---

<div class="post-metadata">

**Author:** ![Monarch](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/monarch/32/18530_2.png) [@Monarch](https://discuss.python.org/u/Monarch)\
**Post date:** [October 1, 2025, 6:13pm UTC](https://discuss.python.org/t/problem-with-python-in-virtual-environment/104082/3 "2025-10-01T18:13:57Z")

</div>

I’m on Windows 11 and wasn’t able to reproduce this issue, whether using `pwsh` (PowerShell 7.5.3) or `Windows PowerShell` (5.1). For example:

```powershell
❯ uvx python@3.13 -m venv .venv
❯ .\.venv\Scripts\activate
❯ python -c 'import sys; print(sys.executable)'
<redacted>\.venv\Scripts\python.exe

```

I also tried the same steps with Python 3.14 and it worked just as expected.

---

<div class="post-metadata">

**Author:** ![JoBe](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/jobe/32/26961_2.png) [@JoBe](https://discuss.python.org/u/JoBe)\
**Post date:** [October 1, 2025, 6:31pm UTC](https://discuss.python.org/t/problem-with-python-in-virtual-environment/104082/4 "2025-10-01T18:31:49Z")

</div>

Due to python not showing up when you do `where python`, I’d guess python isn’t on PATH (mainly because I had a similar error once). If you have multiple Python instalments, one has to be prioritised over the other, and perhaps one outside the `venv` is the one that’s supposed to run, but it can’t access the `venv`.

I don’t know if something like that could be the issue, but I’d suggest you check your PATH anyways, it might reveal the error.

---

<div class="post-metadata">

**Author:** ![AlSweigart](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/alsweigart/32/12237_2.png) [@AlSweigart](https://discuss.python.org/u/AlSweigart)\
**Post date:** [October 1, 2025, 7:35pm UTC](https://discuss.python.org/t/problem-with-python-in-virtual-environment/104082/5 "2025-10-01T19:35:26Z")

</div>

Note that Python on Windows installs py.exe into C:\Windows, which is already on the PATH. So you should be able to run `py main.py` to run it. If you have multiple versions of Python installed, you can run `py -3.14 main.py` to run a particular version.

---

<div class="post-metadata">

**Author:** ![mauryasuryakant](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/mauryasuryakant/32/31356_2.png) [@mauryasuryakant](https://discuss.python.org/u/mauryasuryakant)\
**Post date:** [October 2, 2025, 5:03am UTC](https://discuss.python.org/t/problem-with-python-in-virtual-environment/104082/6 "2025-10-02T05:03:35Z")

</div>

Hi Brénainn, thanks for your suggestion! I tried running:

```bash
. env\Scripts\activate.ps1

```

It does activate the virtual environment, but I’m still getting the same error when I try to run my script: I tried @AlSweigart ’s approach by ruuning via py and py.exe

 ![Screenshot 2025-10-02 095747](https://us1.discourse-cdn.com/flex002/uploads/python1/original/3X/0/d/0ddb8a1d7bbabb30f9ab5b0db412cbe2d31aa6ff.png)

So unfortunately I’m getting the same error as before. Do you have any ideas what else I should check?

---

<div class="post-metadata">

**Author:** ![bwoodsend](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/bwoodsend/32/4027_2.png) [@bwoodsend](https://discuss.python.org/u/bwoodsend)\
**Post date:** [October 2, 2025, 5:20am UTC](https://discuss.python.org/t/problem-with-python-in-virtual-environment/104082/7 "2025-10-02T05:20:16Z")

</div>

How did you create this env in the first place? I find it odd that you’d have been able to run `python -m venv` before activating the environment but not even be able to run `python` afterwards.

---

<div class="post-metadata">

**Author:** ![bwoodsend](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/bwoodsend/32/4027_2.png) [@bwoodsend](https://discuss.python.org/u/bwoodsend)\
**Post date:** [October 2, 2025, 5:22am UTC](https://discuss.python.org/t/problem-with-python-in-virtual-environment/104082/8 "2025-10-02T05:22:26Z")

</div>

If you share the value of `$env:path`, that might give some clue.

---

<div class="post-metadata">

**Author:** ![mauryasuryakant](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/mauryasuryakant/32/31356_2.png) [@mauryasuryakant](https://discuss.python.org/u/mauryasuryakant)\
**Post date:** [October 2, 2025, 5:28am UTC](https://discuss.python.org/t/problem-with-python-in-virtual-environment/104082/9 "2025-10-02T05:28:10Z")

</div>

I created the virtual environment initially with:

```bash
python -m venv venv

```

I also tried @Monarch’s approach using:

```bash
uvx python@3.13 -m venv .venv

```

but I’m still facing the same issue.

Here’s the current value of my PATH (from PowerShell):

```bash
(.venv) PS D:\TOOLs\TestEnv> $env:Path
D:\TOOLs\TestEnv\.venv\Scripts;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\windows\System32\OpenSSH\;C:\Program Files\dotnet\;C:\Program Files\Docker\Docker\resources\bin;C:\Program Files\Git\cmd;C:\nodejs\;C:\Users\Suryakant\AppData\Local\Programs\Python\Python313\Scripts\;C:\Users\Suryakant\AppData\Local\Programs\Python\Python313\;C:\Users\Suryakant\AppData\Local\Microsoft\WindowsApps;C:\Users\Suryakant\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\Suryakant\AppData\Roaming\npm
(.venv) PS D:\TOOLs\TestEnv>

```

Do you see anything in PATH that might be causing Python to not be found?

---

<div class="post-metadata">

**Author:** ![mauryasuryakant](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/mauryasuryakant/32/31356_2.png) [@mauryasuryakant](https://discuss.python.org/u/mauryasuryakant)\
**Post date:** [October 2, 2025, 6:10am UTC](https://discuss.python.org/t/problem-with-python-in-virtual-environment/104082/10 "2025-10-02T06:10:07Z")

</div>

@bwoodsend @jobe

I realized the main issue is that I installed **Python** via the **Microsoft Store** , which can cause **PATH** and virtual environment problems.

Even after creating the venv with

```bash
python -m venv venv 

```

or

```bash
uvx python@3.13 -m venv .venv

```

running **`python`** inside the venv gives issues.

**Apologies if this is obvious — “I’m learning Python 😅 — I just started. Thanks for the help!”**

---

<div class="post-metadata">

**Author:** ![DavidCEllis](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/davidcellis/32/9789_2.png) [@DavidCEllis](https://discuss.python.org/u/DavidCEllis)\
**Post date:** [October 2, 2025, 9:24am UTC](https://discuss.python.org/t/problem-with-python-in-virtual-environment/104082/11 "2025-10-02T09:24:41Z")

</div>

`where python` in your first post probably didn’t display anything because you got the `Where-Object` command from Powershell rather than the `where.exe` application.

You can try `where.exe python` instead.

The output of `uv python list` may also be helpful.

---

<div class="post-metadata">

**Author:** ![mauryasuryakant](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/mauryasuryakant/32/31356_2.png) [@mauryasuryakant](https://discuss.python.org/u/mauryasuryakant)\
**Post date:** [October 2, 2025, 3:25pm UTC](https://discuss.python.org/t/problem-with-python-in-virtual-environment/104082/12 "2025-10-02T15:25:24Z")

</div>

Hi everyone,

I just wanted to give an update: my Python program is running fine now. 🎉

Earlier, I was getting this error in Windows 11 when running `python --version`:

```bash
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Apps > Advanced app settings > App execution aliases.

```

The issue turned out to be related to the PATH setup. Python was added to the **User PATH** , but Windows was not picking it up correctly. I fixed it by adding Python to the **System PATH** instead.

After that, everything works as expected:

```bash
py --version
Python 3.13.7

```

and my test script runs successfully.

Thanks to everyone who helped! 🙏

— Suryakant

---

<div class="post-metadata">

**Author:** ![JoBe](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/jobe/32/26961_2.png) [@JoBe](https://discuss.python.org/u/JoBe)\
**Post date:** [October 2, 2025, 5:58pm UTC](https://discuss.python.org/t/problem-with-python-in-virtual-environment/104082/13 "2025-10-02T17:58:24Z")

</div>

That’s not obvious, and I wouldn’t have thought of that to be honest. Thanks for telling us what the issue was however, so we might learn from it for the future.
