0

I have installed Python3. I created a virtual environment to point to the new version and installed Django which is using python3. But when I am trying to use Django from the virtual environment, I am getting an error message:

ImportError: No module named 'django'

source activate
sudo pip install django
python -c "import django;"

Screen shot

1
  • 1
    Please don't post screenshots of text. It's text; copy and paste it here. Commented May 3, 2015 at 19:10

2 Answers 2

4

Don't use sudo when using virtualenv, just use pip will do the installation.

Because sudo pip install will install into your global python, not the virtualenv.

Sign up to request clarification or add additional context in comments.

6 Comments

That's true, but irrelevant; OP does not seem to have even activated their virtualenv.
perhaps the image is small. anyway, I saw there's a source activate, so I guess he have activated the environment. and also there's a bracket (django) in front of the command marking the environment
Yes, sorry, you're right, I couldn't read that bit. Hence why it's a bad idea to post images.
I tried by only using pip without sudo but throwing a error message: PermissionError: [Errno 13] Permission denied: '/home/joker/django/lib/python3.4/site-packages/django'
@user3287367 the problem is in your virtualenv installation. How did you install your virtualenv? at least my way of installation is by using python3-pip in global environment. so to do this, you just need to type: deactivate; sudo pip install virtualenvwrapper. but since you already installed it using apt-get i believed, you need to remove it first. apt-get remove virtualenvwrapper and clean up those unnecessary leftover.
|
1

You must install Django for your Virtualenv. After use "source activate" you must run "pip install django".

7 Comments

I tried by only using pip without sudo but throwing a error message: PermissionError: [Errno 13] Permission denied: '/home/joker/django/lib/python3.4/site-packages/django'
When you are in a virtualenv always run pip instead of pip3. Virtualenv knows how to use packages from all versions. If still doesn't work, you can delete your virtualenv and try creating it again without sudo. Also try to reinstall Virtualenv, it worked once for me.
Thanks ..... I have created a new virtualenv ......For new one it worked fine .....for first time I have created the environment using: virtualenv -p /usr/bin/python3.4 <path/to/new/virtualenv/> , second time I have used : virtualenv --python=/usr/bin/python3.4 <path/to/new/virtualenv/> , I don't have much idea about virtual environment creation & not sure are they making any real difference or not
The standard way to do it is "virtualenv some_name". You can see information about all parameters using "virtualenv --help" but probably you won't need them.
But I need my virtualenv to point to python3 .......virtualenv some_name.... by default it points to python 2.7
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.