Python virtualenv no module named django - python

In my ec2 machine i need to run a django project,
I do the below thinks:
Install python 3.4:
sudo yum install python34
ok, now i create a virtual enviroment for python 3:
virtualenv -p python3 .venv3
at this point activate my venv:
source .venv3/bin/activate
all done!
Now i have to install django:
pip install django
the installation was ok but when i try to check my django version:
python -c "import django; print(django.get_version())"
system return the error "No module name django found"
How is possible?
In my machine there is also python 2.7 installed.
I try outside the virtualenv to remove django with:
sudo python -m pip uninstall django
all done, but in my .venv3 enviroment the issue is still present.
How can i fix the problem?
i also tried to reinstall django like this:
pip install --upgrade --force-reinstall django
response:
Collecting django
Using cached https://files.pythonhosted.org/packages/56/0e/afdacb47503b805f3ed213fe732bff05254c8befaa034bbada580be8a0ac/Django-2.0.6-py3-none-any.whl
Collecting pytz (from django)
Using cached https://files.pythonhosted.org/packages/dc/83/15f7833b70d3e067ca91467ca245bae0f6fe56ddc7451aa0dc5606b120f2/pytz-2018.4-py2.py3-none-any.whl
Installing collected packages: pytz, django
Found existing installation: pytz 2018.4
Uninstalling pytz-2018.4:
Successfully uninstalled pytz-2018.4
Successfully installed django-2.0.6 pytz-2018.4
but when i try:
pip freeze
response is:
gunicorn==19.8.1
pytz==2018.4
virtualenv==16.0.0
Why django isn't installed?
thanks in advance

The answer to your question depends on your version of python so you need to install pip3
sudo apt-get install python3-pip
Then, you have to create a virtual environment with venv
pip3 -p python3.6 virtualenv name
After that install Django:
pip3 install Django
As in the recent version, you can use
apt-get install python3-django
Or you can simply do the follwing:
sudo apt-get install python3 virtualenvwrapper
mkvirtualenv <venv> -p python3
workon <venv>
--system-site-packages
pip install Django

Related

"google-oauthlib-tool: command not found" when trying to install google assistant on raspbian

I'm trying to install google assistant on a newly set up pi 3 with Raspbian. I got the message "No module named googlesamples.assistant.auth_helpers" so I followed the instructions given in answer to this question: No module named googlesamples.assistant.auth_helpers
The first 2 commands appear to complete OK, but the third command gives
"google-oauthlib-tool: command not found"
My programming skills are too rusty to work out what's going wrong.
Python 3.5.3; forgotten how to find the version of SDK, but should be the latest one.
Any help greatly appreciated.
Have you followed the instructions to set up a virtual Python environment?
sudo apt-get update
sudo apt-get install python3-dev python3-venv
# Use python3.4-venv if the package cannot be found.
python3 -m venv env
env/bin/python -m pip install --upgrade pip setuptools
source env/bin/activate
Then you should be able to install the oauth tool with pip:
python -m pip install --upgrade google-auth-oauthlib[tool]
You can display all of your installed packages using pip freeze
pip freeze | grep google
Before running python -m pip install --upgrade google-auth-oauthlib[tool] , run
pip install google-auth
And then:
python -m pip install --upgrade google-auth-oauthlib[tool]
google-auth is a dependency of google-auth-oauthlib in Raspbian
You need to locate the tool via locate google-oauthlib-tool
Then, cd into the path and open it there with your arguments

pip install Django on python3.6

If I run pip install Django I get
Requirement already satisfied: Django in
/usr/local/lib/python2.7/dist-packages
I'd like to use python3.6 instead (which is already installed in /usr/bin/python3.6). What's the correct pip syntax to install the last version of Django on python 3.6?
You have to install pip3 :
sudo apt-get install python3-pip
Then, you have to work with venv
pip3 -p python3.6 virtualenv name
And you have to write :
pip3 install Django
#or specific version
pip3 install Django==1.10.5
If you have pip3 then directly use
pip3 install Django
Else try to use virtualenv for your python version as :
pip -p python3.6 virtualenv name
then you can install any version of Django on it.
You can install it globally as others suggested, but the recommended way to install it is to use virtualenv or venv. In case you are using virtualenv (with virtualenvwrapper), just do
mkvirtualenv --python="path to python3 executable" "environment name"
pip install django
Inside virtual environment pip would be pip3 by default and so is python.
As is common with these sort of pip issues, before you install, check where pip is pointing to with pip -V.
If that points to Python 2, you can then try pip3 -V; if that points to an older version of Python 3, go for pip3.6.
As a final approach, you can always go through python itself with python3.6 -m pip install ...
It means you already installed django in python2.7.
You can install django for python3 via:
pip3 install Django
You can also activate virtualenv, and run pip install Django

"sudo pip install Django" => sudo: pip: command not found

This what my terminal is saying when trying to install Django.
MacBook-XXXX:~ Stephane$ sudo pip install Django
sudo: pip: command not found
I have tested in idle shell if pip is installed:
>>> import easy_install
>>> import pip
>>>
What am I doing wrong?
you need to install pip
sudo easy_install pip
pip is a package management system used for installing packages written in python. So first install pip and then Django.
sudo apt-get install python-pip.
And for installing django, follow
django installation steps.

Errors in my Django install

I'm a beginner to Django so please excuse my ignorance here. I am trying to manually install Django so that I can start working with it. I've already installed Python successfully and downloaded Django to my Mac.
When I run the command "sudo python setup.py install" in the Django-1.5.1 directory, I get the following response:
/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: can't open file 'setup.py': [Errno 2] No such file or directory
Can anyone help me understand why this isn't running correctly and what I can do to fix it?
Thanks,
Ryan
As Nathan said pip or easy_install is the best way to install packages. But you need to make sure you have pip installed first:
sudo easy_install pip
sudo pip install django
If you need to specify your version of Django you can do it this way:
sudo pip install django==1.5.1
But normally it's better not to install packages globally (with sudo) and instead it's better to use virtual environments:
sudo easy_install pip
sudo pip install virtualenv
sudo pip install virtualenvwrapper
source /usr/local/bin/virtualenvwrapper.sh
mkdir myproject
cd myproject
mkvirtualenv --no-site-packages myprojectenv
workon myprojectenv
pip install django
I would suggest installing it via pip:
sudo pip install django
or easy_install:
sudo easy_install install django
Both methods will use the Python cheeseshop to install the latest version of django.
Take a look at https://docs.djangoproject.com/en/dev/topics/install/#installing-an-official-release-with-pip for more details.

How can I install a python .egg file

I am trying to install twisted on python 2.6 and it seems that the Zop interface is missing.
Also it seems that it is a .egg file. I downloaded this .egg file, now how can I install it?
Install virtualenv, which includes pip. Then you can simply run:
pip install twisted
pip will handle installing the zope.interface.
Instructions for installing virtualenv and pip on OS X
This is how I installed virtualenv and pip on OS X:
curl -O http://peak.telecommunity.com/dist/ez_setup.py
sudo python ez_setup.py
sudo easy_install pip
sudo pip install virtualenv
I also like to use virtualenvwrapper with virtualenv, so I installed it using:
sudo pip install virtualenvwrapper
Instructions for installing Twisted in a virtualenv
Now to create a new virtual environment and install Twisted, I simply issue:
mkvirtualenv twisted-env
pip install twisted

Categories

Resources