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!
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 installed eventlet library in python using : pip install eventlet. But when I tried to import eventlet this error occured:
$python
Python 2.7.10 (default, Oct 23 2015, 18:05:06)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import eventlet
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named eventlet
I tried to install it again but I got this :
$pip install eventlet
Requirement already satisfied (use --upgrade to upgrade): eventlet in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/eventlet-0.18.1-py3.5.egg
Requirement already satisfied (use --upgrade to upgrade): greenlet>=0.3 in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/greenlet-0.4.9-py3.5-macosx-10.6-intel.egg (from eventlet)
How to rectify this error?
P.S : I am using Python 2.7
This question is not specific to Eventlet, it's just about managing multiple versions of Python on OSX.
Your pip command installed eventlet into /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5, see version.
It means you actually have two Python versions installed: 2.7 and 3.5 and pip works with 3.5.
Your options:
(recommended) use separate virtualenv [1] for every project, explicitly specify python version when creating virtualenv using virtualenv --python=python2.7 /path/to/new/venv
run python3 and use eventlet in latest Python
run pip2 install eventlet
symlink pip to pip2 ln -snf $(which pip2) $(which pip)
[1] http://docs.python-guide.org/en/latest/dev/virtualenvs/
You may also use
$py -2 -m pip install eventlet
It worked for me in Windows 10.
$pip install eventlet
This worked for me in windows10
I have multiple versions of Python installed(2.5,2.7). I am using Ubuntu. Python2.7 is my default Python interpreter. So all packages like PIL is installed in python2.7. Now i want to install some packages in Python 2.5 version.
I need to install Pip so that i could install the packages. Now i do understand some would give the advice of virtualenv. I tried that too.
But installing Pil through that too doesn't show the packages in the python2.5 version. It installs it in python2.7 version. So i need to do something so that when pip installs the package it installs it in Python2.5 version. Any suggestions?
I also tried this:
python2 -m pip install SomePackage # default Python 2
python2.5 -m pip install SomePackage # specifically Python 2.5
but it says no module named pip
According to this answer: pip: dealing with multiple Python versions?
You have to try like this if pip >= 1.5:
$ pip2.5 install SomePackage
$ pip2.7 install SomePackage
Else:
$ pip-2.5 install SomePackage
$ pip-2.7 install SomePackage
What is the process to upgrade from Django 1.3 to 1.4 (or any other version)?
I thought it may be difficult to upgrade the django from 1.3.1 to 1.4.1 (latest).
It is so simple for this you should have pip to make it easy
Take a backup copy of your resources
If you don't have pip
$ sudo apt-get install python-pip
$ pip install -U django # it will install/upgrade to latest version
or you need to upgrade to particular version
pip install --upgrade django==1.4.1
after the installation just confirm like this
$ python
>>> import django
>>> django.get_version()
'1.4.1'
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.