New to linux, I have install django in virtualenv, but i am not able to import django. Is there any variable path i need to set ?
(virs) akash@akash-Inspiron-3542:/usr/virs/bin$ django-admin --version
1.11.10
(virs) akash@akash-Inspiron-3542:/usr/virs/bin$ python
Python 3.6.4 (default, Jan 28 2018, 17:52:01)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'django'
You need to use manage.py
if you want to access django library inside python shell. Here's a little bit example.
Try:
django-admin startproject mysite
cd mysite
./manage.py shell
or
python manage.py shell
Here's what it looks like accessing django library inside python shell. In this case, I use IPython. If you don't have IPython installed, manage.py
automatically using python shell.
In [1]: import django
In [2]: django.__version__
Out[2]: '3.0'
In [3]: django.get_version()
Out[3]: '3.0'
Please run this command and write result here.
whereis django-admin
probably! django-admin command run from out of virtualenv
运行命令
pip install django
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.