I have installed virtualenv
pip3 install virtualenv
create a virtualenv
virtualenv djangoenv
access the virtualenv
source ./djangoenv/bin/activate
Then I install
pip3 install django
when import django I get errorno module named django
django-admin.py --version displalys 1.9.4 So it is installed. what am I doing wrong ??
Install virtualenv with pip :
sudo pip install virtualenv
create Virtualenv
virtualenv -p /usr/local/bin/python3 virtualenv_name
activte Virtualenv
source virtualenv_name/bin/activate
finally install django
pip install django
With that you will get django installed using python3
Related
I am having issues with virtualenv installations on a mac.
First change to the directory and activate virtualenv
cd my-project/
virtualenv venv
source venv/bin/activate
Second...my terminal changes to the virtualenv and install Django version 3.1.7
(venv) andrescamino#Robertos-MacBook-Pro WJKTM % pip install Django==3.1.7
To make sure the installation is on the virtualenv i make a pip freeze and these are the results
(venv) andrescamino#Robertos-MacBook-Pro WJKTM % pip freeze
asgiref==3.3.1
Django==3.1.7
pytz==2021.1
sqlparse==0.4.1
Then I start the project
(venv) andrescamino#Robertos-MacBook-Pro WJKTM % django-admin startproject bandsite
However when I go to the editor and check the settings file...it still shows the version installed globally which is the 3.1.2
Generated by 'django-admin startproject' using Django 3.1.2.
Am i missing something?
That's because vscode is using your global python installation. You can see and change which python environement vscode uses from the status bar in the bottom.
I used virtualenvwrapper to create a new env but when I tried to install pip3 to install newer versions of django it was install globally although my environment was activated , which leads to global installation of django ..
How can I use it only inside my virtual env
did you activated virtual env first ? If you see env name in front of name in terminal - it is activated. If it is activated try python3 -m pip install --upgrade pip
then python3 -m pip install django
it is obliged to install last stable version of django (3rd for now) I'm doing this often
Use below commands to install django inside virtual environment.
1) upgrade pip3:
python3 -m pip install --upgrade pip
2) Install virtual env
pip3 install virtualenv
3) You can then create a virtualenv using the full path like this:
virtualenv -p /home/example_username/opt/python-3.6.2/bin/python3 venv
4) Activate virtual env
source venv/bin/activate
5) install Django
pip3 install Django
1.create a virtualenvironment with virtualenv or venv.
2.Activate the virtual environment by entering in the virtual environment folder and type this command if you are on windows cd scripts then type activate.bat or if you are using git bash just do . scripts/activate then you will see ("name of your virtual environment") which proves that your virtual environment is active.
3.Then you can pip install django in your virtual environment
some images below to guide you
enter image description here
enter image description here
you are welcomed!!!
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
So I have done the install for virtualenv but when I try to create my folder this is what I get:
desktop duwaynew$ virtualenv someone -bash: /usr/local/bin/virtualenv: /usr/local/opt/python/bin/python2.7: bad interpreter: No such file or directory
What does this mean?
virtualenv creation in windows:
http://pymote.readthedocs.io/en/latest/install/windows_virtualenv.html
virtualenv creation in ubunutu(Linux platform)
Install pip using sudo apt-install pip and pip install virtualenv
create a env ( example global ) virtualenv global , and activate
source global/bin/activate
I have just installed virtualenvwrapper by it documentation site and from link http://www.openbookproject.net
but on running command-
workon <vir.Env.Name>
i am getting the following error-
workon: command not found The list of commands i used to install are-
sudo aptitude install python-virtualenv
sudo aptitude install python-dev
mkdir mydjangoapp
cd mydjangoapp/
virtualenv --no-site-packages mydjangoappvenv
virtualenv --no-site-packages jango
source jango/bin/activate
pip install virtualenv
pip install virtualenvwrapper
pip install --install-option="--user" virtualenvwrapper
cat >> ~/.bash_profile
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/directory-you-do-development-in
source /usr/local/bin/virtualenvwrapper.sh
I guess my virtualenvwrapper is not installed. Plz anybody can tell whats the problem.Also tell me what is .bash file and where it is found in our file directory.
I think you may have installed virtualenvwrapper inside any virtual enviroment like this-
rahul#rahulpc:~/mydjangoapp$ source jango/bin/activate
(jango)rahul#rahulpc:~/mydjangoapp$ pip install virtualenvwrapper
So before installing virtualenvwrapper you have to deactivate virtual enviroment.
(jango)rahul#rahulpc:~/mydjangoapp$ deactivate
rahul#rahulpc:~/mydjangoapp$ pip install virtualenvwrapper
now follow all further steps.