3
votes

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()
3
How you search for this file in the Internet? Seems it is created for every Python virtual environment. - user2235698
Try recreating the venv... - Avishka Dambawinna

3 Answers

1
votes

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

0
votes

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.

0
votes

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.