Activating Python Virtual Envornment
Creater requirements.txt from all the installed packages in a virtual env:
First activate the virtualenv, then run:
pip freeze > requirements.txt
.
Requirements.txt can also be installed from (though make sure you’re in your virtualenv first) using:
pip install -r requirements.txt
Converting json into yaml
import json
import yaml
with open('myfile.json','r') as json_file:
ourjson = json.load(json_file)
json_file.close()
print(ourjson)
print(yaml.dump(ourjson))
And yaml into JSON
import json
import yaml
yaml_file = open("myfile.yaml","r")
pythondata = yaml.safe_load(yaml_file)
print(json.dumps(pythondata))