[英]No pyvenv.cfg file
I made a variable cfg = waterot.cfg
and then made a new file " waterot.cfg
" in pycharm, this automatically made a pyvenv.cfg
file, 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
.我创建了一个变量
cfg = waterot.cfg
,然后在 pycharm 中创建了一个新文件“ waterot.cfg
”,这自动创建了一个pyvenv.cfg
文件,我不知道这是什么,我删除的代码出现错误pyvenv.cfg
文件并从.cfg
更改为.txt
。 Now when I run my code I get an error No pyvvenv.cfg file
现在,当我运行代码时出现错误
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()
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如果您知道用于创建虚拟环境的 python 发行版的路径及其版本,您可以自己创建一个包含以下内容的
pyvenv.cfg
文件
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. <location-of-python-exe>
是python.exe
所在的文件夹,用于创建 python 虚拟环境。 Example C:\Python\Python385-64
.C:\Python\Python385-64
。<version>
is the version of the python, at <location-of-python-exe>
. <version>
是 python 的版本,位于<location-of-python-exe>
。 You can check it by running <location-of-python-exe>\python.exe
.<location-of-python-exe>\python.exe
来检查它。 Example: 3.8.5
.3.8.5
。 Valid locations for the pyvenv.cfg
are ( PEP405 ): pyvenv.cfg
的有效位置是( PEP405 ):
venv/Scripts/pyvenv.cfg
), ie in the same folder with python.exe
.venv/Scripts/pyvenv.cfg
) 旁边,即与python.exe
位于同一文件夹中。venv/pyvenv.cfg
)venv/pyvenv.cfg
) where venv
is the assumed name of the virtual environment (could be something else, too).其中
venv
是虚拟环境的假定名称(也可以是其他名称)。
the python.exe must be name like this. python.exe 必须是这样的名称。 I had py.exe and it did not work.
我有 py.exe 但它不起作用。 Create the file: pyvenv.cfg and store it in the venv directory.
创建文件:pyvenv.cfg,存放在venv目录下。
home = C:\Windows
include-system-site-packages = false
version = Flask 2.3.2
pyvenv.cfg
is a configuration file for a virtual environment . pyvenv.cfg
是虚拟环境的配置文件。 Without knowing how you set things up, I assume Pycharm made the virtual environment .在不知道您如何设置的情况下,我假设Pycharm 制作了虚拟环境。
You should not delete the pyvenv.cfg
file if you want the virtual environment to work.如果您希望虚拟环境正常工作,则不应删除
pyvenv.cfg
文件。
With PyCharm you can restore that change in a couple of clicks:使用PyCharm ,您只需单击几下即可恢复该更改:
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.
右侧窗格显示了一个差异查看器,其中显示了每个修订版与文件的当前 state 之间的差异。
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.要将整个文件或目录恢复到此版本的 state,请右键单击它并从上下文菜单中选择恢复或单击工具栏上的恢复图标。
To restore a specific code fragment , select the revision that contains that fragment.要恢复特定代码片段,请 select 包含该片段的修订版。 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.
在右侧的差异视图中,找到要恢复的代码,单击 V 形按钮 V 形按钮从左侧窗格中复制它。
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.
我只是删除现有的venv目录并从我的编辑器中设置项目解释器。 PyCharm Editor Setting Thanks
PyCharm 编辑器设置谢谢
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. 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.
它对我有用。
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.我在 Windows 上作为一个不同的用户使用一些丑陋的 pywin32 代码启动了一个进程,当我遇到
No pyvenv.cfg file
时,我的 venv 中的python.exe
返回代码为 106。
Long story short, I fixed it by replacing the relative path to the exe with an absolute path.长话短说,我通过用绝对路径替换 exe 的相对路径来修复它。
venv\Scripts\python.exe
venv\Scripts\python.exe
C:\...\venv\Scripts\python.exe
C:\...\venv\Scripts\python.exe
I tried to read the above solutions but did not understand.我试图阅读上述解决方案但不明白。 I uninstalled Python and reinstalled it again , and everything worked well.
我卸载了 Python 并重新安装了一遍,一切正常。 The error disappeared.
错误消失了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.