virtual env python 3.5 only finds django python 2.7 - django

I have created python 3.5.2 virtual environment ("python --version" confirms that)
but when i try to install django using "pip install django~=1.10.0" I get this message:
Requirement already satisfied: django~=1.10.0 in /usr/local/lib/python2.7/dist-packages
How can I get django version that agrees with the python version in my venv?

Personally I use conda to manage environments and I'm not really familiar with virtualenv, but a few things to check.
I bet you need to use pip3 not pip (aka pip2) to install django that way it will be installed in your python 3 env.

Probabily you have already installed django outside the venv with python2.
just write see in the pip list if django is installed.
Then uninstall, enter in the venv and reinstall django with python3

Ok - so I figured out what happened. I have installed django using sudo pip install. Even though I was in the venv (created with python3) this has resulted in reference to django outside the venv. Sooo...it was an interesting thing to learn I guess.

Related

I installed Django version over 2.x but the command django-admin startproject(lowercase) make project with 1.x version

python3 -m venv venv
source venv/bin/actvaite # activate virtual env
pip install --upgrade pip
pip3 install Django # Django 2.1.7 installed
django-admin startproject temp # 1.x version
Django-admin startproject temp # 2.x version
django-admin vs Django-admin
django-admin start with lowercase make project 1.x version
Django-admin start with uppercase make project 2.x version
offical docs - start with lowercase
docs
summary
1) whats wrong in my environment?
2) how can i make project with django-admin(lowercase)
It seems like the pip command is pointing to Python 2.x, and pip3 is pointing to Python 3.x. To see if this is this case:
deactivate # in case you're in a virtual environment
pip --verison
pip3 --verison
This will show you which version of Python each one points to. Since Django 2.x is only compatible with Python 3, pip will automatically installed Django 1.11.x if you're installing with pip under Python 2.x.
The best way around this is to ensure you're using a virtual environment. To start a new Django project:
python3 -m venv my_project_venv
. my_project_venv/bin/activate
pip --version # Make sure it is pointing to Python 3
pip install django
django-admin startproject my_project
The next time you come back to work on your project, you can re-activate the virtual environment with everything you've pip installed inside it:
. my_project_venv/bin/activate
Good luck!
Did you install Django in your environment?
pip install Django
A quick workaround is running the following in your environment:
python3 venv/bin/django-admin startproject temp

Can't find any modules in Django project

I've been following a Django tutorial and initially created virtualenv and a requirements file in it. Project was halfway and in working state. Today I activated virtualenv successfully and tried python manage.py runserver to get error
ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?
I realized it's not finding Django and just to be sure checked my requirements.txt file (which confirmed right Django version). Tried to reinstall it from the file using pip3 install -r requirements.txt (tried using just pip too) to get another error --
ModuleNotFoundError: No module named 'pip'
It seems the environment is unable to find any of the modules. I tried to reinstall pip also just to be sure, but then it couldn't find apt-get command.
OS: Mac OSX El Capitan 10.11.6
Python: 3.6.2
Django: 1.10.3 (in requirements file)
Try running python -m ensurepip (or python3 -m ensurepip) to see if pip is already installed:
In most cases, end users of Python shouldn’t need to invoke this module directly (as pip should be bootstrapped by default), but it may be needed if installing pip was skipped when installing Python (or when creating a virtual environment) or after explicitly uninstalling pip.

pip install django-adaptors overwriting 1.5 version of Django

When I install django-adaptors using pip install django-adaptors it also seems to install django 1.4 in the process, which overwrites my django 1.5 installation.
How can I install django-adaptors without it overwriting my version of Django?
Thanks
pip install django-adaptors --no-deps
It's an issue with the packages setup.py. You can see the source here: https://raw.github.com/anthony-tresontani/django-adaptors/master/setup.py
It defines 'Django==1.4' rather than 'Django>=1.4' so it will install Django 1.4 therefore overriding your 1.5 install.
All I can suggest is alter your requirements.txt so django-adaptors is above Django==1.5 so when pip installs 1.5 would be installed after django-adaptors has installed 1.4.
You could simply run pip install django -U after having installed django-adaptors. That will give you django-adaptors, all its dependencies and django 1.5. You could also simply download django-adaptors and change its dependencies file.
The advantage of this approach is that it is easily repeatable when you are moving to a production server (for instance in a fabric script).
One caveat, though: read the django 1.5 release notes to know whether you are likely to encounter any problems.
I just uploaded django-adaptors 0.2.4 which integrate Andrew Ingram fix that that.
You, then, just have to do again:
pip install django-adaptors

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/

Uninstalling old version Django for upgrade to latest version

I want to upgrade Django from 1.2.5 to 1.3. I uninstalled 1.2.5 version, by the Ubuntu Software Center, for future upgrading, but it still in dist-packages and it still imported in python shell. What should I do? Would it be normal if I would brutally deleted the folder and egg from dist-packages?
It runs on Ubuntu 10.04
I recommend using setup-tools. Then run
easy_install --upgrade django
It will remove current django path from PYTHON_PATH and will add it's own path. To get easy_install do:
apt-get install python-setuptools
For both actions sudo is needed.
Go to the /usr/local/lib/python2.6/dist-packages. Find django folder there and delete it. then download django 1.3 and run python setup.py install. This should do the trick.
Remove django version using pip:
pip uninstall django
And install the version you want, for example 1.5:
pip install django==1.5