No pyvenv.cfg file

Viewed 31244

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()
5 Answers

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

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 Thanks

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.

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.

Related