r/Python • • Apr 30 '18

xkcd: Python Environment

Post image
2.4k Upvotes

388 comments sorted by

View all comments

Show parent comments

0

u/meandertothehorizon It works on my machine May 01 '18

Sorry, the tools are there, I’m impressed at your ability to over complicate this. You come bitching, and snarky - so.. enjoy your misery? Not sure what you want here.

1

u/TBSchemer May 01 '18

You literally haven't even addressed my use case.

1

u/meandertothehorizon It works on my machine May 02 '18
C:\>mkdir %USERPROFILE%\bin

C:\>set PATH=%PATH%;%USERPROFILE%\bin

C:\>mkdir %USERPROFILE%\venv

C:\>C:\Python27\Scripts\pip.exe install virtualenv
Collecting virtualenv
  Downloading https://files.pythonhosted.org/packages/ed/ea/e20b5cbebf45d3096e8138ab74eda139595d827677f38e9dd543e6015bdf/virtualenv-15.2.0-py2.py3-none-any.whl (2.6MB)
    100% |################################| 2.6MB 261kB/s
Installing collected packages: virtualenv
Successfully installed virtualenv-15.2.0

C:\>C:\Python27\Scripts\virtualenv.exe %USERPROFILE%\venv\py27venv
New python executable in C:\Users\meandertothehorizon\venv\py27venv\Scripts\python.exe
Installing setuptools, pip, wheel...done.

C:\>C:\Python34\python.exe -m venv %USERPROFILE%\venv\py34venv

C:\>C:\Python35\python.exe -m venv %USERPROFILE%\venv\py35venv

C:\>C:\Python36\python.exe -m venv %USERPROFILE%\venv\py36venv

C:\>for %x in (27, 34, 35, 36) do echo #!%USERPROFILE%\venv\py%xvenv\Scripts\python.exe > %USERPROFILE%\bin\py%x-test-script.py

C:\>echo #!C:\Users\meandertothehorizon\venv\py27venv\Scripts\python.exe  1>C:\Users\meandertothehorizon\bin\py27-test-script.py

C:\>echo #!C:\Users\meandertothehorizon\venv\py34venv\Scripts\python.exe  1>C:\Users\meandertothehorizon\bin\py34-test-script.py

C:\>echo #!C:\Users\meandertothehorizon\venv\py35venv\Scripts\python.exe  1>C:\Users\meandertothehorizon\bin\py35-test-script.py

C:\>echo #!C:\Users\meandertothehorizon\venv\py36venv\Scripts\python.exe  1>C:\Users\meandertothehorizon\bin\py36-test-script.py

C:\>for %x in (27, 34, 35, 36) do echo import sys; print(sys.version) >> %USERPROFILE%\bin\py%x-test-script.py

C:\>echo import sys; print(sys.version)  1>>C:\Users\meandertothehorizon\bin\py27-test-script.py

C:\>echo import sys; print(sys.version)  1>>C:\Users\meandertothehorizon\bin\py34-test-script.py

C:\>echo import sys; print(sys.version)  1>>C:\Users\meandertothehorizon\bin\py35-test-script.py

C:\>echo import sys; print(sys.version)  1>>C:\Users\meandertothehorizon\bin\py36-test-script.py

C:\>for %x in (27, 34, 35, 36) do py%x-test-script

C:\>py27-test-script
2.7.15 (v2.7.15:ca079a3ea3, Apr 30 2018, 16:22:17) [MSC v.1500 32 bit (Intel)]

C:\>py34-test-script
3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 19:28:18) [MSC v.1600 32 bit (Intel)]

C:\>py35-test-script
3.5.4 (v3.5.4:3f56838, Aug  8 2017, 02:07:06) [MSC v.1900 32 bit (Intel)]

C:\>py36-test-script
3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 16:07:46) [MSC v.1900 32 bit (Intel)]

You will notice I did not use virtualenvwrapper-win because you should not be using it. You obviously do not understand how things are working here (which I will say is normal, not everyone can be an expert at everything) and yet at the same time you seem to want to maintain some sense of superiority by disregarding the advice of people who know more than you. The fact that you could not get the above working for weeks tells me that you are not willing to simply RTFM and gain an understanding of the tools you use.

1

u/TBSchemer May 02 '18

The entire point of everything I'm trying to set up here is to avoid having to type the full path to every binary on my system every time I want to use it.

For example, in my Linux setup with virtualenvwrapper, if I want to create and activate a virtual environment named "testenv", I will simply type:

> mkvirtualenv testenv
> workon testenv

Similarly, it's not really correct to have the full binary path in your shebang lines, as that destroys cross-platform support (a crucial doctrine of Python). It was after I RTFM that I discovered that the cross-platform shebangs can work if you configure Python Launcher For Windows. Yet, as I described, set-up of PLFW didn't work exactly according to TFM.

→ More replies (0)