I cannot find a good source of information on how to upgrade Django to 1.4 on TurnKey Django (based on Ubuntu 10.04). I did not worked at Unix machine for a long time and I am a bit lost. Some IRC channel?
The best way to do this is to install django 1.4 in a virtual environment.
First, install virtualenv (if its not installed already sudo apt-get install python-virtualenv)
Then, install django 1.4:
$ virtualenv --no-site-packages django_1_4
$ source django_1_4/bin/activate
(django_1_4) $ pip install django
(django_1_4) $ python
Python 2.7.3 (default, Apr 20 2012, 22:44:07)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> django.get_version()
'1.4'
After your comment, I have another suggestion. Since this is a single purpose machine, you can simply upgrade the global version of django on your machine.
First, to avoid conflicts, uninstall django if it was installed from apt:
apt-get remove --purge python-django
Then, since you already installed python-virtualenv from above, you can do this:
$ sudo pip install -U django
This will upgrade (or install) django to the latest version available to the global site packages directory.
Then you can do the same import django and then django.get_version() and it should return 1.4.
While I am having a hard time finding an official source with version information, it seems to me that the latest Django release for TurnKey Linux is (as of Dec. 2011) at most version 1.3.1.
Check out this mail archive question and click through the threads for more information. They discuss setting up the latest version of Django for TurnKey Linux using tools such as virtualenv to ensure that you are able to continue to use older (outdated) packages if need be.
Related
Goal: Have python 2.7.14 and python 3.6 on my RHEL server and use pip2/pip3 to manage both.
Note: Although this server lacks an internet connection, I can download them separately and upload them to this server.
I recently installed RHEL 7.2 on a VM, this installs python 2.7.5 by default.
I decided upgrade this by doing a parallel install of 2.7.14 (using make altinstall method and keeping the existing 2.7.5 intact). Also installed python 3.6 as I plan to port all my existing python code to it in the future.
The problem arises when I try to install pip for the Python 2.7.14 or any libraries (as you will see in a little bit).
I first did a easy_install of pip:
[root#VMW01 bin]# easy_install pip
Searching for pip
Best match: pip 9.0.1
Adding pip 9.0.1 to easy-install.pth file
Installing pip script to /usr/local/bin
Installing pip3 script to /usr/local/bin
Installing pip3.5 script to /usr/local/bin
Using /usr/local/lib/python3.6/site-packages
Processing dependencies for pip
Finished processing dependencies for pip
This installs pip for python 2.7.5 and 3.6 but not for python 2.7.14.
Next, I downloaded the get-pip.py:
This gets installed fine for python 2.7.5 but not for python 2.7.14:
[root#VMW01 pshah]# python get-pip.py
Collecting pip
Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB)
100% |████████████████████████████████| 1.3MB 978kB/s
Collecting wheel
Downloading wheel-0.30.0-py2.py3-none-any.whl (49kB)
100% |████████████████████████████████| 51kB 9.2MB/s
Installing collected packages: pip, wheel
Successfully installed pip-9.0.1 wheel-0.30.0
[root#VMW01 pshah]# /usr/local/bin/python2.7 get-pip.py
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting pip
Could not fetch URL https://pypi.python.org/simple/pip/: There was a problem confirming the ssl certificate: Can't connect to HTTPS URL because the SSL module is not available. - skipping
Could not find a version that satisfies the requirement pip (from versions: )
No matching distribution found for pip
This seems like a lack of a SSL libray.
First, I did install this using yum:
[root#VMW01 pshah]# yum install openssl
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Package 1:openssl-1.0.1e-42.el7_1.9.x86_64 already installed and latest version
Nothing to do
[root#VMW01 pshah]# yum install openssl-devel
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Package 1:openssl-devel-1.0.1e-42.el7_1.9.x86_64 already installed and latest version
Nothing to do
Second, this seems to be present for python 2.7.5
[root#VMW01 pshah]# python
Python 2.7.5 (default, Oct 11 2015, 17:47:16)
[GCC 4.8.3 20140911 (Red Hat 4.8.3-9)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
>>>
Am I overarching too much? Should I settle with the default installation of 2.7.5 and python 3.6?
I know virtualenv might be a solution here, but i'm not sure how I can make it work with Apache executing python scripts.
Thanks.
As it mentions here: https://pip.pypa.io/en/latest/installing I did a local install of pip but called the python executable for python 2.7.14.
Downloaded the .whl files for wheel, setuptools and pip and then ran the below:
[root#VMW01 pshah]# /usr/local/bin/python2.7 get-pip.py --no-index --find-link=.
Collecting pip
Collecting setuptools
Collecting wheel
Installing collected packages: pip, setuptools, wheel
Successfully installed pip-9.0.1 setuptools-36.5.0 wheel-0.30.0
I believe calling pip2.7 will install packages for the python 2.7.14 now.
Tested this by installing the xlrd library (Note - I had the xlrd tarball in the local directory):
[root#VMW01 pshah]# pip2.7 install xlrd-1.1.0.tar.gz
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Processing ./xlrd-1.1.0.tar.gz
Building wheels for collected packages: xlrd
Running setup.py bdist_wheel for xlrd ... done
Stored in directory: /root/.cache/pip/wheels/b9/dc/43/e6acfa12bc48cdf3654dd7f44c66880548ea0322324bc6095f
Successfully built xlrd
Installing collected packages: xlrd
Successfully installed xlrd-1.1.0
[root#VMW01 pshah]# /usr/local/bin/python2.7
Python 2.7.14 (default, Oct 6 2017, 18:31:52)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import xlrd
>>>
I have two versions installed in my envirment, django 1.8.7 and 1.10 which i have installed with pip! I want to use django 1.10 by default instead of the version 1.8.7. how can I do that ?
thank you
A good way to run multiple versions of Python programs is to use virtualenv.
Installation depends on your operating system, but there is more info here.
See this tutorial for information on how to use virtualenv with Django.
With virtualenvs, you can run multiple versions of Django that use multiple versions of Python. If you add virtualenvwrapper, you can use a simple command, like workon project1 to work on a Django 1.8 project that uses Python 2.7, or workon project2 to work on a Django 1.10 project that uses Python 3.5.
Edit: in 2020 you can do:
$ python3 -m venv .venv
$ source .venv/bin/activate
$ pip install django
You can install any version of Django there that you want. That version of Django will be different than any version that might be on your system.
Read more about it here: https://docs.python.org/3/library/venv.html
This is not a duplicate because the suggested article references a general question. My question refers to how do you fix paths after two versions are installed.
Im working in RHEL 7 and accidentally installed Python2.7 on top of Python3.5... long story, it happened. I need to use 2.7 for my scripts. I tried creating a sym link and that works, but yum is still not working. Also, if I install anything with pip, it's putting it into /usr/local/lib/python3.5/site-packages. Suggestions how to fix this? I've been googling for hours and I'm pulling my hair out. Thank you in advance.
pip version:
# pip --version
pip 8.0.2 from /usr/local/lib/python3.5/site-packages (python 3.5)
created link to 2.7 version:
# ln -s /usr/local/bin/python2.7 /usr/bin/python
python location:
# which python
/usr/bin/python
check version:
# python
Python 2.7.11 (default, Mar 3 2016, 08:44:22)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>quit()
tried to use yum:
# yum update
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:
No module named yum
Please install a package which provides this module, or
verify that the module is installed correctly.
It's possible that the above module doesn't match the
current version of Python, which is:
2.7.11 (default, Mar 3 2016, 08:44:22)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)]
If you cannot solve this problem yourself, please go to
the yum faq at:
http://yum.baseurl.org/wiki/Faq
pip version has not changed after uninstalling/reinstalling
# pip --version
pip 8.0.2 from /usr/local/lib/python3.5/site-packages (python 3.5)
How can Homebrew be used to install Django? How can Homebrew be used to install tools like setup-tools in python? What all packages can be installed using Homebrew?
Homebrew doesn't package Django. You should install Django using Python's package manager, pip:
$ pip install Django
Using pip to install Django is very convenient and should only take a few seconds using the instructions below. However, be careful you use the correct pip depending on whether installing on an older version of Python (2.7 or lower), or Python 3+. You may have python & python3 installed, and therefore wish to distinguish between pip and pip3.
For instance, locally I have:
$ pip --version
pip 1.2.1 from /Library/Python/2.7/site-packages/pip-1.2.1-py2.7.egg (python 2.7)
$ pip3 --version
pip 1.5.6 from /usr/local/lib/python3.4/site-packages (python 3.4)
Depending on which version you are installing to:
$ pip install Django
or
$ pip3 install Django
To test the install was successful (here I installed with pip3, hence running python3 command):
$ python3
Python 3.4.2 (default, Jan 19 2015, 22:35:23)
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> print(django.get_version())
1.8.6
>>>
That's it!
I would like to learn Django on Windows.I have installed python 2.7.I am unaware of installing Django. I have googled a lot,but didn't understand properly.I referred this question ,But i didn't understood the third point in the accepted answer. I have installed python in c:\.Also django also in c:\.Please help me.I have extracted the django
I always used this link and everything worked like a charm (I didn't install iPython and didn't go through step 3):
http://www.swegler.com/becky/blog/2011/08/27/python-django-mysql-on-windows-7-part-i-getting-started/
I'm going to suggest some extra steps for you that will be invaluable in the long run. First, use virtualenv for your development. This lets you keep several separate Python environments on your machine, each tuned to the projects they're running. Keeping all your projects in a virtualenv also means, if you do something that breaks that environment's Python installation, the rest of your projects are unaffected. I use Linux so I've never installed virtualenv on Windows but this tutorial seems sensible.
Virtualenv has a package called pip installed automatically. Pip is a Python package installer. Using that, getting Django installed and set up is as easy as typing pip install Django at a command prompt. It also has lots of other really useful features for controlling and backing up Python environments that you can find in its documentation.
The 3rd point is where Django gets installed, if you are stuck on that point, you have not installed it yet.
You need to extract django to a folder, cd to that folder and run python setup.py install
The reason that the other answer has C:\download\Django-1.2.5> is that they extracted django to that directory and c:\Python27\python.exe because on windows, you need to reboot in order for path modifications to take effect. So instead, they are accessing the python executable directly with no need to reboot.
To check if you have successfully installed django you can do the following (yes, will work for windows)
(virtualenv)[root#localhost ~]# python
Python 2.7.4 (default, Apr 8 2013, 14:05:01)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> django.get_version()
'1.5.1'
open up cmd, type python (as long as you added it to your path)
then type import django
followed by django.get_version()
If you did it successfully, there will be no import errors and you will see the version of django that is installed.