I’m attempting to install Anaconda using the command line and I get an error at the very end when it tries to run “conda init”. Everything installs just fine except at the last part, I get the following:
TypeError: memoryview: a bytes-like object is required, not ‘str’
(Screen shots of the full error and report are below)
Any help would be greatly appreciated.
thank you for posting.
This is a problem caused by MacOS being zsh.
To avoid this, choose “no” for the first conda init answer during installation.
Then after the installation is complete run “conda init zsh” as you show in the screenshot.
However, in this case, the shell parameter is bash, so if you refer to the following article and fix it for zsh, jupyter etc. will work normally.
Zsh on MacOS X.
The reason for this error is that in Python 3, strings are Unicode, but when transmitting on the network, the data needs to be bytes instead. We can convert bytes to string using bytes class decode() instance method, So you need to decode the bytes object to produce a string. In Python 3 , the default encoding is “utf-8” , so you can use directly:
b"python byte to string".decode("utf-8")
Python makes a clear distinction between bytes and strings . Bytes objects contain raw data — a sequence of octets — whereas strings are Unicode sequences . Conversion between these two types is explicit: you encode a string to get bytes, specifying an encoding (which defaults to UTF-8); and you decode bytes to get a string. Clients of these functions should be aware that such conversions may fail, and should consider how failures are handled.