Issue: The solution was to uninstall the virtualenv.
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
installation and virtualenv
is installed.
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:The PyCharm terminal is like the default Ubuntu terminal except that it can be used within the PyCharm application. It looks to me like there is a typo in your question and instead of running
virtualenv cmd
which would have worked in the terminal you ranvirtualenv
which wouldn't have worked.You got the following additional error in PyCharm.
That looks like another typo error. The correct command to import Django is
import django
notimport Django
.If
import django
doesn't work either then you need to tell PyCharm to look for Python packages that were installed from the default Ubuntu repositories when you create a new project. If any of the project's Python packages are installed from the default Ubuntu repositories PyCharm will find them automatically if you select the Inherit global-site packages option when you create a new project.Select File -> New Project to create a new project. Click the triangle marked by the mouse cursor in the below screenshot to show the new project's options.
Then check the Inherit global-site packages checkbox and click the Create button in the lower right corner of the Create Project window.
The broken
virtualenv
was causing theimport error
the whole time. The only solution was to uninstall the virtualenv and it's dependencies. Here's all thecmd
I used tried with in order:To ensure all the virtualenv was uninstalled.
The
python3 venv
still remains as it should be.