No pyvenv.cfg file
Asked Answered
M

12

7

I made a variable cfg = waterot.cfg and then made a new file "waterot.cfg" in pycharm, this automatically made a pyvenv.cfgfile, I didn't know what this was and I was getting errors with my code I deleted the pyvenv.cfg file and changed from .cfg to .txt. Now when I run my code I get an error No pyvvenv.cfg file

This is the problematic piece of code

redeemkey = message.author
if redeemkey.startswith('!download'):
    if message.channel.id == 695834994064490658:
        with open ('waterOT.txt', 'rb') as otcfg:
            await message.author.send(file=discord.File(otcfg, 'waterOT.cfg'))
        await message.delete()
Motive answered 4/4, 2020 at 10:1 Comment(2)
How you search for this file in the Internet? Seems it is created for every Python virtual environment.Bannock
Try recreating the venv...Xerophthalmia
R
6

In my case I tried many ways, but finally I do one thing that solve my error. I just delete existing venv directory and set Project Interpreter from my editor. PyCharm Editor Setting

Rockett answered 27/7, 2021 at 8:40 Comment(0)
T
4

If you know the path for the python distribution used to create the virtual environment, and it's version, you can just create yourself a pyvenv.cfg file with following contents

home = <location-of-python-exe>
include-system-site-packages = false
version = <version>

where

  • <location-of-python-exe> is the folder where the python.exe is located that was used to create the python virtual environment. Example C:\Python\Python385-64.
  • <version> is the version of the python, at <location-of-python-exe>. You can check it by running <location-of-python-exe>\python.exe. Example: 3.8.5.

Valid locations for the pyvenv.cfg are (PEP405):

  • Next to the python executable (venv/Scripts/pyvenv.cfg), i.e. in the same folder with python.exe.
  • One directory up from the python executable; root of the virtual environment (venv/pyvenv.cfg)

where venv is the assumed name of the virtual environment (could be something else, too).

Thilda answered 2/4, 2021 at 15:57 Comment(0)
H
1

the python.exe must be name like this. I had py.exe and it did not work. Create the file: pyvenv.cfg and store it in the venv directory.

home = C:\Windows
include-system-site-packages = false
version = Flask 2.3.2 
Hughmanick answered 3/6, 2023 at 13:50 Comment(0)
A
0

With PyCharm you can restore that change in a couple of clicks:

Right-click anywhere in the editor and choose Local History | Show History from the context menu.

In the dialog that opens, the left-hand pane shows a list of all saved revisions of the current file with timestamps. The right-hand pane shows a diff viewer which displays the differences between each revision and the current state of the file.

OR

Do one of the following:

To revert the whole file or directory to the state of this revision, right-click it and choose Revert from the context menu or click the Revert icon on the toolbar.

To restore a specific code fragment, select the revision that contains that fragment. In the diff view on the right locate the piece of code you want to restore click the chevron button the Chevron button to copy it from the left pane.

Adjunct answered 7/6, 2021 at 16:48 Comment(0)
M
0

The easiest way is to chose 'file' in left hand corner of pycharm window, then choose restart IDE, then follow the steps of restarting settings of IDE. It worked for me.

Monaghan answered 31/1, 2022 at 17:4 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Kandi
Y
0

I was starting a process on Windows as a different user with some ugly pywin32 code, when I ran into No pyvenv.cfg file with return code 106 from the python.exe inside of my venv.

Long story short, I fixed it by replacing the relative path to the exe with an absolute path.

  • Relative path (bad): venv\Scripts\python.exe
  • Absolute path (good): C:\...\venv\Scripts\python.exe
Yautia answered 6/3, 2023 at 16:26 Comment(0)
B
0

in my case, I deleted the Scripts folder and then went to the root folder of the project and generated the virtual environment again with the command of: virtualenv .

Basuto answered 5/8, 2023 at 8:0 Comment(0)
Y
0

For those that came here like me, that is found this error updating python 3.10 to 3.11 with 'upgrade option' instead of custom installation. Thu bug exist on VSCode

The solution are pretty straighforward:

  1. Uninstall old python (on windows, via dd or remove program)
  2. Update system environment variable so it points boyt 3.11 script and py.exe file
  3. Open extensions list on VSCode, disable, enable

Note that the step 3 might be only step needed, but I can't confirm because I did those three step on my case.

Yl answered 12/10, 2023 at 8:43 Comment(0)
J
0

I ran into No pyvenv.cfg file with return code 106 from the python.exe inside of my venv.I tried everyone's solutions but it didn't work until,I just opened a new project and it was as good as new

Jacobah answered 21/3 at 21:43 Comment(0)
H
0

My scenario was I had an existing venv created using:

python -m venv .venv

Then, I installed poetry, pyenv-win, initialized poetry using poetry init, then installed a new version of Python using:

pyenv install 3.11

Apparently this destroyed the .venv directory.

  • I simply needed to rm -rf .venv

This page helped: https://hatchjs.com/no-pyvenv-cfg-file/

Hydrometallurgy answered 6/9 at 2:54 Comment(0)
H
-1

pyvenv.cfg is a configuration file for a virtual environment. Without knowing how you set things up, I assume Pycharm made the virtual environment.

You should not delete the pyvenv.cfg file if you want the virtual environment to work.

Heinous answered 16/2, 2021 at 19:4 Comment(0)
B
-1

I tried to read the above solutions but did not understand. I uninstalled Python and reinstalled it again, and everything worked well. The error disappeared.

Benilda answered 14/5, 2023 at 9:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.