Crysistec Crysistec - 1 year ago 159
Python Question

the 'package' argument is required to perform a relative import for

I'm not sure what is causing this error I'm looking to try and runsever on django from windows PowerShell but im am getting that error and this wall of issues.

Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x03D366A8>
Traceback (most recent call last):
File "D:\Python\lib\site-packages\django\utils\", line 226, in wrapper
fn(*args, **kwargs)
File "D:\Python\lib\site-packages\django\core\management\commands\", line 121, in inner_run
File "D:\Python\lib\site-packages\django\core\management\", line 374, in check
File "D:\Python\lib\site-packages\django\core\management\", line 361, in _run_checks
return checks.run_checks(**kwargs)
File "D:\Python\lib\site-packages\django\core\checks\", line 81, in run_checks
new_errors = check(app_configs=app_configs)
File "D:\Python\lib\site-packages\django\core\checks\", line 14, in check_url_config
return check_resolver(resolver)
File "D:\Python\lib\site-packages\django\core\checks\", line 24, in check_resolver
for pattern in resolver.url_patterns:
File "D:\Python\lib\site-packages\django\utils\", line 35, in __get__
res = instance.__dict__[] = self.func(instance)
File "D:\Python\lib\site-packages\django\urls\", line 313, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "D:\Python\lib\site-packages\django\utils\", line 35, in __get__
res = instance.__dict__[] = self.func(instance)
File "D:\Python\lib\site-packages\django\urls\", line 306, in urlconf_module
return import_module(self.urlconf_name)
File "D:\Python\lib\importlib\", 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 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 665, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "D:\Python\courseworkupload\courseworkupload\", line 26, in <module>
url(r'^upload/', include('.upload.urls')),
File "D:\Python\lib\site-packages\django\conf\urls\", line 50, in include
urlconf_module = import_module(urlconf_module)
File "D:\Python\lib\importlib\", line 121, in import_module
raise TypeError(msg.format(name))
TypeError: the 'package' argument is required to perform a relative import for '.upload.urls'

This was done after i ran python runserver

Any help on the issue would be great

Edit: Adding tree below

│ db.sqlite3

│ courseworkupload.iml
│ misc.xml
│ modules.xml
│ workspace.xml

│ │
│ │
│ │
│ │
│ │
│ └───__pycache__
│ settings.cpython-35.pyc
│ urls.cpython-35.pyc
│ wsgi.cpython-35.pyc
│ __init__.cpython-35.pyc




Answer Source

The leading dot in include('.upload.urls') is causing the problem.

Assuming that upload is in your project directory (the one that contains, changing it to upload.urls should work.

url(r'^upload/', include('upload.urls')),
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download