Gizmotronn / python-learning

Learning about python for future projects
https://github.com/acord-robotics/python-learning
4 stars 3 forks source link

Install django (windows) on virtual env #20 #21

Closed Gizmotronn closed 4 years ago

Gizmotronn commented 4 years ago

https://acordrobotics.slack.com/archives/C012SSZ0VKJ/p1587180009000400

Gizmotronn commented 4 years ago

Now I'm doing it on Raspbian on my R.Pi model 4 b:

pi@raspberrypi:~ $ pip3 install virtualenv
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting virtualenv
  Downloading https://files.pythonhosted.org/packages/23/1a/d55f5fb904564365c3d364fd41701a74ad497379f04fd548cccc3f227d98/virtualenv-20.0.18-py2.py3-none-any.whl (4.6MB)
    100% |████████████████████████████████| 4.6MB 98kB/s 
Requirement already satisfied: six<2,>=1.9.0 in /usr/lib/python3/dist-packages (from virtualenv) (1.12.0)
Requirement already satisfied: appdirs<2,>=1.4.3 in /usr/lib/python3/dist-packages (from virtualenv) (1.4.3)
Collecting distlib<1,>=0.3.0 (from virtualenv)
  Downloading https://www.piwheels.org/simple/distlib/distlib-0.3.0-py3-none-any.whl (340kB)
    100% |████████████████████████████████| 348kB 748kB/s 
Collecting filelock<4,>=3.0.0 (from virtualenv)
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))': /simple/filelock/
  Downloading https://files.pythonhosted.org/packages/93/83/71a2ee6158bb9f39a90c0dea1637f81d5eef866e188e1971a1b1ab01a35a/filelock-3.0.12-py3-none-any.whl
Collecting importlib-metadata<2,>=0.12; python_version < "3.8" (from virtualenv)
  Downloading https://files.pythonhosted.org/packages/ad/e4/891bfcaf868ccabc619942f27940c77a8a4b45fd8367098955bb7e152fb1/importlib_metadata-1.6.0-py2.py3-none-any.whl
Collecting zipp>=0.5 (from importlib-metadata<2,>=0.12; python_version < "3.8"->virtualenv)
  Downloading https://files.pythonhosted.org/packages/b2/34/bfcb43cc0ba81f527bc4f40ef41ba2ff4080e047acb0586b56b3d017ace4/zipp-3.1.0-py3-none-any.whl
Installing collected packages: distlib, filelock, zipp, importlib-metadata, virtualenv
Successfully installed distlib-0.3.0 filelock-3.0.12 importlib-metadata-1.6.0 virtualenv-20.0.18 zipp-3.1.0
pi@raspberrypi:~ $ mkdir myproject
pi@raspberrypi:~ $ cd myproject
pi@raspberrypi:~/myproject $ virtualenv venv -p python3
created virtual environment CPython3.7.3.final.0-32 in 775ms
  creator CPython3Posix(dest=/home/pi/myproject/venv, clear=False, global=False)
  seeder FromAppData(download=False, pip=latest, setuptools=latest, wheel=latest, via=copy, app_data_dir=/home/pi/.local/share/virtualenv/seed-app-data/v1.0.1)
  activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator
pi@raspberrypi:~/myproject $ source venv/bin/activate
(venv) pi@raspberrypi:~/myproject $ pip3 install django
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting django
  Using cached Django-3.0.5-py3-none-any.whl (7.5 MB)
Collecting pytz
  Using cached pytz-2019.3-py2.py3-none-any.whl (509 kB)
Collecting sqlparse>=0.2.2
  Using cached sqlparse-0.3.1-py2.py3-none-any.whl (40 kB)
Collecting asgiref~=3.2
  Using cached asgiref-3.2.7-py2.py3-none-any.whl (19 kB)
Installing collected packages: pytz, sqlparse, asgiref, django
Successfully installed asgiref-3.2.7 django-3.0.5 pytz-2019.3 sqlparse-0.3.1
(venv) pi@raspberrypi:~/myproject $ django-admin startproject myproject
(venv) pi@raspberrypi:~/myproject $ python manage.py runserver
python: can't open file 'manage.py': [Errno 2] No such file or directory
(venv) pi@raspberrypi:~/myproject $ cd myproject
(venv) pi@raspberrypi:~/myproject/myproject $ python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).

You have 17 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.

April 21, 2020 - 08:42:52
Django version 3.0.5, using settings 'myproject.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
[21/Apr/2020 08:43:43] "GET / HTTP/1.1" 200 16351
[21/Apr/2020 08:43:43] "GET /static/admin/css/fonts.css HTTP/1.1" 200 423
[21/Apr/2020 08:43:43] "GET /static/admin/fonts/Roboto-Bold-webfont.woff HTTP/1.1" 200 86184
[21/Apr/2020 08:43:43] "GET /static/admin/fonts/Roboto-Light-webfont.woff HTTP/1.1" 200 85692
[21/Apr/2020 08:43:43] "GET /static/admin/fonts/Roboto-Regular-webfont.woff HTTP/1.1" 200 85876
Not Found: /favicon.ico
[21/Apr/2020 08:43:44] "GET /favicon.ico HTTP/1.1" 404 1975
django-admin startup boards

More to come acordrobotics.slack.com #rasp-pi

Gizmotronn commented 4 years ago

django-project-1.zip I have a problem with this that I'd like some help with :)

Following the tutorial from SimpleIsBetterThanComplex, going to ask in the comments/forums for help.

Gizmotronn commented 4 years ago

I've sent in a forum thread: https://community.simpleisbetterthancomplex.com/t/having-trouble-setting-up-django-on-a-raspberry-pi-4-model-b/1067

Gizmotronn commented 4 years ago

20

Gizmotronn commented 4 years ago

On Windows, I got to this step in the SIBTC tutorial:

python manage.py runserver

The reason this didn't work was because I had created a project folder (myproject) inside the dir myproject, but I hadn't "cd'd" to it. Now that I've done that, the ip python manage.py runserver works

Gizmotronn commented 4 years ago

I may have fixed the problem that I sent in the forum!

(c) 2019 Microsoft Corporation. All rights reserved.

C:\Users\droid>cd myproject

C:\Users\droid\myproject>cd myproject

C:\Users\droid\myproject\myproject>venv\Scripts\activate
The system cannot find the path specified.

C:\Users\droid\myproject\myproject>venv\Scripts\activate
The system cannot find the path specified.

C:\Users\droid\myproject\myproject>cd ...

C:\Users\droid\myproject\myproject>cd...

C:\Users\droid\myproject\myproject>cd ..

C:\Users\droid\myproject>venv\Scripts\activate

(venv) C:\Users\droid\myproject>cd myproject

(venv) C:\Users\droid\myproject\myproject>django-admin startapp boards

(venv) C:\Users\droid\myproject\myproject>python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).

You have 17 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.
May 01, 2020 - 12:26:20
Django version 3.0.5, using settings 'myproject.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
[01/May/2020 12:26:21] "GET / HTTP/1.1" 200 13

https://1drv.ms/u/s!Ak1pvbWm73Epjopi4DVwaKDLj9BdRA?e=M4GpPb