2

Some of you here might direct me to other questions on this site such as

  1. Error : Failed to create temp directory "C:\Users\user\AppData\Local\Temp\conda-<RANDOM>\"
  2. What is the difference between Anaconda Prompt and Anaconda Powershell Prompt?

But, I have a different problem. I reinstalled Miniconda on my C drive for the reason that might fix the problem. The problem is the "Failed to create temp directory" every time I open the Anaconda Powershell Prompt.

I have already followed some steps provided on the questions, on GitHub, and anywhere online. But, what worked for me (in the meantime) is the solution provided by Sir Ronil on the question (1) above which happened to be the answer also provided on GitHub (https://github.com/conda/conda/issues/9757).

However, when I opened Anaconda Powershell Prompt, it worked but has other problems with it. Anyways, I disregard it knowing it will work on the other prompt (cause they are the same right?) but when I opened Anaconda Prompt (CMD), the failed to create directory problem still exists. See the prompt below.

ANACONDA POWERSHELL PROMPT:

Warning: PowerShell detected that you might be using a screen reader and has disabled PSReadline
for compatibility purposes. If you want to re-enable it, run 'Import-Module PS Readline'.
    
(base) PS C:\Users\king>conda 

usage: conda-script.py [-h] [-V] command ...

ANACONDA PROMPT (CMD):

Failed to create temp directory "C:\temp\conda-<RANDOM>\"

C:\Users\king>conda

'conda' is not recognized as an internal or external command, operable program, or batch file.

Although Anaconda Powershell Prompt is working (I mean it "somehow fixed" the failed to create directory problem) it still fails to perform some codes because of errors. But, I would not discuss it here to focus on the directory problem. See the code below.

(base) PS C:\Users\king> conda install ipykernel 

CondaError: Error encountered while attempting to create cache directory. 
    Directory: C:\Users\king\AppData\Local\conda\conda\Cache\notices 
    Exception: [WinEror 2] The system cannot find the file specified: 'C:\\Users\\king\\AppData\\Local\\conda\\conda\\Cache'

I want is to make this Miniconda work on my device and install the kernels I need for VSCode to run and test our program.

  1. Why it has different errors? Why it works on the other and the other did not?
  2. How can I fix this? or any way to install the kernels and run the Jupyter on VSCode?
Yunnosch
  • 26,130
  • 9
  • 42
  • 54
JustPeter
  • 140
  • 1
  • 10
  • It's really confusing to figure out what steps you ahve performed so far. Can you add them to your question? After installing miniconda, what did you do? – FlyingTeller May 03 '23 at 10:50
  • Like what is instructed on this Youtube video sir (from the official Visual Studio Code channel). After I installed Miniconda I opened the prompt to supposedly install "ipykernel" through "conda install ipykernel." Nothing else. Then proceed to trying to fix the error. – JustPeter May 03 '23 at 20:15
  • 1
    Please do not edit solution announcements into the question. Accept (i.e. click the "tick" next to it) one of the existing answer, if there are any. You can also create your own answer, and even accept it, if your solution is not yet covered by an existing answer. Compare https://stackoverflow.com/help/self-answer – Yunnosch May 04 '23 at 13:20
  • My apologies. Yeah, I was about to do that but I need 18hrs to approve my solution thank you by the way to all who visit and commented here. – JustPeter May 04 '23 at 13:22
  • Thanks for seeing helpful people (where you could have perceived two users ganging up and bashing on you....). My pleasure to help with what are obviously harmless small things done in good faith. Have fun. – Yunnosch May 04 '23 at 13:24

1 Answers1

2

Now, while trying to find out the culprit here for I have already made and followed all the suggested solutions available online, I decided to work on Safe Mode for all the solutions did not work for me. On Safe Mode, the program works perfectly fine with no errors at all. When this worked for you it means that it is not the installation that has the problem but a program that stops the Anaconda from accessing folders.

BUT POSSIBLY IT IS THE WINDOWS SECURITY

I tried to turn off the antivirus but still, had no luck not until I found C: drive on the Protected Folders setting which is under the

Virus & threat protection > Virus & threat protection settings > Controlled folder access Manage > Controlled folder access > Protected Folders

I discovered that because C:\ Drive is protected, all the permissions and related access by other programs are prohibited and thus denied.

The Protected Folders feature in Windows helps prevent unauthorized access to important system folders. It does this by:

  • Restricting permissions on protected folders. Folders marked as "protected" will have more limited permissions, preventing unauthorized users from modifying or deleting them.

  • Preventing protected folders from being renamed or moved. This helps ensure important system folders stay in their designated locations.

  • Providing an additional layer of security. Even if a user has administrative permissions, the Protected Folders feature adds an extra check to prevent accidental or malicious changes to critical system folders.

Even when you run the prompt with administrative privileges it will not still work if the folder accessed is protected like what happened to me.

By removing the entire C: Drive on the protected folders setting, it made my Python directory problems be solved. I swear that is the only solution that completely worked for me for all the problems related to it and even my name has space in it.

I suggest being specific in protecting folders in C: Drive. It is still needed to protect your C: drive folders to prevent malicious access, renaming, or deleting them. Here are the folders that I protected:

  • C:\Windows
  • C:\Users
  • C:\ProgramFiles
  • C:\ProgramFiles (x86)
  • C:\ProgramData and so on.

Just do not include the entire C:\ drive folder since we are creating temps on either the conda_temp or temp folder.

Marking the C: drive itself as protected can cause issues by restricting permissions too tightly. Some specific folders under C: may need protection, but the drive letter itself should typically be unprotected. I was able to fix the conda prompt issue by simply un-checking the "C:" folder from the list of protected locations.

I hope this fix helped you because it did great for me.

JustPeter
  • 140
  • 1
  • 10