Downloading different versions of python






















How this works is that the latest 2. So if you have multiple 2. The same applies for a generic 3: the latest Python version in the 3. For example, if you have Python 2. In this case, that script will run against Python 2. You could change this operation by:. This probably seems odd behavior but I think the rationale here is two-fold. One is that many people using a Python ecosystem are still stuck in the 2. So a default of Python 2 may make sense. Second is that Unix-based versions tend to rely on symbolic links from python to a specific version and that tends to be a 2.

So I think the Windows launcher is trying to emulate the most likely use case for Python developers, but this can come at the expense of newcomers to Python. Earlier, in particular with shebang lines, I mentioned there was a caveat that I would mention. That particular caveat is that the new Windows launcher recognizes Unix!

It seems the launcher requires you to follow one of the following patterns:. Another caveat to be aware of is that if there are both shebang lines in the Python script and a version number switch is provided in the command line used to execute that script, the command line version will override that specified in the shebang line.

Note that both launchers should have automatically disabled setting the PATH to a location of python. This is important as well. Another caveat, although a potential useful one, is that the launcher will also let you distinguish between bit and bit versions of Python that are installed. So I can have Python 2. Using the launcher would allow me to distinguish between all of those. The launcher turns that around and always attempts to use the latest version that it can find on the machine.

If you request a version of Python that is not installed, you will get an error message along the lines of Requested Python version 2. Beyond that, I have not found too many other caveats worthy of mention.

If Python is your language of choice, but you are worried about the 2. This should be the accepted answer. The others above this do not work. Have tried this on a Windows machine and it works If you wanna install opencv for python version 3. Anurag Bhalekar Anurag Bhalekar 5 5 silver badges 7 7 bronze badges.

Can i do this without administrator privilege? NaveenKumar yes, you can. Alternatively, if you want to install specific version of the package with the specific version of python, this is the way sudo python2. Python 2 sudo pip2 install johnbonjovi Python 3 sudo pip3 install johnbonjovi. This doesn't work when you have multiple installations of python3. Bhaskar Bhuyan Bhaskar Bhuyan 3 3 silver badges 14 14 bronze badges. Gayan Weerakutti Gayan Weerakutti 8, 57 57 silver badges 58 58 bronze badges.

Then pip3 will install packages only for default python3. RKelley RKelley 6 6 silver badges 15 15 bronze badges. Making a simple change worked for me. Raji Raji 85 6 6 bronze badges. The Overflow Blog. Who owns this outage? Building intelligent escalation chains for modern SRE. Podcast Who is building clouds for the independent developer? Featured on Meta. Now live: A fully responsive profile. Reducing the weight of our footer. Visit chat. Linked 0. Collectives on Stack Overflow.

Learn more. Installing multiple versions of a package with pip Ask Question. Asked 10 years, 4 months ago. Active 3 months ago. Viewed 47k times. Improve this question. Jeremy 1. On a side note, the scenario in this question, and the hacky solution in the currently accepted answer are a good example of why a package owner should not and must not be picky to pin an exact version of their dependency.

More details here — RayLuo. RobertLugg, there is a difference between a mid-tier library and a final application. Pray won't even help them. Show 2 more comments. Active Oldest Votes. The best you can hope is for this hack to work. Improve this answer. To run your script in Python version 2: Simply add the following line of code as the first line to your any Python script.

Happy Pythoning! Python shebang. Aniruddha Chaudhari. I am complete Python Nut, love Linux and vim as an editor. I keep sharing my coding knowledge and my own experience on CSEstack. Your name can also be listed here. Got a tip?



0コメント

  • 1000 / 1000