Django installation on Mac - django

I'm trying to install Django on Mac, Python version 3.7 already installed , here is the comment I have put in terminal-
Django-admin startproject hello
command not found

pip install virtualenv ,
virtualenv some name inside the less than and greater than sign ,
and then cd into the directory and run:
,
source bin/activate,
pip install Django
hope this will help you.. :)

Follow the following steps to install and use django
Install django. $ python -m pip install --upgrade django
Now, check the installation $ python -m pip freeze | grep django
Create django project $ django-admin startproject mysite
What i see wrong in your question ? You are using Django-admin

Related

django-admin startproject command returning bad interpreter: No such file or directory

I can create a project outside of a virtual environment just fine, but when I am using a venv and try to create a django project, I get the following:
/Users/justin/Desktop/Programming/Python/Django
Projects/env/bin/django-admin: "/Users/justin/
Desktop/Programming/Python/Django: bad interpreter: No such
file or directory
I created the venv with python3 -m venv env, I then tried to run pip install django where the above error also appeared, I then learned I should be using python3 -m pip install django (pip3: bad interpreter: No such file or directory) and this successfully installed django, but I still cannot start a project. I've ran pip install django and django-admin startproject from a venv many times without an issue so it seems like I broke something recently. Does anyone know how to fix this/where I can begin looking for the issue? Thanks for any help.
Save a copy of your project in another folder and Try again.
OR
Step First :- RUN - python -m venv env
Step Second :- pip install django
Step Third :- after that install pip
Step Fourth :- ( If your pip version is lower, then it may be issue after
some time and every time it will show the Warning: for upgrading the pip.
So if version is lower then USE ) python -m pip install -U pip

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

Django 2.1.1 Import Errors

i use vscode on windows10. I just created a Django project+app like this:
In the vscode powershell terminal:
python -m venv venv #createing a virtual environment called venv
.\scripts\activate #activate the virtual environment
pip install django==2.1.1 #install the newest version of Django
python -m pip install --upgrade pip #upgrading pip
pip install requests #install requests for api-requests
django-admin startproject api_order . #creates a django project called api_order
python manage.py migrate #create database
python manage.py runserver #starting the server
because of the server running in my powershell terminal i take a second powershell terminal and continue with activating the venv and creating a app.
.\scripts\activate
python manage.py startapp api_order_app #creating a app called api_order_app
When i now open the models.py python is reporting an problem "E0401:Unable to import 'django.db'" Same for all other imports in every other script.
What did go wrong?
I did this twice always the same problem.
This is how it looks like in the IDE
<img src="https://i.stack.imgur.com/JTmvb.jpg">
Thanks in Advance for helping me out.
Ben
I figured it out... I wasnt on the right virtualenvironment. But Django was only installed at the venv.
In Visual Studio Code you can choose the environment u want to use in the bottom left corner.
Now everything works just fine.

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

create virtual environment for Python 3.4-Django 1.7 in Windows with another vers of Python installed

I am new in web programming, so just starting with Python and Django.
I am working on Windows 7 and already have Python 2.7 and Django 1.6.5 for a project I am working on.
For another project I need a virtual environment with Python 3.4 and Django 1.7 so I did:
install Python 3.4 in another folder (c:\python34)
create a folder for my new project (my_proj) and here executed:
> c:\python34\python -m venv py34env
> py34env/bin/activate
> django-admin.py startproject --template='my proj github archive' env my_proj
> cd my_proj
> pip install -r requirements.txt
> cd src
> python manage.py migrate
The file requirements.txt contains among other packages Django 1.7
Now command manage.py migrate gives an error: it seems it doesn't find Django.
If I do django --version I get no result, but if I do pip freeze it shows me Django 1.7.
Any help will be apreciated,
Thanks a lot,
Dani
When working with Python on Windows, I always install virtualenvwrapper-win: https://github.com/davidmarble/virtualenvwrapper-win to get all the same convenience commands that you have on Linux or OS X.
You can create a virutalenv for Python 3.4, or any other Python runtime using the -p option (short for --python) and specifying the path to the Python executable:
mkvirtualenv my_env -p C:\python34\python.exe