django-admin pointing outside virtualenv












1















I've initialised a virtual environment using the virtualenvwrapper command mkvirtualenv -a <path to project> django_project.



I then installed django with pip install django. But then if i try to use django-admin i get:



Traceback (most recent call last):
File "/usr/local/bin/django-admin", line 7, in <module>
from django.core.management import execute_from_command_line
ModuleNotFoundError: No module named 'django'


Now pip list gives me



Package    Version
---------- -------
Django 2.1.3
pip 18.1
pytz 2018.7
setuptools 40.6.2
wheel 0.32.3


python -m django --version gives



2.1.3


If I run which python it correctly points to my virtualenv, however which django-admin gives:



/usr/local/bin/django-admin


I'd think that it should point to my venv. Why would it point to a global django admin? How do I fix it so that it'll work for my future virtual environments?



I'm on MacOS using zsh and python 3.7.0.



Thank you!



Edit: Mistake in a command



Edit: I realised I don't have a system-wide installation of Django and so the django-admin and django-admin.py files in my /usr/local/bin must've been leftovers from an earlier installation. Hence I deleted them and that solved the problem. Without any further django-admin inside the venv point to the correct django installation (inside the venv).



However, I would still like to know why the command didn't point to the Django installed in the venv in the first place?










share|improve this question

























  • Jus checked my $PATH inside the venv, and it correctly points to the venv as the first directory. In the env/bin there is a django-admin with the shebang line correctly pointing to the venv...

    – Morten
    Nov 27 '18 at 15:29
















1















I've initialised a virtual environment using the virtualenvwrapper command mkvirtualenv -a <path to project> django_project.



I then installed django with pip install django. But then if i try to use django-admin i get:



Traceback (most recent call last):
File "/usr/local/bin/django-admin", line 7, in <module>
from django.core.management import execute_from_command_line
ModuleNotFoundError: No module named 'django'


Now pip list gives me



Package    Version
---------- -------
Django 2.1.3
pip 18.1
pytz 2018.7
setuptools 40.6.2
wheel 0.32.3


python -m django --version gives



2.1.3


If I run which python it correctly points to my virtualenv, however which django-admin gives:



/usr/local/bin/django-admin


I'd think that it should point to my venv. Why would it point to a global django admin? How do I fix it so that it'll work for my future virtual environments?



I'm on MacOS using zsh and python 3.7.0.



Thank you!



Edit: Mistake in a command



Edit: I realised I don't have a system-wide installation of Django and so the django-admin and django-admin.py files in my /usr/local/bin must've been leftovers from an earlier installation. Hence I deleted them and that solved the problem. Without any further django-admin inside the venv point to the correct django installation (inside the venv).



However, I would still like to know why the command didn't point to the Django installed in the venv in the first place?










share|improve this question

























  • Jus checked my $PATH inside the venv, and it correctly points to the venv as the first directory. In the env/bin there is a django-admin with the shebang line correctly pointing to the venv...

    – Morten
    Nov 27 '18 at 15:29














1












1








1








I've initialised a virtual environment using the virtualenvwrapper command mkvirtualenv -a <path to project> django_project.



I then installed django with pip install django. But then if i try to use django-admin i get:



Traceback (most recent call last):
File "/usr/local/bin/django-admin", line 7, in <module>
from django.core.management import execute_from_command_line
ModuleNotFoundError: No module named 'django'


Now pip list gives me



Package    Version
---------- -------
Django 2.1.3
pip 18.1
pytz 2018.7
setuptools 40.6.2
wheel 0.32.3


python -m django --version gives



2.1.3


If I run which python it correctly points to my virtualenv, however which django-admin gives:



/usr/local/bin/django-admin


I'd think that it should point to my venv. Why would it point to a global django admin? How do I fix it so that it'll work for my future virtual environments?



I'm on MacOS using zsh and python 3.7.0.



Thank you!



Edit: Mistake in a command



Edit: I realised I don't have a system-wide installation of Django and so the django-admin and django-admin.py files in my /usr/local/bin must've been leftovers from an earlier installation. Hence I deleted them and that solved the problem. Without any further django-admin inside the venv point to the correct django installation (inside the venv).



However, I would still like to know why the command didn't point to the Django installed in the venv in the first place?










share|improve this question
















I've initialised a virtual environment using the virtualenvwrapper command mkvirtualenv -a <path to project> django_project.



I then installed django with pip install django. But then if i try to use django-admin i get:



Traceback (most recent call last):
File "/usr/local/bin/django-admin", line 7, in <module>
from django.core.management import execute_from_command_line
ModuleNotFoundError: No module named 'django'


Now pip list gives me



Package    Version
---------- -------
Django 2.1.3
pip 18.1
pytz 2018.7
setuptools 40.6.2
wheel 0.32.3


python -m django --version gives



2.1.3


If I run which python it correctly points to my virtualenv, however which django-admin gives:



/usr/local/bin/django-admin


I'd think that it should point to my venv. Why would it point to a global django admin? How do I fix it so that it'll work for my future virtual environments?



I'm on MacOS using zsh and python 3.7.0.



Thank you!



Edit: Mistake in a command



Edit: I realised I don't have a system-wide installation of Django and so the django-admin and django-admin.py files in my /usr/local/bin must've been leftovers from an earlier installation. Hence I deleted them and that solved the problem. Without any further django-admin inside the venv point to the correct django installation (inside the venv).



However, I would still like to know why the command didn't point to the Django installed in the venv in the first place?







django python-3.x virtualenvwrapper






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 27 '18 at 16:00







Morten

















asked Nov 27 '18 at 15:06









MortenMorten

326




326













  • Jus checked my $PATH inside the venv, and it correctly points to the venv as the first directory. In the env/bin there is a django-admin with the shebang line correctly pointing to the venv...

    – Morten
    Nov 27 '18 at 15:29



















  • Jus checked my $PATH inside the venv, and it correctly points to the venv as the first directory. In the env/bin there is a django-admin with the shebang line correctly pointing to the venv...

    – Morten
    Nov 27 '18 at 15:29

















Jus checked my $PATH inside the venv, and it correctly points to the venv as the first directory. In the env/bin there is a django-admin with the shebang line correctly pointing to the venv...

– Morten
Nov 27 '18 at 15:29





Jus checked my $PATH inside the venv, and it correctly points to the venv as the first directory. In the env/bin there is a django-admin with the shebang line correctly pointing to the venv...

– Morten
Nov 27 '18 at 15:29












1 Answer
1






active

oldest

votes


















0














So Django has been installed at system level, while you verified that python command refer to your virtual environment. I bet this is an issue with pip. You may check that it is under <path to project>/bin and is correctly used when you perform



(django_project) $ pip install django


Try to run



which pip


with your venv enabled and disabled to see what pip is used in each case






share|improve this answer
























  • Thank you Antwane. I don't think django was installed system-wide this time around. which pip correctly points to the venv, while active and to the system while not active. I can also see that django is installed in the venv/bin folder.

    – Morten
    Nov 27 '18 at 15:53











  • In such case, you have to understand why django-admin executable was copied into /usr/local/bin/django-admin. It may have been installed from OS package manager (previous installation ?). Can you try to pip uninstall django and check the list of files about to be deleted to see if this command try to modify something at system level ? Also, which user own /usr/local/bin/django-admin ?

    – Antwane
    Nov 27 '18 at 15:57











  • As I write in my latest edit, I think the django-admin executables in /usr/local/bin/ are leftovers from a previous installation, as you write. I deleted them and it solved the problem for me. I can't see the owner as I have deleted them, but I'm quite sure it would have been me.

    – Morten
    Nov 27 '18 at 16:06











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53502536%2fdjango-admin-pointing-outside-virtualenv%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














So Django has been installed at system level, while you verified that python command refer to your virtual environment. I bet this is an issue with pip. You may check that it is under <path to project>/bin and is correctly used when you perform



(django_project) $ pip install django


Try to run



which pip


with your venv enabled and disabled to see what pip is used in each case






share|improve this answer
























  • Thank you Antwane. I don't think django was installed system-wide this time around. which pip correctly points to the venv, while active and to the system while not active. I can also see that django is installed in the venv/bin folder.

    – Morten
    Nov 27 '18 at 15:53











  • In such case, you have to understand why django-admin executable was copied into /usr/local/bin/django-admin. It may have been installed from OS package manager (previous installation ?). Can you try to pip uninstall django and check the list of files about to be deleted to see if this command try to modify something at system level ? Also, which user own /usr/local/bin/django-admin ?

    – Antwane
    Nov 27 '18 at 15:57











  • As I write in my latest edit, I think the django-admin executables in /usr/local/bin/ are leftovers from a previous installation, as you write. I deleted them and it solved the problem for me. I can't see the owner as I have deleted them, but I'm quite sure it would have been me.

    – Morten
    Nov 27 '18 at 16:06
















0














So Django has been installed at system level, while you verified that python command refer to your virtual environment. I bet this is an issue with pip. You may check that it is under <path to project>/bin and is correctly used when you perform



(django_project) $ pip install django


Try to run



which pip


with your venv enabled and disabled to see what pip is used in each case






share|improve this answer
























  • Thank you Antwane. I don't think django was installed system-wide this time around. which pip correctly points to the venv, while active and to the system while not active. I can also see that django is installed in the venv/bin folder.

    – Morten
    Nov 27 '18 at 15:53











  • In such case, you have to understand why django-admin executable was copied into /usr/local/bin/django-admin. It may have been installed from OS package manager (previous installation ?). Can you try to pip uninstall django and check the list of files about to be deleted to see if this command try to modify something at system level ? Also, which user own /usr/local/bin/django-admin ?

    – Antwane
    Nov 27 '18 at 15:57











  • As I write in my latest edit, I think the django-admin executables in /usr/local/bin/ are leftovers from a previous installation, as you write. I deleted them and it solved the problem for me. I can't see the owner as I have deleted them, but I'm quite sure it would have been me.

    – Morten
    Nov 27 '18 at 16:06














0












0








0







So Django has been installed at system level, while you verified that python command refer to your virtual environment. I bet this is an issue with pip. You may check that it is under <path to project>/bin and is correctly used when you perform



(django_project) $ pip install django


Try to run



which pip


with your venv enabled and disabled to see what pip is used in each case






share|improve this answer













So Django has been installed at system level, while you verified that python command refer to your virtual environment. I bet this is an issue with pip. You may check that it is under <path to project>/bin and is correctly used when you perform



(django_project) $ pip install django


Try to run



which pip


with your venv enabled and disabled to see what pip is used in each case







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 27 '18 at 15:46









AntwaneAntwane

7,93332456




7,93332456













  • Thank you Antwane. I don't think django was installed system-wide this time around. which pip correctly points to the venv, while active and to the system while not active. I can also see that django is installed in the venv/bin folder.

    – Morten
    Nov 27 '18 at 15:53











  • In such case, you have to understand why django-admin executable was copied into /usr/local/bin/django-admin. It may have been installed from OS package manager (previous installation ?). Can you try to pip uninstall django and check the list of files about to be deleted to see if this command try to modify something at system level ? Also, which user own /usr/local/bin/django-admin ?

    – Antwane
    Nov 27 '18 at 15:57











  • As I write in my latest edit, I think the django-admin executables in /usr/local/bin/ are leftovers from a previous installation, as you write. I deleted them and it solved the problem for me. I can't see the owner as I have deleted them, but I'm quite sure it would have been me.

    – Morten
    Nov 27 '18 at 16:06



















  • Thank you Antwane. I don't think django was installed system-wide this time around. which pip correctly points to the venv, while active and to the system while not active. I can also see that django is installed in the venv/bin folder.

    – Morten
    Nov 27 '18 at 15:53











  • In such case, you have to understand why django-admin executable was copied into /usr/local/bin/django-admin. It may have been installed from OS package manager (previous installation ?). Can you try to pip uninstall django and check the list of files about to be deleted to see if this command try to modify something at system level ? Also, which user own /usr/local/bin/django-admin ?

    – Antwane
    Nov 27 '18 at 15:57











  • As I write in my latest edit, I think the django-admin executables in /usr/local/bin/ are leftovers from a previous installation, as you write. I deleted them and it solved the problem for me. I can't see the owner as I have deleted them, but I'm quite sure it would have been me.

    – Morten
    Nov 27 '18 at 16:06

















Thank you Antwane. I don't think django was installed system-wide this time around. which pip correctly points to the venv, while active and to the system while not active. I can also see that django is installed in the venv/bin folder.

– Morten
Nov 27 '18 at 15:53





Thank you Antwane. I don't think django was installed system-wide this time around. which pip correctly points to the venv, while active and to the system while not active. I can also see that django is installed in the venv/bin folder.

– Morten
Nov 27 '18 at 15:53













In such case, you have to understand why django-admin executable was copied into /usr/local/bin/django-admin. It may have been installed from OS package manager (previous installation ?). Can you try to pip uninstall django and check the list of files about to be deleted to see if this command try to modify something at system level ? Also, which user own /usr/local/bin/django-admin ?

– Antwane
Nov 27 '18 at 15:57





In such case, you have to understand why django-admin executable was copied into /usr/local/bin/django-admin. It may have been installed from OS package manager (previous installation ?). Can you try to pip uninstall django and check the list of files about to be deleted to see if this command try to modify something at system level ? Also, which user own /usr/local/bin/django-admin ?

– Antwane
Nov 27 '18 at 15:57













As I write in my latest edit, I think the django-admin executables in /usr/local/bin/ are leftovers from a previous installation, as you write. I deleted them and it solved the problem for me. I can't see the owner as I have deleted them, but I'm quite sure it would have been me.

– Morten
Nov 27 '18 at 16:06





As I write in my latest edit, I think the django-admin executables in /usr/local/bin/ are leftovers from a previous installation, as you write. I deleted them and it solved the problem for me. I can't see the owner as I have deleted them, but I'm quite sure it would have been me.

– Morten
Nov 27 '18 at 16:06




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53502536%2fdjango-admin-pointing-outside-virtualenv%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

Calculate evaluation metrics using cross_val_predict sklearn

Insert data from modal to MySQL (multiple modal on website)