I can't connect to RPC from python. JSONRPCException: -342
Indeed to use bitcoinrpc, you need to set the username and password in bitcoin.conf by:
rpcauth=user:salt$hash of password

which you can generate using https://github.com/bitcoin/bitcoin/blob/master/share/rpcauth/rpcauth.py. Simply shutdown bitcoind, add this to bitcoin.conf, restart, and you'll immediately be able to run commands in python like
print(rpc_connection.getinfo())