The parameter env indicates the name of the environment, you can use any name you like instead of using env
.
python3 -m venv env
source env/bin/activate
This should point to .../env/bin/python
which python
Okay, this is wrong and stupid but it works. This is a One-Liner that reads environment.yml
and converts it into a proper formatted dependency file for pip.
python -c "import base64; exec(base64.decodebytes(b'aW5kZXggPSBOb25lCmYgICAgID0gb3BlbigiZW52aXJvbm1lbnQueW1sIiwgInIiKS5yZWFkKCku\nc3BsaXRsaW5lcygpCgpmb3IgbGluZSBpbiBmOgogICAgaWYgbGluZS5zdGFydHN3aXRoKCdkZXBl\nbmRlbmNpZXMnKToKICAgICAgICBpbmRleCA9IGYuaW5kZXgobGluZSkrMQogICAgICAgIGJyZWFr\nCgppZiBpbmRleDoKICAgIHdpdGggb3BlbigicmVxdWlyZW1lbnRzLnR4dCIsICJ3IikgYXMgbzoK\nICAgICAgICBmb3IgbGluZSBpbiBmW2luZGV4Ol06CiAgICAgICAgICAgIG8ud3JpdGUoIiA9PSAi\nLmpvaW4obGluZS5zcGxpdCgiLSIpWy0xXS5zdHJpcCgpLnNwbGl0KCI9IilbOjJdKSArICJcbiIp\nCgpwcmludCgiZG9uZS4iKQ=='))"
Here's the content of that suspicious looking base64-encoded string:
index = None
f = open("environment.yml", "r").read().splitlines()
for line in f:
if line.startswith('dependencies'):
index = f.index(line)+1
break
if index:
with open("requirements.txt", "w") as o:
for line in f[index:]:
o.write(" == ".join(line.split("-")[-1].strip().split("=")[:2]) + "\n")
print("done.")
deactivate