I'm trying to set up a virtual environment for my Python + Django project, so I ran the following in my terminal:
pip3 install pipenv
Afterward while being in my folder I tried doing this
pipenv install django
but I keep getting this error, and I have no idea how to solve it. Not sure if this makes a difference but i work in VScode
zsh: command not found: pipenv
Any ideas on how to solve this problem?
With venv module
Create a virtual environment with venv
python3 -m venv .venv
Set as active environment:
source .venv/bin/activate
Install django:
pip install django
Try:
python -m pipenv install django
Related
I am a beginner and trying to learn Django, for that I am working in virtual environment. Whenever I try to install Django in my virtual environment it is installed globally, which is I think I should avoid.
Here is the picture of my command prompt.enter image description here
Try calling pip from your env folder in your command prompt and not global pip
pip install django
env\Scripts\pip.exe install django
Try with this ---
First check your virtual environment is activate or not, if not use this command -
[virtual env folder name]/scripts/activate [Enter]
After Activating Virtualenv install Django:
python -m pip install Django
check Django Version:---------
py -m django --version
Hope it will work for you.
I have set up a virtual environment correctly have activated it and when I do "which python" it tells me the correct directory, but when I do pip install in the venv it installs the package in the default directory of the mac and not in my venv. I have tried using pycharm and installing packages with that, but it happens the same thing.
Edit:
Following I will do a walkthru of my steps, first I did python3 -m venv /path/to/new/virtual/environment, then I did source env/bin/activate, then I did which python and I got the intended directory, afterwards I did pip3 install numpy and I saw the installation process, then I did pip list and numpy was not there, I checked the directory manually and it still was not there. I retried all the same thing with pycharm with the same results.
Follow these steps in order -
In your current working directory :
python3 -m venv venv
source venv/bin/activate
(venv) pip3 install library_name
To check if libraries were properly installed or not :
(venv) pip3 freeze
and check if your installed libraries is displayed on the terminal screen or not.
To deactivate the virtual environment :
(venv) deactivate
This is due to permission issues
Run this command to change permission of your virtual environment folder
sudo chmod -R 777 venv
After activating your virtual environment
source venv/bin/activate
Then try to install Django by either Python3 or Python2
pip3 install django or pip install django
Then check the list of installed packages by either Python3 or Python2
pip3 list or pip list
NOTE: If you run sudo pip3 install django or pip install in virtual environment that is not writeable by default it will be installed outside of virtual environment
If you run pip3 install django or pip install in virtual environment that is not writtable by default it will be installed outside of virtual environment you will get OS Persmission Error
I have used pip3 and pip because you can install packages by either Python3 or Python2, thing to remember if you created virtual environment by Python3, use pip3 and if you created by using Python2 use pip.
I have both python 2.7 and 3.8 installed in my computer but whenever I would install virtualenv using pip install virtualenvwrapper-win and then open a new virtualenv using mkvirtualenv test it says Running virtualenv with interpreter /usr/bin/python2. Now I downloaded django in the virtualenv and got the outdated version 1.11. So now I am unable to import path from django.urls among other things.
Is there any way to install vitrualenwrapper with python3 interpreter?
Please help. I am trying to learn django and this is creating a huge hassle.
Virtualenv is already included in standard library of the Python3. You can create a virtual environment using the command below:
python3 -m venv venv
The second venv is the name of your virtualenv, you can name it as you want.
To use an existing virtualenv you should use the command:
path_to_your_venv\Scripts\activate.bat
https://docs.python.org/3/library/venv.html
You can create a virtual environment for any Python version by giving the python interpreter as an argument:
mkvirtualenv -p /path/to/python_binary test
virtualenvwrapper should be installed into the same global site-packages area where virtualenv is installed. You may need administrative privileges to do that. The easiest way to install it is using pip:
pip3 install virtualenvwrapper
or:
sudo pip3 install virtualenvwrapper
I need help in understanding with venv. I have installed venv with virtualenv venv -p python3.6.
I have activated it (venv) and install django
pip django`install django`
And so, when I work with my project should I always activate venv or not? Because I run my manage.py without venv and using python2, but I need python3.
And then I run with active venv with python3 I got mistakes like this:
ModuleNotFoundError: No module named 'forms'
I also use python3.5.2 and I created a virtual environment using the following command
python3 -m venv venv
And activated it using the following command
. venv/bin/activate
I always activate the virtual environment before running the application
You must activate the virtualenv before calling pip install ... (potentially using pip3 with Python 3.x) and also every time you need to work with the virtualenv (e.g. before calling python manage.py ...)
Under C:\Python27\ArcGIS10.2\Scripts I have the following installed:
-easy install
-pip
-virtualenv
However, whenever i go to activate my virtualenv in the following directory C:\Users\username\djangotest i type in the command line the following code: C:\Python27\python -m venv myvenv and i get a not recognized as internal or external command response. I am following the setup steps on http://tutorial.djangogirls.org/en/django_installation/index.html
Am i setting virtual env in the wrong filepath?
Thanks
If my memory serve me right, only python3.3 support -m to create virtualenv. Version prior to that you have to use virtualenv to install virtual enviroment.
pip install virtualenv
virtualenv -p /usr/bin/python2.7 <path/to/new/virtualenv/>
Update:
C:
CD\
virtualenv -p C:\Python27\python.exe MyVirtualEnv
That should create a "MyVirtualEnv" virtualenv folder in your c: drive.