PyCharm Pro ImportError (Disco Dingo) Django 2.0Pycharm Pro and UbuntuDo I need Django-2.0.checksum.txt to check if the downloaded tar.gz is not malware ?while creating module getting errorDisco Dingo PyCharm 'Running virtualenv with interpreter /usr/bin/python2' while everything else runs Python 3File ignored PyCharm Pro IDE and this the correct sys.path for PYTHONPATH?

What color is a wolf's coat?

What makes an airport "international"?

Why do airline tickets have titles in addition to names?

What would cause vast differences in lifespans between the sexes?

Heavy condensation inside car during winter. Tried multiple things, but no results!

How to test oom-killer from command line

Why does the media continue to hide the identity of the Trump-Ukraine whistle blower when they have already been outed?

Does a small cup of coffee result in a 45% reduced blood flow to the brain?

Undefined control sequence when using edef with foreach

Now I realize I used too many GFCI outlets. How can I reclaim them?

copying files with a string in their name from one folder to another

Average Two Letters

I'm from Mumbai, India. I want to travel to Europe as a tourist but my salary is low ( €190/month)

Opening Moves: Pawn Chains and Countering Attacks

Receive a list of names and return a list of users - HackerRank test

Why do some applications have files with no extension?

Why don't all humans have absolute pitch?

White marks on garage ceiling

Plot the Pascalian triangle

How do I experimentally measure the surface area of a rock?

How does Facebook track your browsing without third party cookies?

Why use Fourier series instead of Taylor?

How to get best taste out of tomatoes?

Why does this relative clause not end with the verb?



PyCharm Pro ImportError (Disco Dingo) Django 2.0


Pycharm Pro and UbuntuDo I need Django-2.0.checksum.txt to check if the downloaded tar.gz is not malware ?while creating module getting errorDisco Dingo PyCharm 'Running virtualenv with interpreter /usr/bin/python2' while everything else runs Python 3File ignored PyCharm Pro IDE and this the correct sys.path for PYTHONPATH?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;









0

















Issue was found in chat, I am using the wrong version of virtualenv which requires uninstallation.



While I was trying to set-up a Django Project. On the manage.py:



ImportError("Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? `Did you "`
"forget to activate a virtual environment?"

) from exc


Update: I ran virtualenv cmd in Pycharm Pro terminal
This came up:



You must provide a DEST_DIR
Usage: virtualenv [OPTIONS] DEST_DIR


Any solution?

Additional information:
Pip3was used in installation and virtualenv is installed.



Django MCVE:



def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Example.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Example.settings')
application = get_wsgi_application()
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',


]



ROOT_URLCONF = 'Example.urls'

TEMPLATES = [

'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')]
,
'APP_DIRS': True,
'OPTIONS':
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
,
,


]



WSGI_APPLICATION = 'Example.wsgi.application'









share|improve this question























  • 1





    Is your PyCharm configured to use a virtualenv inside your project directory, or is it using the 'system' libraries? If system libraries, have you installed Django requisites from PyPI into your environment with sudo pip3 install and such?

    – Thomas Ward
    Aug 8 at 15:37






  • 1





    Checking the project the new environment using virtualnev is ticked for python and Django both inside the project directory.

    – SeemsToBeStuck
    Aug 8 at 15:52











  • Going onto Pycharm Pro Project Interrupter. I had only had the two installed packages (not Django or virtualnev). I need to install some more packages.

    – SeemsToBeStuck
    Aug 8 at 22:11











  • Yes. You will need to drop into the PyCharm Pro 'Terminal' which will drop you into your venv. Then install Django and its requisites.

    – Thomas Ward
    Aug 9 at 0:00











  • I was following the instructions and installed them from project interperter.

    – SeemsToBeStuck
    Aug 9 at 0:32

















0

















Issue was found in chat, I am using the wrong version of virtualenv which requires uninstallation.



While I was trying to set-up a Django Project. On the manage.py:



ImportError("Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? `Did you "`
"forget to activate a virtual environment?"

) from exc


Update: I ran virtualenv cmd in Pycharm Pro terminal
This came up:



You must provide a DEST_DIR
Usage: virtualenv [OPTIONS] DEST_DIR


Any solution?

Additional information:
Pip3was used in installation and virtualenv is installed.



Django MCVE:



def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Example.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Example.settings')
application = get_wsgi_application()
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',


]



ROOT_URLCONF = 'Example.urls'

TEMPLATES = [

'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')]
,
'APP_DIRS': True,
'OPTIONS':
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
,
,


]



WSGI_APPLICATION = 'Example.wsgi.application'









share|improve this question























  • 1





    Is your PyCharm configured to use a virtualenv inside your project directory, or is it using the 'system' libraries? If system libraries, have you installed Django requisites from PyPI into your environment with sudo pip3 install and such?

    – Thomas Ward
    Aug 8 at 15:37






  • 1





    Checking the project the new environment using virtualnev is ticked for python and Django both inside the project directory.

    – SeemsToBeStuck
    Aug 8 at 15:52











  • Going onto Pycharm Pro Project Interrupter. I had only had the two installed packages (not Django or virtualnev). I need to install some more packages.

    – SeemsToBeStuck
    Aug 8 at 22:11











  • Yes. You will need to drop into the PyCharm Pro 'Terminal' which will drop you into your venv. Then install Django and its requisites.

    – Thomas Ward
    Aug 9 at 0:00











  • I was following the instructions and installed them from project interperter.

    – SeemsToBeStuck
    Aug 9 at 0:32













0












0








0








Issue was found in chat, I am using the wrong version of virtualenv which requires uninstallation.



While I was trying to set-up a Django Project. On the manage.py:



ImportError("Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? `Did you "`
"forget to activate a virtual environment?"

) from exc


Update: I ran virtualenv cmd in Pycharm Pro terminal
This came up:



You must provide a DEST_DIR
Usage: virtualenv [OPTIONS] DEST_DIR


Any solution?

Additional information:
Pip3was used in installation and virtualenv is installed.



Django MCVE:



def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Example.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Example.settings')
application = get_wsgi_application()
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',


]



ROOT_URLCONF = 'Example.urls'

TEMPLATES = [

'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')]
,
'APP_DIRS': True,
'OPTIONS':
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
,
,


]



WSGI_APPLICATION = 'Example.wsgi.application'









share|improve this question

















Issue was found in chat, I am using the wrong version of virtualenv which requires uninstallation.



While I was trying to set-up a Django Project. On the manage.py:



ImportError("Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? `Did you "`
"forget to activate a virtual environment?"

) from exc


Update: I ran virtualenv cmd in Pycharm Pro terminal
This came up:



You must provide a DEST_DIR
Usage: virtualenv [OPTIONS] DEST_DIR


Any solution?

Additional information:
Pip3was used in installation and virtualenv is installed.



Django MCVE:



def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Example.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Example.settings')
application = get_wsgi_application()
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',


]



ROOT_URLCONF = 'Example.urls'

TEMPLATES = [

'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')]
,
'APP_DIRS': True,
'OPTIONS':
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
,
,


]



WSGI_APPLICATION = 'Example.wsgi.application'






python django pycharm






share|improve this question
















share|improve this question













share|improve this question




share|improve this question








edited Aug 19 at 15:46







SeemsToBeStuck

















asked Aug 7 at 22:50









SeemsToBeStuckSeemsToBeStuck

357 bronze badges




357 bronze badges










  • 1





    Is your PyCharm configured to use a virtualenv inside your project directory, or is it using the 'system' libraries? If system libraries, have you installed Django requisites from PyPI into your environment with sudo pip3 install and such?

    – Thomas Ward
    Aug 8 at 15:37






  • 1





    Checking the project the new environment using virtualnev is ticked for python and Django both inside the project directory.

    – SeemsToBeStuck
    Aug 8 at 15:52











  • Going onto Pycharm Pro Project Interrupter. I had only had the two installed packages (not Django or virtualnev). I need to install some more packages.

    – SeemsToBeStuck
    Aug 8 at 22:11











  • Yes. You will need to drop into the PyCharm Pro 'Terminal' which will drop you into your venv. Then install Django and its requisites.

    – Thomas Ward
    Aug 9 at 0:00











  • I was following the instructions and installed them from project interperter.

    – SeemsToBeStuck
    Aug 9 at 0:32












  • 1





    Is your PyCharm configured to use a virtualenv inside your project directory, or is it using the 'system' libraries? If system libraries, have you installed Django requisites from PyPI into your environment with sudo pip3 install and such?

    – Thomas Ward
    Aug 8 at 15:37






  • 1





    Checking the project the new environment using virtualnev is ticked for python and Django both inside the project directory.

    – SeemsToBeStuck
    Aug 8 at 15:52











  • Going onto Pycharm Pro Project Interrupter. I had only had the two installed packages (not Django or virtualnev). I need to install some more packages.

    – SeemsToBeStuck
    Aug 8 at 22:11











  • Yes. You will need to drop into the PyCharm Pro 'Terminal' which will drop you into your venv. Then install Django and its requisites.

    – Thomas Ward
    Aug 9 at 0:00











  • I was following the instructions and installed them from project interperter.

    – SeemsToBeStuck
    Aug 9 at 0:32







1




1





Is your PyCharm configured to use a virtualenv inside your project directory, or is it using the 'system' libraries? If system libraries, have you installed Django requisites from PyPI into your environment with sudo pip3 install and such?

– Thomas Ward
Aug 8 at 15:37





Is your PyCharm configured to use a virtualenv inside your project directory, or is it using the 'system' libraries? If system libraries, have you installed Django requisites from PyPI into your environment with sudo pip3 install and such?

– Thomas Ward
Aug 8 at 15:37




1




1





Checking the project the new environment using virtualnev is ticked for python and Django both inside the project directory.

– SeemsToBeStuck
Aug 8 at 15:52





Checking the project the new environment using virtualnev is ticked for python and Django both inside the project directory.

– SeemsToBeStuck
Aug 8 at 15:52













Going onto Pycharm Pro Project Interrupter. I had only had the two installed packages (not Django or virtualnev). I need to install some more packages.

– SeemsToBeStuck
Aug 8 at 22:11





Going onto Pycharm Pro Project Interrupter. I had only had the two installed packages (not Django or virtualnev). I need to install some more packages.

– SeemsToBeStuck
Aug 8 at 22:11













Yes. You will need to drop into the PyCharm Pro 'Terminal' which will drop you into your venv. Then install Django and its requisites.

– Thomas Ward
Aug 9 at 0:00





Yes. You will need to drop into the PyCharm Pro 'Terminal' which will drop you into your venv. Then install Django and its requisites.

– Thomas Ward
Aug 9 at 0:00













I was following the instructions and installed them from project interperter.

– SeemsToBeStuck
Aug 9 at 0:32





I was following the instructions and installed them from project interperter.

– SeemsToBeStuck
Aug 9 at 0:32










1 Answer
1






active

oldest

votes


















1


















from django.core.management import execute_from_command_line works perfectly plus you are getting the following error when using python3.7 interpreter in Ubuntu 19.04:



You must provide a DEST_DIR
Usage: virtualenv [OPTIONS] DEST_DIR


I recommend testing a simple "hello world" Python program in the virtualenv, because it looks like the problem is with the virtualenv, not with the Python code. This could be for two reasons:



  1. The virtualenv is messed up and must be re-created from scratch.

  2. If you created the same two virtualenvs, one in PyCharm and the other one in your home directory and a "hello world" program only works in the virtualenv that was not created in PyCharm, it is possible that the virtualenv is OK, but it's not configured correctly in PyCharm.

The following screenshot shows my project structure of a simple "hello world" project in PyCharm which is named hello-world-1. My source file is named hello-world-1.py. I ran this code by clicking the green run triangle ▶ marked by the mouse cursor in the below screenshot.



hello-world-1 project



All of the files that you see in the hello-world-1 directory tree were created automatically by PyCharm when I created the project except for the hello-world-1.py file which I created afterwards in PyCharm. I didn't configure the virtualenv when I created the project. I accepted all the defaults and clicked OK.



pip3 was automatically created by PyCharm in the bin directory in case I want to install any Python packages for my python3 program with pip3 install <package name>.



The next thing I did was to edit my "hello world" code so that it looks like this:



print("Hello world!")
from django.core.management import execute_from_command_line


This code also ran without errors showing that it imported Django, which is globally installed by sudo apt install python3-django, into the virtualenv without any additional configuration required.



The purpose of the venv directory is to provide a landing directory for the virtualenv. venv is just a name that PyCharm uses to identify this directory, but venv can be changed by the user to any other name. The purpose of the virtualenv is to provide a secure sandboxed environment where the user can safely install whatever packages are required by an individual project. Of course, if the same packages are also provided by the default Ubuntu repositories there's no point in messing around with pip because Ubuntu repository packages have already been checked by the Ubuntu developers.



$ apt policy python3-django
python3-django:
Installed: 1:1.11.11-1ubuntu1.5
$ python3
>>> import django
>>> from django.core.management import execute_from_command_line # no error message
>>> exit()





share|improve this answer




























  • Comments are not for extended discussion; this conversation has been moved to chat.

    – Thomas Ward
    Aug 12 at 13:55












Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "89"
;
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/4.0/"u003ecc by-sa 4.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%2faskubuntu.com%2fquestions%2f1164178%2fpycharm-pro-importerror-disco-dingo-django-2-0%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









1


















from django.core.management import execute_from_command_line works perfectly plus you are getting the following error when using python3.7 interpreter in Ubuntu 19.04:



You must provide a DEST_DIR
Usage: virtualenv [OPTIONS] DEST_DIR


I recommend testing a simple "hello world" Python program in the virtualenv, because it looks like the problem is with the virtualenv, not with the Python code. This could be for two reasons:



  1. The virtualenv is messed up and must be re-created from scratch.

  2. If you created the same two virtualenvs, one in PyCharm and the other one in your home directory and a "hello world" program only works in the virtualenv that was not created in PyCharm, it is possible that the virtualenv is OK, but it's not configured correctly in PyCharm.

The following screenshot shows my project structure of a simple "hello world" project in PyCharm which is named hello-world-1. My source file is named hello-world-1.py. I ran this code by clicking the green run triangle ▶ marked by the mouse cursor in the below screenshot.



hello-world-1 project



All of the files that you see in the hello-world-1 directory tree were created automatically by PyCharm when I created the project except for the hello-world-1.py file which I created afterwards in PyCharm. I didn't configure the virtualenv when I created the project. I accepted all the defaults and clicked OK.



pip3 was automatically created by PyCharm in the bin directory in case I want to install any Python packages for my python3 program with pip3 install <package name>.



The next thing I did was to edit my "hello world" code so that it looks like this:



print("Hello world!")
from django.core.management import execute_from_command_line


This code also ran without errors showing that it imported Django, which is globally installed by sudo apt install python3-django, into the virtualenv without any additional configuration required.



The purpose of the venv directory is to provide a landing directory for the virtualenv. venv is just a name that PyCharm uses to identify this directory, but venv can be changed by the user to any other name. The purpose of the virtualenv is to provide a secure sandboxed environment where the user can safely install whatever packages are required by an individual project. Of course, if the same packages are also provided by the default Ubuntu repositories there's no point in messing around with pip because Ubuntu repository packages have already been checked by the Ubuntu developers.



$ apt policy python3-django
python3-django:
Installed: 1:1.11.11-1ubuntu1.5
$ python3
>>> import django
>>> from django.core.management import execute_from_command_line # no error message
>>> exit()





share|improve this answer




























  • Comments are not for extended discussion; this conversation has been moved to chat.

    – Thomas Ward
    Aug 12 at 13:55















1


















from django.core.management import execute_from_command_line works perfectly plus you are getting the following error when using python3.7 interpreter in Ubuntu 19.04:



You must provide a DEST_DIR
Usage: virtualenv [OPTIONS] DEST_DIR


I recommend testing a simple "hello world" Python program in the virtualenv, because it looks like the problem is with the virtualenv, not with the Python code. This could be for two reasons:



  1. The virtualenv is messed up and must be re-created from scratch.

  2. If you created the same two virtualenvs, one in PyCharm and the other one in your home directory and a "hello world" program only works in the virtualenv that was not created in PyCharm, it is possible that the virtualenv is OK, but it's not configured correctly in PyCharm.

The following screenshot shows my project structure of a simple "hello world" project in PyCharm which is named hello-world-1. My source file is named hello-world-1.py. I ran this code by clicking the green run triangle ▶ marked by the mouse cursor in the below screenshot.



hello-world-1 project



All of the files that you see in the hello-world-1 directory tree were created automatically by PyCharm when I created the project except for the hello-world-1.py file which I created afterwards in PyCharm. I didn't configure the virtualenv when I created the project. I accepted all the defaults and clicked OK.



pip3 was automatically created by PyCharm in the bin directory in case I want to install any Python packages for my python3 program with pip3 install <package name>.



The next thing I did was to edit my "hello world" code so that it looks like this:



print("Hello world!")
from django.core.management import execute_from_command_line


This code also ran without errors showing that it imported Django, which is globally installed by sudo apt install python3-django, into the virtualenv without any additional configuration required.



The purpose of the venv directory is to provide a landing directory for the virtualenv. venv is just a name that PyCharm uses to identify this directory, but venv can be changed by the user to any other name. The purpose of the virtualenv is to provide a secure sandboxed environment where the user can safely install whatever packages are required by an individual project. Of course, if the same packages are also provided by the default Ubuntu repositories there's no point in messing around with pip because Ubuntu repository packages have already been checked by the Ubuntu developers.



$ apt policy python3-django
python3-django:
Installed: 1:1.11.11-1ubuntu1.5
$ python3
>>> import django
>>> from django.core.management import execute_from_command_line # no error message
>>> exit()





share|improve this answer




























  • Comments are not for extended discussion; this conversation has been moved to chat.

    – Thomas Ward
    Aug 12 at 13:55













1














1










1









from django.core.management import execute_from_command_line works perfectly plus you are getting the following error when using python3.7 interpreter in Ubuntu 19.04:



You must provide a DEST_DIR
Usage: virtualenv [OPTIONS] DEST_DIR


I recommend testing a simple "hello world" Python program in the virtualenv, because it looks like the problem is with the virtualenv, not with the Python code. This could be for two reasons:



  1. The virtualenv is messed up and must be re-created from scratch.

  2. If you created the same two virtualenvs, one in PyCharm and the other one in your home directory and a "hello world" program only works in the virtualenv that was not created in PyCharm, it is possible that the virtualenv is OK, but it's not configured correctly in PyCharm.

The following screenshot shows my project structure of a simple "hello world" project in PyCharm which is named hello-world-1. My source file is named hello-world-1.py. I ran this code by clicking the green run triangle ▶ marked by the mouse cursor in the below screenshot.



hello-world-1 project



All of the files that you see in the hello-world-1 directory tree were created automatically by PyCharm when I created the project except for the hello-world-1.py file which I created afterwards in PyCharm. I didn't configure the virtualenv when I created the project. I accepted all the defaults and clicked OK.



pip3 was automatically created by PyCharm in the bin directory in case I want to install any Python packages for my python3 program with pip3 install <package name>.



The next thing I did was to edit my "hello world" code so that it looks like this:



print("Hello world!")
from django.core.management import execute_from_command_line


This code also ran without errors showing that it imported Django, which is globally installed by sudo apt install python3-django, into the virtualenv without any additional configuration required.



The purpose of the venv directory is to provide a landing directory for the virtualenv. venv is just a name that PyCharm uses to identify this directory, but venv can be changed by the user to any other name. The purpose of the virtualenv is to provide a secure sandboxed environment where the user can safely install whatever packages are required by an individual project. Of course, if the same packages are also provided by the default Ubuntu repositories there's no point in messing around with pip because Ubuntu repository packages have already been checked by the Ubuntu developers.



$ apt policy python3-django
python3-django:
Installed: 1:1.11.11-1ubuntu1.5
$ python3
>>> import django
>>> from django.core.management import execute_from_command_line # no error message
>>> exit()





share|improve this answer
















from django.core.management import execute_from_command_line works perfectly plus you are getting the following error when using python3.7 interpreter in Ubuntu 19.04:



You must provide a DEST_DIR
Usage: virtualenv [OPTIONS] DEST_DIR


I recommend testing a simple "hello world" Python program in the virtualenv, because it looks like the problem is with the virtualenv, not with the Python code. This could be for two reasons:



  1. The virtualenv is messed up and must be re-created from scratch.

  2. If you created the same two virtualenvs, one in PyCharm and the other one in your home directory and a "hello world" program only works in the virtualenv that was not created in PyCharm, it is possible that the virtualenv is OK, but it's not configured correctly in PyCharm.

The following screenshot shows my project structure of a simple "hello world" project in PyCharm which is named hello-world-1. My source file is named hello-world-1.py. I ran this code by clicking the green run triangle ▶ marked by the mouse cursor in the below screenshot.



hello-world-1 project



All of the files that you see in the hello-world-1 directory tree were created automatically by PyCharm when I created the project except for the hello-world-1.py file which I created afterwards in PyCharm. I didn't configure the virtualenv when I created the project. I accepted all the defaults and clicked OK.



pip3 was automatically created by PyCharm in the bin directory in case I want to install any Python packages for my python3 program with pip3 install <package name>.



The next thing I did was to edit my "hello world" code so that it looks like this:



print("Hello world!")
from django.core.management import execute_from_command_line


This code also ran without errors showing that it imported Django, which is globally installed by sudo apt install python3-django, into the virtualenv without any additional configuration required.



The purpose of the venv directory is to provide a landing directory for the virtualenv. venv is just a name that PyCharm uses to identify this directory, but venv can be changed by the user to any other name. The purpose of the virtualenv is to provide a secure sandboxed environment where the user can safely install whatever packages are required by an individual project. Of course, if the same packages are also provided by the default Ubuntu repositories there's no point in messing around with pip because Ubuntu repository packages have already been checked by the Ubuntu developers.



$ apt policy python3-django
python3-django:
Installed: 1:1.11.11-1ubuntu1.5
$ python3
>>> import django
>>> from django.core.management import execute_from_command_line # no error message
>>> exit()






share|improve this answer















share|improve this answer




share|improve this answer








edited Aug 24 at 6:57

























answered Aug 7 at 23:05









karelkarel

70.2k15 gold badges158 silver badges184 bronze badges




70.2k15 gold badges158 silver badges184 bronze badges















  • Comments are not for extended discussion; this conversation has been moved to chat.

    – Thomas Ward
    Aug 12 at 13:55

















  • Comments are not for extended discussion; this conversation has been moved to chat.

    – Thomas Ward
    Aug 12 at 13:55
















Comments are not for extended discussion; this conversation has been moved to chat.

– Thomas Ward
Aug 12 at 13:55





Comments are not for extended discussion; this conversation has been moved to chat.

– Thomas Ward
Aug 12 at 13:55


















draft saved

draft discarded















































Thanks for contributing an answer to Ask Ubuntu!


  • 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%2faskubuntu.com%2fquestions%2f1164178%2fpycharm-pro-importerror-disco-dingo-django-2-0%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

Tamil (spriik) Luke uk diar | Nawigatjuun

Align equal signs while including text over equalitiesAMS align: left aligned text/math plus multicolumn alignmentMultiple alignmentsAligning equations in multiple placesNumbering and aligning an equation with multiple columnsHow to align one equation with another multline equationUsing \ in environments inside the begintabularxNumber equations and preserving alignment of equal signsHow can I align equations to the left and to the right?Double equation alignment problem within align enviromentAligned within align: Why are they right-aligned?

Training a classifier when some of the features are unknownWhy does Gradient Boosting regression predict negative values when there are no negative y-values in my training set?How to improve an existing (trained) classifier?What is effect when I set up some self defined predisctor variables?Why Matlab neural network classification returns decimal values on prediction dataset?Fitting and transforming text data in training, testing, and validation setsHow to quantify the performance of the classifier (multi-class SVM) using the test data?How do I control for some patients providing multiple samples in my training data?Training and Test setTraining a convolutional neural network for image denoising in MatlabShouldn't an autoencoder with #(neurons in hidden layer) = #(neurons in input layer) be “perfect”?