Installing django on two existing versions on python - django

I have both python 2.7 and 3.2 installed on my computer and I wanted to install django. And when I did it automatically installed django 1.4 on python 3. Is there a way I can install it on python 2.7?

You can mention explicitly the python version while installing.
First download the source from django website.
Now extract it to any location and open the terminal and go to the location into the folder. There must be a file named setup.py that is the installation file.Now type:
For Python 3.2
python3.2 setup.py install
For Python 2.7
python2.7 setup.py install

The real answer here is that you should be using virtual environments, as they both solve this particular problem, and are the industry standard because they solve many problems.
Simple process:
install python-virtualenv :
$>sudo apt-get install python-virtualenv # on Ubuntu
create a virtual-env against the Python you want, and activate it
$> virtualenv -p /usr/bin/pythonX ve
$> source ve/bin/activate
install django into this virtual-env
$> pip install django
...
PROFIT!

Related

Trying to install Pyramid package with "python setup.py install" gives error searching for a package

I'm working on a Pyramid project that has to be deployed in a Debian 7 server.
The Debian 7 server has the python version 2.7.3 as from the archives repositories.
After creating a virtual environment with virtualenv command the pip version installed in this virtualenv is 1.1.
First thing noted: I can't upgrade pip with pip install --upgrade pip. The version is not updated and remains in 1.1 version.
After installing the OS packages needed to install the project I ran python setup.py install but I get the error:
Searching for zipp==0.5
Reading http://pypi.python.org/simple/zipp/
Couldn't find index page for 'zipp' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading http://pypi.python.org/simple/
No local packages or download links found for zipp==0.5
error: Could not find suitable distribution for Requirement.parse('zipp==0.5')
So, the python setup.py install command could not recognize the zipp package.
I thought that this was related to the older version of pip (1.1). So I could update pip version successfully using the index-url option:
$ pip install --index-url https://pypi.python.org/simple --upgrade pip
That updated pip version from 1.1 to 20.3b1. Then I tried python setup.py install again, but the same error occurred.
What I could see is that, after updating pip version, the zipp==0.5.0 package is installed if I ran pip install zipp==0.5.
I'm new to Pyramid and the package installing using the setup.py module. I'm not understanding why I can install the zipp package with pip and can't with python setup.py install.
I'm not putting the content of setup.py here because I think it's not a problem of the setup.py script. With more recent versions of python and pip in an Ubuntu 18.04 machine the setup.py works like a charm.
Someone could explain how to solve this issue?
When you run python setup.py install directly, you are not using pip, so the version of pip you have installed is irrelevant. This command is antiquated, should not be used, etc, etc. The right answer is to use pip install . as a replacement for python setup.py install and to use pip install -e . as a replacement for python setup.py develop.
With respect to what you're seeing, when you run python setup.py install this using the version of easy_install bundled with setuptools to talk to PyPI and install dependencies. This should be avoided for a lot of reasons but just know that to override urls it uses they go in ~/.pydistutils.cfg and have nothing to do with pip. HTTPS is one problem that you looked at, another is that old versions of Python do not have the right CA trust store, nor support the minimum required TLS 1.2 to handshake with PyPI. So expect lots of problems using old tools - at the very least try to use pip instead of easy_install.

how to install pip remotely using ssh

Hi I hope someone can point me in the right direction.
I am trying to upload a django project which I have developed locally on my machine and now moved the project files to a server and am trying to install django on the server.
I have Python 2.7.5 installed and accessed the server remotely using ssh (putty) I can confirm Python is installed by running the command python --version
I don't have pip installed as when i run the command pip --version
I get following notification
-bash: pip: command not found
I am new to django and python so not sure what I should do to install both django and pip.
p.s In my requirements file and when working locally I have pip and django installed correctly and all working.
Ok, lets say you are already on your remote server. First thing to do is to install pip for your version of python. You can do this via:
sudo apt-get install python-pip
From now you have pip installed. Next thing to do is to install django globally in your system:
pip install django==1.11
Please note that django 1.11 is the last version that supports
python2
Next thing to do is to create django app:
django-admin startproject test_project
And the last thing is to install virtualenv
To install libraries for each of your django projects and keep them
separate
pip install virtualenv
Also note
If you have requirements.txt file with all libs, you can do something like this on your remote server:
pip install -r requirements.txt
That will automatically install all libraries at once
First you should understand which OS you're running:
uname -a
and:
lsb_release -a
When you find the OS version, you can easily follow this guide:
https://packaging.python.org/guides/installing-using-linux-tools/#installing-pip-setuptools-wheel-with-linux-package-managers

Pip installation bug

So I tried to install pip using the get-pip.py file, and when I ran the file, terminal told me I already had pip installed on 2.7. However, when I try to find the version of my pip, terminal tells me pip doesn't exist and points to a version of 3.5 I have installed. Clearly my issue is that I have pip installed on v2.7 but the pip command is linked to v3.5. Any clues on how to fix?
Here's a picture of my terminal output:
To install a package in a particular version of python, use the following commands always:
For python 2.x:
sudo python -m pip install [package]
For python 3.x:
sudo python3 -m pip install [package]
This should resolve the doubt of which python version is the given package getting installed for.
Note: This is assuming you have not created aliases for the python command

Python3 pyserial library

I am working on small python scripts. Basically i am not a python programmer and very new to it. Recently i have been working on IOT protocol MQTT. I have installed a open source MQTT clinet based on python3 in my raspberypi board. And now i am facing a problem. I have python 2.7 and 3.2 installed.
My MQTT client work with Python3.x and i want to use pyserial library also which i am not able to , i am getting a error
Serial module not found
I goggled a bit and end up here.. Now it say that you need to install pip3 in order to install pyserial for python3.x.
I tried to install pip3 using this link , but end up installing pip2 using
pip install -U pip
I feel totally being messed up now. I just want to use pyserial while working with python3.x version.Can any one suggest me how?
Edit 1:
On Linux, Mac OS X and other POSIX systems, use the versioned Python commands in combination with the -m switch to run the appropriate copy of pip:
python2 -m pip install SomePackage # default Python 2
python2.7 -m pip install SomePackage # specifically Python 2.7
python3 -m pip install SomePackage # default Python 3
python3.4 -m pip install SomePackage # specifically Python 3.4
I recently came through this documentation given here . But it even give a error to me /usr/bin/python3 : NO module named pip. main : 'pip' is a package and cannot be installed directly.
Assuming you're using raspbian on your pi, you could install pip3 from the normal repositories:
apt-get install python3-pip
You can get the serial module the same way:
apt-get install python3-serial
I succeeded installing pyserial2.7 on a Mac running Yosemite and Python3.4
I entered the pyserial-x.y directory and run:
python3 setup.py install
I got lot of errors that I corrected one by one by editing the files containing the syntax errors. Only 2 types of errors are encountered:
- print needs ()
- except needs as instead of ,
So by correcting the dozen of errors with some patience, installation finish correctly.
I wonder why a syntactically correct version for Python3 is not ready!

How to install Django on different version of PYTHON?

I have two python versions 2.6 and 3.0. I want to install django1.3 in python3.0's site-package directory and my default python setting is on 2.6. I also added path /usr/local/bin/python3.0 and /usr/local/bin/python3.0 into .bashrc file.
Please help me.
Django is not compatible with Python 3. You must install it in the 2.X branch.
However, what you want to achive will be easier done using virtualenv:
easy_install virtualenv
virtualenv project --python=python2.6
source project/bin/activate
pip install django
Django doesn't yet work with python3.0. So it is better you install it on the python2.6 dist-packages folder.
That said, if you had python2.7 and wanted to install django on python 2.7, while the better approach is to use virtualenv, a simple solution is to:
python2.7 setup.py install
or
easy_install2.7 django
or
/path/to/python2.7/dist-packages/pip/pip install django
easy_install virtualenv
pip install django
Sudo pip install django
Seemed to work for me!
by using pip install django --> it installs the latest version of django.
https://technicalforum.wordpress.com/2016/12/17/introduction-to-django/