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
. 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()
asked Apr 4, 2020 at 10:01
2
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.
vvvvv
23.8k19 gold badges48 silver badges75 bronze badges
answered Jul 27, 2021 at 8:40
0
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 thepython.exe
is located that was used to create the python virtual environment. ExampleC:PythonPython385-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 withpython.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).
answered Apr 2, 2021 at 15:57
Niko PasanenNiko Pasanen
27k10 gold badges92 silver badges96 bronze badges
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.
answered Jun 7, 2021 at 16:48
RoeeRoee
1131 silver badge4 bronze badges
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.
answered Jan 31, 2022 at 17:04
1
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):
venvScriptspython.exe
- Absolute path (good):
C:...venvScriptspython.exe
answered Mar 6 at 16:26
xjclxjcl
12.1k6 gold badges66 silver badges86 bronze badges
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.
answered May 14 at 9:30
Привет. Сам решил проблему.
Тут дело не в коде. В настройках. Я искал назначение pyvenv.cfg файла, сходу наткнулся на статью на хабре:
Питон в коробке – venv в python 3.3
Наверняка, большинство из тех, кто разрабатывает или деплоит Python приложения, использует виртуальные окружения. В частности через virtualenv , написанный Ian Bicking. Идея оказалась так хороша и…
habr.com
Прочитал, суть понял, но c установкой виртуальной среды для python немного подзавис. Поискал и нашел вот эту статью:
через командную строку установил Virtualenv, добавил его место нахождение в PATH.
Уже в настройках PyCharm, в разделе Python Interpreter, указал указал путь до установленной программы.
Все заработало.
Вероятно, можно было и не мучаться с поисками предназначения pyvenv.cfg, а сразу залезть в настройки и в разделе Python Interpreter кликнуть на значок «шестеренки» и поменять base interpreter на один из имеющихся там вариантов. Результат тот же.
У меня согласно настройкам указанный путь интерпретатора указывал на пустую папку Scripts, что приводило к ошибке ниже.А вот почему сбились эти настройки, понять не могу.
[Solved this two Stack Over Flow issue:
1)
https://stackoverflow.com/questions/52404529/cannot-setup-a-python-sdk-in-pycharm-project-using-virtualenv-after-os-reinsta/70457029#70457029
2) https://stackoverflow.com/questions/61026458/no-pyvenv-cfg-file]
Delete venv (Virtual Environment) folder if it exists in the project
then go to File>Settings>Project>Python Interpreter . Click the Python Interpreter box and select Show all . Delete Invalid Interpreter by clicking (-)
Click + to create a new venv
You may see this then:
Now run a code and it will be solved
What should I do if there is a No pyvenv.cfg file error in pycharm
What should I do if there is a No pyvenv.cfg file error in pycharm? Mostly, I deleted the file by mistake when I deleted the file pyvenv.cfg. Just find the history record and retrieve it.
- First, right click on the item to be restored and find show History under local History
2. Find the status of not deleted pyvencv.cfg
- Then click revert in the upper left corner.
Intelligent Recommendation
More Recommendation
What should I do?
This article will share some common means of front-end performance optimization, including reducing the number of requests, reducing resource size, various caches, pretreatment, and long connection me…
What should I do
difficulty: The method is a static method. If the injection object is used, it is definitely not static If we want to inject the object, then our tool class will be in the container If we use @Bean an…
I am working with a Python virtual environment on a Windows machine. I used venv with Python 3.10 to create the environment and pip to install libraries. I have used this environment successfully with Jupyter Lab — launching it from the command line.
(as an aside, I then installed a separate Python 3.7 virtual environment that I used with PyCharm. The following error began after that action).
I now get the following error when I launch Jupyter Lab:
(extractpdf) C:venvextractpdf>jupyter lab
No pyvenv.cfg file
The above directory (C:venvextractpdf
) does in fact contain a pyvenv.cfg file with the following content, which looks as expected according to this answer:
home = C:Python310
include-system-site-packages = false
version = 3.10.1
I deleted the virtual environment, reinstalled Python 3.10.1, and recreated the virtual environment, while this error persists.
This error is occurring with my virtual environments, even when a pyvenv.cfg file exists.
The following system interpreters do not have a pyvenv.cfg file.
My Python 3.7 system interpreter gives this error:
C:Python37>python
No pyvenv.cfg file
while my Python 3.10 system interpreter does not produce an error.
C:Python310>python
Python 3.10.1 (tags/v3.10.1:2cd268a, Dec 6 2021, 19:10:37) [MSC v.1929 64 bit (AMD64)] on win32