ModuleNotFoundError: No module named 'datetime'

2,190 views
Skip to first unread message

bhushan Gupta

unread,
Jan 3, 2020, 12:38:27 PM1/3/20
to Django users
I want to use Django to build a simple portal. I have done the following on Windows 10
installed Python 3.8 and pip
Installed virtualenv 
Created an env 'cargo' 
Installed Djengo 3.0.1
Set the path: 
C:\Program Files (x86)\Python38-32\
C:\Program Files (x86)\Python38-32\Python.exe
C:\Program Files (x86)\Python38-32\Scripts\
C:\Program Files (x86)\Python38-32\Lib\site-packages
C:\Program Files (x86)\Python38-32\Lib\site-packages\django\bin\

I have activated the environment - (cargo) C:\Users\Gupta Consulting\Envs\cargo>
When I start a project using - python django-admin.py startproject cargo  I get the following error:
(cargo) C:\Users\Gupta Consulting\Envs\cargo>django-admin.py startproject myproject
Traceback (most recent call last):
  File "C:\Users\GUPTAC~1\Envs\cargo\Scripts\django-admin.py", line 2, in <module>
    from django.core import management
  File "c:\users\guptac~1\envs\cargo\lib\site-packages\django\__init__.py", line 1, in <module>
    from django.utils.version import get_version
  File "c:\users\guptac~1\envs\cargo\lib\site-packages\django\utils\version.py", line 1, in <module>
    import datetime
ModuleNotFoundError: No module named 'datetime'

I commented out "import datetime" from the vsersion.py file. Then it did not find the next module in in the version.py file.

Looks like there is a setup problem.
Any help will be appreciated
Thanks. 

Daniel Roseman

unread,
Jan 3, 2020, 12:51:16 PM1/3/20
to Django users
Exactly what did you do when you "set the path"? Why did you think you needed to do that manually in the first place? Don't. That is what a virtualenv is for.
-- 
DR.

bhushan Gupta

unread,
Jan 3, 2020, 1:07:38 PM1/3/20
to Django users
I went to windows environment variables and added the last two lines. I was following instructions from: 

C:\Program Files (x86)\Python38-32\Lib\site-packages
C:\Program Files (x86)\Python38-32\Lib\site-packages\django\bin\

sanusi ibrahim adekunle

unread,
Jan 3, 2020, 1:10:27 PM1/3/20
to django...@googlegroups.com
You do not have datetime module installed on your virtual environment. 

To install, type this command: "pip install datetime"

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/17cf2d01-94f8-45e7-a4f6-171e93e32176%40googlegroups.com.

Mohamed A

unread,
Jan 3, 2020, 2:14:02 PM1/3/20
to django...@googlegroups.com
How about deleting your virtualenv and recreating a new one.
It may be located here ::: C:\Users\<user>\.virtualenvs\cargo

When reactivated, could you please provide as with the results of "echo $PATH" from cmdline.


Bhushan Gupta

unread,
Jan 6, 2020, 12:21:26 PM1/6/20
to django...@googlegroups.com

Recreated virtual environment – no change.

 

Here is the PATH:

PATH=C:\Program Files (x86)\Python38-32\;C:\Program Files (x86)\Python38-32\Python.exe;C:\Program Files (x86)\Python38-32\Scripts\;C:\Program Files (x86)\Python38-32\Lib\site-packages;C:\Program Files (x86)\Python38-32\Lib\site-packages\django\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Users\Gupta Consulting\AppData\Local\Microsoft\WindowsApps;

 

Sent from Mail for Windows 10

Kasper Laudrup

unread,
Jan 6, 2020, 1:10:55 PM1/6/20
to django...@googlegroups.com
Hi Bhushan,

On 06/01/2020 18.20, Bhushan Gupta wrote:
> Recreated virtual environment – no change.
>

Inside your virtual environment, what's the output of:

# pip freeze

?

Kind regards,

Kasper Laudrup

Mohamed A

unread,
Jan 6, 2020, 1:29:06 PM1/6/20
to django...@googlegroups.com
Can you please check whether the python interpreter inside the virtual environment is python 2 or python 3 ?
In order to do so, you need to goto to the virtualenv folder, activate cargo env, and then check "python -V"

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

bhushan Gupta

unread,
Jan 9, 2020, 10:55:28 AM1/9/20
to django...@googlegroups.com
Hello Kasper, thanks for following up.

I installed Datetime module using pip. The module is there but still the same error. Looks like a setup error. Here is the pip output:
asgiref==3.2.3
DateTime==4.3
Django==3.0.1
pytz==2019.3
pywin32==227
sqlparse==0.3.0
virtualenv==16.7.8
zope.interface==4.7.1

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages