简体   繁体   中英

How do i specify the version of a module(django) on atom?

I'm trying to run a code I imported from github on my laptop. I think i know where the problem is; as the code is using django v2, and when I do: python -m django --version on my laptop it tells me I'm running on django v1. I installed django v2 but can't "connect it".

I guess my problem is in the path taken, could anyone help?

Just get the src folder and than create a new env and add the src folder in it. There should be a txt file where all the packages are. Run this command inside the env pip install -r nameOfTheTxtFile.txt. This is going to get all the packages that was used to create the project and install it. This way you will not face any problem with the version. The txt file looks like this. 在此处输入图像描述

In first step: you must install pip and virtualenv package:

  • install pip package on windows : python -m pip install -U pip or upgrade with python -m pip install --upgrade pip if not work you must check Windows PATH or Environment variables for add python.
  • install pip package on Linux or mac : pip2 install -U pip or upgrade with python3 -m pip install --upgrade pip Help link

In second step: you must install virtualenv package:

In third step: you must create and activate virtual environment for install project requirements package.

  • Create a virtual environment with: virtualenv env command.

  • Go to "ProjectRoot/env/scripts" direction, and write activate and enter.

  • Then go back to where folder that exists requirements.txt project file, and enter pip install -r requirements.txt for install project requirements. maybe Django version ( django==2.x ) does not exist in requirements.txt so you can add Django version into requirements.txt, and again enter pip install -r requirements.txt for install Django and check Django version with django-admin --version command. Now go to the folder that exists manage.py file and enter below commands:

    python manage.py migrate python manage.py makemigrations

and if you want to login as an admin user for additional content to the database you must create a superuser with python manage.py createsuperuser and enter the name, email, and password. Then enter python manage.py runserver command. Congratulations, Now your project is running on 127.0.0.1:8000.

To solve this issue you can use the following method:

pip install virtualenv
Go to "ProjectRoot/env/scripts" direction, and write activate and enter.
go back and run pip install -r requirements.txt
then run python manage.py makemigrations
and python manage.py migrate
if you want to create a user use:

python manage.py createsuperuser

and finally, run python manage.py runserver now you have your server working at http://127.0.0.1:8000

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM