No pyvenv cfg file pycharm как исправить

от admin

Ошибка "No pyvenv.cfg file" при работе с PyCharm

ОС — Windows 10
Python 3.8.2
Package Version
——— ———-
certifi 2020.4.5.1
chardet 3.0.4
geojson 2.5.0
idna 2.9
pip 20.1.1
pyowm 2.10.0
requests 2.23.0
urllib3 1.25.9

Учу Python, третью неделю пользуюсь PyCharm для решения учебных задач.
При попытке проверять решения, программа стала выдавать ошибку No pyvenv.cfg file
Самостоятельно решение проблемы найти не смог, прошу помочь с решение проблемы.
Заранее благодарю.

Bibliotekar
Новичок
  • Май 29, 2020
  • #4

Привет. Сам решил проблему.
Тут дело не в коде. В настройках. Я искал назначение pyvenv.cfg файла, сходу наткнулся на статью на хабре:

Питон в коробке – venv в python 3.3

habr.com

Прочитал, суть понял, но c установкой виртуальной среды для python немного подзавис. Поискал и нашел вот эту статью:

через командную строку установил Virtualenv, добавил его место нахождение в PATH.
Уже
в настройках PyCharm, в разделе Python Interpreter, указал указал путь до установленной программы.
Все заработало.

Вероятно, можно было и не мучаться с поисками предназначения pyvenv.cfg , а сразу залезть в настройки и в разделе Python Interpreter кликнуть на значок "шестеренки" и поменять base interpreter на один из имеющихся там вариантов. Результат тот же.

У меня согласно настройкам указанный путь интерпретатора указывал на пустую папку Scripts, что приводило к ошибке ниже.А вот почему сбились эти настройки, понять не могу.

fedor11
Новичок
  • Май 29, 2020
  • #2
fedor11
Новичок
  • Май 29, 2020
  • #3
iddypak
Новичок
  • Ноя 6, 2021
  • #5

Привет. Сам решил проблему.
Тут дело не в коде. В настройках. Я искал назначение pyvenv.cfg файла, сходу наткнулся на статью на хабре:

Питон в коробке – venv в python 3.3

habr.com

Прочитал, суть понял, но c установкой виртуальной среды для python немного подзавис. Поискал и нашел вот эту статью:

через командную строку установил Virtualenv, добавил его место нахождение в PATH.
Уже
в настройках PyCharm, в разделе Python Interpreter, указал указал путь до установленной программы.
Все заработало.

Вероятно, можно было и не мучаться с поисками предназначения pyvenv.cfg , а сразу залезть в настройки и в разделе Python Interpreter кликнуть на значок "шестеренки" и поменять base interpreter на один из имеющихся там вариантов. Результат тот же.

У меня согласно настройкам указанный путь интерпретатора указывал на пустую папку Scripts, что приводило к ошибке ниже.А вот почему сбились эти настройки, понять не могу.

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 . Now when I run my code I get an error No pyvvenv.cfg file

This is the problematic piece of code

6 Answers 6

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's user avatar

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

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

np8's user avatar

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.

no pyvenv.cfg file or, Python Interpreter error

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

2

3

Click + to create a new venv

4

5

You may see this then:

6
Now run a code and it will be solved
Code run

Python Launcher is sorry to say. No pyvenv.cfg file #85537

The text was updated successfully, but these errors were encountered:

It seems like you’re trying to launch the python.exe that is created for a virtual environment rather than the actual one. This probably means that at some point you created a virtual environment and updated your file association to launch it.

The best thing to do is to right-click your .pyw file, choose «Open With», «Choose another app», enable «Always open . » and choose «Python» from its list (the icon should have a space shuttle being launched). That will switch you back to the original file association.

Mr. Dower, I apologize for not being more specific. since this is Windows based and not console driven, the file used for execution should be pythonw.exe according to the instructions at https://github.com/gurnec/decrypt_bitcoinj_seed so I right clicked on decrypt_bitcoinj_seed.pyw and went to properties and changed it’s association to pythonw.exe so it would run in a non-console manner. After doing this however, it still didn’t work with the error «No pyvenv.cfg file». Would I still follow your instructions, choosing Python instead of pythonw.exe? Do you happen to know why the pyvenv.cfg never got created in the first place? After all, when I do a search it’s no where to be found on my C: drive.

Does anyone know why when Python Launcher is executed by double clicking on the Python script called ecrypt_bitcoinj_seed.pyw a small window pops of stating. «Python Launcher is sorry to say. No pyvenv.cfg file» as in the image? Why wouldn’t the pyvenv.cfg file NOT get created like it’s supposed to. After doing a search for it on C: drive it is not found. If anyone has a copy of the file, would you please provide it and also tell me the folder to place it in? Thank you

«Python Launcher is sorry to say. No pyvenv.cfg file»

As already mentioned, that it fails with this error means you’re running a virtual-environment launcher instead of a base Python executable. That it displays a message box means you ran a GUI pythonw.exe virtual-environment launcher. pyvenv.cfg is a configuration file that the virtual-environment launcher looks for beside the executable, or one directory up. It tells the launcher where to find the base python[w].exe executable.

As already suggested, you should associate .py[w] scripts with the «Python» app that depicts a rocket/shuttle being launched on its icon. This will associate .py[w] scripts with the py[w].exe launcher, and it also associates them with a shell drop handler that allows files to be dragged and dropped on a script icon in Explorer.

it fails with this error means you’re running a virtual-environment launcher instead of a base Python executable.

Похожие статьи