Disclaimer: I am getting more and more accustomed with PowerShell, but I am rather inexperienced with PowerShell.
I would like to use PowerShell together with here-string syntax to write the pip.ini
and .condarc
configuration files to use the Python package managers pip, conda, respectively.
With the .condarc
, there is no error, but I think I had to rewrite it again in Notepad++
to really make it work - I think that it is a file encoding issue:
mkdir 'C:\ProgramData\conda\.condarc'
echo @"
show_channel_urls: true
allow_other_channels: false
report_errors: false
remote_read_timeout_secs: 120
"@ > C:\ProgramData\conda\.condarc
And the following gives an error for pip.ini because of [global]:
mkdir 'C:\ProgramData\pip\pip.ini'
echo @"
[global]
index = https://xxxx/nexus/repository/xxxx/pypi
index-url = https://xxxx:8443/nexus/repository/xxxx/simple
trusted-host = xxxx:8443
"@ > C:\ProgramData\pip\pip.ini
Get-Content pip.ini
works well, but pip config list -v
returns:
PS C:\Program Files> pip config list -v
Configuration file could not be loaded.
File contains no section headers.
file: 'C:\\ProgramData\\pip\\pip.ini', line: 1
'ÿþ[\x00g\x00l\x00o\x00b\x00a\x00l\x00]\x00\n'
Remark: xxxx represents sensitive company information, therefore replaces real text.
I also tried to escape the square brackets with `, but without success.
Is there a way to specify some file encoding like UTF-8 above or can the problem be somehow solved in another automatized way?