Failed to create a virtual environment

Hi! Whenever I create a new project, or try to create a run configuration, an error occurs saying: "Failed to create a virtual environment"

(A picture of the error)

 

(My settings and stuff for the project)

0
8 comments

Hi, `idea.log` in "Help | Show Long in ..." should reveal the problem. Try to reproduce the problem and send the log to pycharm-support@jetbrains.com. Feel free to inspect the file yourself.

P.S.: We will improve the error messaging.

0

Create a virtual environment
Ensure that you have downloaded and installed Python on your computer.

Do one of the following:

Click the Python Interpreter selector and choose Add Interpreter.

Press Ctrl+Alt+S to open the project Settings/Preferences and go to Project <project name> | Python Interpreter. Click Python interpreter and select Add.

In the left-hand pane of the Add Python Interpreter dialog, select Virtualenv Environment. The following actions depend on whether the virtual environment existed before. DGCustomerFirst.com

0

I have the above problem on windows. How do I solve it?

0

Aiden Song There could be many root causes for this issue. Could you please send the logs as instructed by Pavel above?

0

I arrived here from google with the same issue.  I can't create or use ANY env or venv from existing or new projects within Pycharm after a fresh install on a VM.

In my cause the "cause" is network UNC paths, AGAIN.  This used to be fixed.  Seems Windows 10 in a VM does not handle network file transactions very well.  Lot of errors like "not a directory", when in fact it IS a directory and it is perfectly valid.  It seems as though the directory gets created, but there is a concurrency issue with the next thread trying to read/write to the directory and it seemingly hasn't actually been created "yet".  Suggesting an async setting in the network or disk settings.

eg:

NotADirectoryError: [WinError 267] The directory name is invalid: '\\\\10.0.0.199\\paul\\devel\\home_auto\\home_heating\\venv\\Lib\\site-packages'

However, if I copy and paste that line into explorer.... it opens fine.

I do not, in my case, think this is a JetBrains issues as Eclipse does similar things on this VM when anything is put on network drives.  I need to check network synchronisation settings.

0

Now I have this:

 

IsADirectoryError: [Errno 21] Is a directory: '\\\\10.0.0.199\\paul\\devel\\home_auto\\home_heating\\venv\\Lib\\site-packages\\setuptools\\command\\__init__.py'

No... it's really not.

<insert frustrated rant> about Windows networking being junk.  Network drives SHOULD BE 100% TRANSPARENT!

0

I suffered from similar problem.

In my case, console encoding was a problem. Changing console encoding from x-windows-949 to utf-8 fixed the problem.

---------------------------------------------

2022-11-02 23:20:57,289 [ 341292]   INFO - #c.j.p.p.PyPackageManagerImpl - Running packaging tool: C:\Users\ysung\AppData\Local\Programs\Python\Python311\python.exe -S C:\Program Files\JetBrains\PyCharm 2022.2.3\plugins\python\helpers\virtualenv.pyz D:\git\slack-proxy\venv
2022-11-02 23:20:57,289 [ 341292]   WARN - #c.j.p.s.PySdkUtil - Charset x-windows-949 is not UTF-8, which is likely lead to troubles
2022-11-02 23:20:57,319 [ 341322]   INFO - #c.j.p.p.PyPackageManagerImpl - Exit code 1
2022-11-02 23:20:57,319 [ 341322]   INFO - #c.j.p.p.PyPackageManagerImpl - Fatal Python error: init_stdio_encoding: failed to get the Python codec name of the stdio encoding
Python runtime state: core initialized
LookupError: unknown encoding: x-windows-949

Current thread 0x00007380 (most recent call first):
  <no Python frame>

2022-11-02 23:21:01,940 [ 345943]   INFO - #c.i.c.ComponentStoreImpl - Saving appCodeVisionSettings took 16 ms

-----

 

0

Ensure that Python is installed on your system and is accessible from the command line. You can check the Python version by running:

Upgrade pip: It's a good practice to ensure that your pip Siding Replacement Estimates  is up-to-date. Run the following command:

bashCopy code

python --version

0

Please sign in to leave a comment.