You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

How do I make OSX Server 5.0 use Python 3.5?

El Capitan and OS X Server 5.0 use Python 2.7 by default. I've installed Python 3.5, but how do I make OS X Server 5.0 use it for wsgi without breaking El Capitan's dependence on Python 2.7?


Basically, I want Mac OS X Server 5.0 to use Python 3.5 instead of Python 2.7.

Posted on Nov 10, 2015 3:48 AM

Reply
Question marked as Top-ranking reply

Posted on Nov 11, 2015 2:16 AM

I have not had to do this with the current Server 5.0 but have done it previously with Server 4.x (I now use Linux Virtual machines for this sort of purpose but the solution is exactly the same as you need for OS X Server.)


First absolutely do not try updating the built-in components of any Apple included software e.g. Apache, and in your case Python. While it may be possible to do this, not only are Apple making such steps harder to do by adding new security measures to prevent their 'official' software being modified/hacked without your knowledge, trying this approach makes it extremely likely you will break something especially the integration between Server.app and these components and also make it likely that installing future official Apple updates will either fail or downgrade what you did anyway.


So, as I implied above I have used a solution before which works, and does not cause the problems described above - at least with regards to Python. The approach you need to adopt is to leave Apple's Python well alone and instead install a separate copy specifically to be used with your own website, indeed if you were to run multiple websites - each needing to use Python you would have separate copies of Python for each site because it is quite common for various Python based projects to be dependent on specific Python versions. So common is this that there is a tool specifically for doing this called VirtualEnv.


See http://docs.python-guide.org/en/latest/dev/virtualenvs/


The way this works is -


  • You install VirtualEnv
  • You run VirtualEnv and create a virtual environment for your website
  • You install the specific Python version you need for your website in to that virtual environment
  • You install all the Python modules you need for your website in to that virtual environment
  • You install your Python code in to that virtual environment


Then you have appropriate entries in your website conf file to run within that virtual environment.


By adopting this approach it is then possible to simultaneously run multiple different versions of Python and not have them conflict with each other.


Note: To install VirtualEnv in OS X do the following.


sudo easy_install virtualenv

1 reply
Question marked as Top-ranking reply

Nov 11, 2015 2:16 AM in response to Emmerac

I have not had to do this with the current Server 5.0 but have done it previously with Server 4.x (I now use Linux Virtual machines for this sort of purpose but the solution is exactly the same as you need for OS X Server.)


First absolutely do not try updating the built-in components of any Apple included software e.g. Apache, and in your case Python. While it may be possible to do this, not only are Apple making such steps harder to do by adding new security measures to prevent their 'official' software being modified/hacked without your knowledge, trying this approach makes it extremely likely you will break something especially the integration between Server.app and these components and also make it likely that installing future official Apple updates will either fail or downgrade what you did anyway.


So, as I implied above I have used a solution before which works, and does not cause the problems described above - at least with regards to Python. The approach you need to adopt is to leave Apple's Python well alone and instead install a separate copy specifically to be used with your own website, indeed if you were to run multiple websites - each needing to use Python you would have separate copies of Python for each site because it is quite common for various Python based projects to be dependent on specific Python versions. So common is this that there is a tool specifically for doing this called VirtualEnv.


See http://docs.python-guide.org/en/latest/dev/virtualenvs/


The way this works is -


  • You install VirtualEnv
  • You run VirtualEnv and create a virtual environment for your website
  • You install the specific Python version you need for your website in to that virtual environment
  • You install all the Python modules you need for your website in to that virtual environment
  • You install your Python code in to that virtual environment


Then you have appropriate entries in your website conf file to run within that virtual environment.


By adopting this approach it is then possible to simultaneously run multiple different versions of Python and not have them conflict with each other.


Note: To install VirtualEnv in OS X do the following.


sudo easy_install virtualenv

How do I make OSX Server 5.0 use Python 3.5?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.