PTVS icon indicating copy to clipboard operation
PTVS copied to clipboard

ImportError: No module named 'my project name'

Open SnailTowardThesun opened this issue 10 years ago • 4 comments

I tried to create a django project using PTVS .When I tried to do "Django Sync DB",I got a fault saying

Executing manage.py syncdb
Traceback (most recent call last):
  File "E:\GITHUB\django-blog\django-blog\manage.py", line 17, in <module>
    execute_from_command_line(sys.argv)
  File "E:\GITHUB\django-blog\django-blog\env\lib\site-packages\django\core\management\__init__.py", line 353, in execute_from_command_line
    utility.execute()
  File "E:\GITHUB\django-blog\django-blog\env\lib\site-packages\django\core\management\__init__.py", line 302, in execute
    settings.INSTALLED_APPS
  File "E:\GITHUB\django-blog\django-blog\env\lib\site-packages\django\conf\__init__.py", line 55, in __getattr__
    self._setup(name)
  File "E:\GITHUB\django-blog\django-blog\env\lib\site-packages\django\conf\__init__.py", line 43, in _setup
    self._wrapped = Settings(settings_module)
  File "E:\GITHUB\django-blog\django-blog\env\lib\site-packages\django\conf\__init__.py", line 99, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "C:\Users\hanvs\AppData\Local\Programs\Python\Python35-32\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 944, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 956, in _find_and_load_unlocked
ImportError: No module named 'django-blog'
The Python REPL process has exited

But when I executed the command "python manager.py runserver" in cmd.exe,It worked well.

SnailTowardThesun avatar Jan 17 '16 11:01 SnailTowardThesun

Can you attach a list of all the files in E:\GITHUB\django-blog and E:\GITHUB\django-blog\django-blog?

I suspect that when you did runserver you were running from a different directory than where syncdb is being run from. This will change the name of your settings module, probably from django-blog.django-blog to just django-blog (because Python does not need to look into a deeper directory if you're running from there).

Also, just an advance warning that Django projects that are not valid module names (Python modules cannot have - in the name - people generally use _ instead) may cause problems for you later down the line.

zooba avatar Jan 18 '16 17:01 zooba

I try to change "django-blog" into "django_blog" ,and it worked ! Thank you very much

SnailTowardThesun avatar Jan 19 '16 14:01 SnailTowardThesun

I am facing this error problem i have settled everything but when i am compiling the runtests.py it showing me this error i tried my best for solve this but could can anyone help me to found out the problem me how can i fix this error

C:\Users\Dhanesh\Desktop\Check it Please\ChatterBot-master>python runtests.py
Traceback (most recent call last):
  File "runtests.py", line 16, in <module>
    django.setup()
  File "C:\Users\Dhanesh\AppData\Local\Programs\Python\Python35\lib\site-packages\django\__init__.py", line 19, in setup
    configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
  File "C:\Users\Dhanesh\AppData\Local\Programs\Python\Python35\lib\site-packages\django\conf\__init__.py", line 56, in __getattr__
    self._setup(name)
  File "C:\Users\Dhanesh\AppData\Local\Programs\Python\Python35\lib\site-packages\django\conf\__init__.py", line 43, in _setup
    self._wrapped = Settings(settings_module)
  File "C:\Users\Dhanesh\AppData\Local\Programs\Python\Python35\lib\site-packages\django\conf\__init__.py", line 106, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "C:\Users\Dhanesh\AppData\Local\Programs\Python\Python35\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 944, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 662, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "C:\Users\Dhanesh\Desktop\Check it Please\ChatterBot-master\tests_django\__init__.py", line 1, in <module>
    from .statement import Statement
ImportError: No module named 'tests_django.statement'

DhaneshKumarHeerani avatar Dec 14 '17 11:12 DhaneshKumarHeerani

@DhaneshKumarHeerani Please create a new issue with your problem, and also include a list of all the files in your project so we can see which ones are not being found.

zooba avatar Dec 14 '17 16:12 zooba