I just installed virtualenv and in it I installed django. However, when I go to the django-admin terminal in the bin file, I wrote
django-admin startproject mysite
I thought that would start a new project but it just returned
Note that only Django core commands are listed as settings are not properly configured (error: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.).
$ django-admin startproject myproject .
A virtual environment is a tool that helps to keep dependencies required by different projects separate by creating isolated python virtual environments for them. This is one of the most important tools that most of the Python developers use.
Here is how to start a new django project in a virtualenv:
1. Create a new virtualenv for your project:
virtualenv py_env --python=python3
--python=python3
is not mandatory. I'd recommend programming in python3.x but this is up to you. If you are unsure about what is the default python that will be used when omitting the --python
option, type python -V
in your terminal.
2. Activate the virtualenv:
source py_env/bin/activate
If you see a (py_env)
at the beginning of the command line, then you know the virtualenv is activated. To deactivate, simply type deactivate
.
3. Install the required packages:
pip install django
While this is not needed, I recommend using ipython, so you might want to run pip install ipython
.
4. Create a new django project:
django-admin startproject mysite
Hope that helped and happy coding!
I think you should first make a virtual environment:
pip3 install --user pipenv
Make a virtual environment:
pipenv --python 3.6
Activate the environment:
pipenv shell
and after this do whatever you want i think it would work better now
Pipenv is best to use because it brings the best Packages of python so that there may not be further bugs while making the virtual environment. And django can be replicated properly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With