LinkError: post-link script failed for package defaults::scikit-learn-1.0.1-py38 hf11a4ad_0

I want to install the scikit-learn package in an environment that previously TensorFlow, NumPy, pandas, scipy, and matplotlib were installed. I installed the scikit-learn package in Windows 7 64-bit. When I write: conda install scikit-learn ; it shows:

Collecting package metadata (current_repodata.json): done 

Solving environment: done

 #All requested packages already installed.

When, in activated enviroment I write: conda install scikit-learn ; it shows:

Collecting package metadata (current_repodata.json): done

Solving environment: done

##Package Plan##

  environment location: G:\programfile\anaconda3\envs\tf

  added / updated specs:

    -scikit-learn


The following NEW packages will be INSTALLED:

  joblib             pkgs/main/noarch::joblib-1.1.0-pyhd3eb1b0_0   
 scikit-learn       pkgs/main/win-64::scikit-learn-1.0.1-py38hf11a4ad_0
 threadpoolctl      pkgs/main/noarch::threadpoolctl-2.2.0-pyh0d69192_0


Proceed ([y]/n)? y

Preparing transaction: done 
Verifying transaction: done 
Executing transaction: done 
ERROR conda.core.link:_execute(699): An error occurred while installing 
package 'defaults::scikit-learn-1.0.1-py38hf11a4ad_0'. Rolling back 
transaction: done

LinkError: post-link script failed for package

defaults::scikit-learn-1.0.1-py38 hf11a4ad_0 location of failed

script: G:\programfile\anaconda3\envs\tf\Scripts\.scikit-lear n-post-link.bat

==> script messages <== 
<None>
==> script output <== 
stdout: 
stderr: 
return code: 1  
()

I want to install the scikit-learn package in an environment that previously TensorFlow, NumPy, pandas, scipy, and matplotlib were installed. I installed the scikit-learn package in Windows 7 64-bit. When I write: conda install scikit-learn ; it shows:

Collecting package metadata (current_repodata.json): done Solving environment: done

 #All requested packages already installed.

When, in activated enviroment I write: conda install scikit-learn ; it shows:

Collecting package metadata (current_repodata.json): done

Solving environment: done

##Package Plan##

  environment location: G:\programfile\anaconda3\envs\tf

  added / updated specs:

    -scikit-learn


The following NEW packages will be INSTALLED:

  joblib             pkgs/main/noarch::joblib-1.1.0-pyhd3eb1b0_0   
 scikit-learn       pkgs/main/win-64::scikit-learn-1.0.1-py38hf11a4ad_0
 threadpoolctl      pkgs/main/noarch::threadpoolctl-2.2.0-pyh0d69192_0


Proceed ([y]/n)? y

Preparing transaction: done 
Verifying transaction: done 
Executing transaction: done 
ERROR conda.core.link:_execute(699): An error occurred while installing 
package 'defaults::scikit-learn-1.0.1-py38hf11a4ad_0'. Rolling back 
transaction: done

LinkError: post-link script failed for package

defaults::scikit-learn-1.0.1-py38 hf11a4ad_0 location of failed

script: G:\programfile\anaconda3\envs\tf\Scripts\.scikit-lear n-post-link.bat

==> script messages <== 
<None>
==> script output <== 
stdout: 
stderr: 
return code: 1  
()

I updated anaconda and use python 3.8.5 as conda compiler.

What are the following terms mean?
ERROR conda.core.link:_execute(699)

I want to know what is wrong I do?

You’ll probably need to contact Anaconda support for this one. It seems to be something in Conda, and the team behind that doesn’t hang out here that often.

Just to be clear, this is likely a machine-specific issue installing the scikit-learn package with conda from the Anaconda defaults channel, not anything to do with Python itself. That said, I can try to help…

It isn’t made clear, but I assume you mean you tried that in base, in which scikit-learn is already installed by default for full-fat Anaconda installs. You can confirm it is installed with conda list scikit-learn, and test it out with python -c "import sklearn"

When, in activated enviroment I write: conda install scikit-learn ; it shows:

Looks like a post-build script failed, without giving any real information on the source of the error. Since I don’t see the post build scripts in the conda-forge feedstock for Scikit-Learn so it seems like its something specific to the Anaconda official defaults channel, and thus I have no direct insight.

However, I do have a few suggestions to try first, which are pretty common to troubleshooting any Anaconda package install:

  • Upgrade conda with conda -n base update conda and try installing in your env again
  • Occasionally, I can run into issues with files being locked on Windows due to being in use. Try rebooting your machine and then run the install command again.
  • Try again from an admin Anaconda prompt (right click Anaconda Prompt and select “Run as administrator”)
  • If all of that still doesn’t work, try installing your needed packages in a fresh environment, from the community conda-forge channel: conda install -c conda-forge -n sklearn-env numpy scipy pandas matplotlib tensorflow scikit-learn then active that and try importing it there.
  • If that doesn’t work, reinstall the latest version of Anaconda/Miniconda
  • If that doesn’t work, reach out to Anaconda support channels (or at any point previous, if you have a support contract)

Best of luck!