4

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()
popsmoke
  • 75
  • 1
  • 1
  • 6

9 Answers9

4

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

vvvvv
  • 25,404
  • 19
  • 49
  • 81
2

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

Niko Föhr
  • 28,336
  • 10
  • 93
  • 96
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 
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.

Roee
  • 113
  • 1
  • 4
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.

UNK30WN
  • 74
  • 7
  • 3
    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](/help/how-to-answer). – Community Jan 31 '22 at 17:28
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
xjcl
  • 12,848
  • 6
  • 67
  • 89
0

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.

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 .

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

Stuart
  • 465
  • 3
  • 6