I am using python 3.5 and windows 10, but had the same issue using windows 8, and that is the traceback i get while trying to runserver:
Traceback (most recent call last):
File "C:\Users\noabendor87\documents\otree\manage.py", line 10, in
execute_from_command_line(sys.argv, script_file=file)
File "c:\users\noabendor87\appdata\local\programs\python\python35-32\lib\site-packages\otree\management\cli.py", line
177, in execute_from_command_line
utility.execute()
File "c:\users\noabendor87\appdata\local\programs\python\python35-32\lib\site-packages\django\core\management__init__
.py", line 346, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "c:\users\noabendor87\appdata\local\programs\python\python35-32\lib\site-packages\django\core\management\base.py"
, line 394, in run_from_argv
self.execute(*args, **cmd_options)
File "c:\users\noabendor87\appdata\local\programs\python\python35-32\lib\site-packages\django\core\management\commands
\runserver.py", line 49, in execute
super(Command, self).execute(*args, **options)
File "c:\users\noabendor87\appdata\local\programs\python\python35-32\lib\site-packages\django\core\management\base.py"
, line 445, in execute
output = self.handle(*args, **options)
File "c:\users\noabendor87\appdata\local\programs\python\python35-32\lib\site-packages\django\core\management\commands
\runserver.py", line 88, in handle
self.run(**options)
File "c:\users\noabendor87\appdata\local\programs\python\python35-32\lib\site-packages\django\core\management\commands
\runserver.py", line 97, in run
autoreload.main(self.inner_run, None, options)
File "c:\users\noabendor87\appdata\local\programs\python\python35-32\lib\site-packages\django\utils\autoreload.py", li
ne 336, in main
reloader(wrapped_main_func, args, kwargs)
File "c:\users\noabendor87\appdata\local\programs\python\python35-32\lib\site-packages\django\utils\autoreload.py", li
ne 307, in python_reloader
exit_code = restart_with_reloader()
File "c:\users\noabendor87\appdata\local\programs\python\python35-32\lib\site-packages\django\utils\autoreload.py", li
ne 293, in restart_with_reloader
exit_code = os.spawnve(os.P_WAIT, sys.executable, args, new_environ)
UnicodeEncodeError: 'mbcs' codec can't encode characters in position 0--1: invalid character
I have already tried following the instructions in the following link:
http://stackoverflow.com/questions/25714826/error-in-manage-py-runserver-with-django-on-windows-8-1
but it did not help.
This is how the lines of code look like:
enter image description here
(Since Im a new user I cannot paste the image to the original post)
Anyone have encountered something similar and have a solution?
I used to have similar problems because of the difficulties with the virtual environment in windows 10. Try running the powershell as an administrator and do "Set-ExecutionPolicy RemoteSigned" or "Set-ExecutionPolicy Unrestricted" if remotesigned does not work. Do this before activating the virtualenv.
first I will like you check the django version you are working with my "type python -m django --version" or "pip freeze". check weather its compatible with the python version on your pc. if it's not install compatible python version. then check weather "init.py" is within your project directory, if not add it to your project directory. then run "Set-ExecutionPolicy -Scope CurrentUser Unrestricted" on your terminal. then run activate your virtualenv, then run "python manage.py runserver"
Related
So I'm working on this test app in Django and i wanted to add some data to my sql tables through the python shell. I ran the following command from the CMD
λ python manage.py shell
Which gave me the following output:
Traceback (most recent call last): File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv) File "C:\Python\lib\site-packages\django\core\management\__init__.py", line 371, in execute_from_command_line
utility.execute() File "C:\Python\lib\site-packages\django\core\management\__init__.py", line 365, in execute
self.fetch_command(subcommand).run_from_argv(self.argv) File "C:\Python\lib\site-packages\django\core\management\base.py", line 288, in run_from_argv
self.execute(*args, **cmd_options) File "C:\Python\lib\site-packages\django\core\management\base.py", line 335, in execute
output = self.handle(*args, **options) File "C:\Python\lib\site-packages\django\core\management\commands\shell.py", line 99, in handle
return getattr(self, shell)(options) File "C:\Python\lib\site-packages\django\core\management\commands\shell.py", line 35, in ipython
from IPython import start_ipython File "C:\Python\lib\site-packages\IPython\__init__.py", line 55, in <module>
from .terminal.embed import embed File "C:\Python\lib\site-packages\IPython\terminal\embed.py", line 15, in <module>
from IPython.core.interactiveshell import DummyMod, InteractiveShell File "C:\Python\lib\site-packages\IPython\core\interactiveshell.py", line 109, in <module>
_assign_nodes = (ast.AugAssign, ast.AnnAssign, ast.Assign) AttributeError: module 'ast' has no attribute 'AnnAssign'
I'm using Python 3 and Django 2.0.3.
Some things I tried on my own:
I checked that ipython was up to date using pip, my database runs on SQL community server runs and works fine and the Django server itself also runs without issues.
EDIT: I did some more digging AST is part of the standard python library. However i dont find any issues with my python install, any ideas?
EDIT2: Tried reinstalling Ipython, same traceback error.
Alright, so i did a complete reinstall of Django and Mysqlclient through PIP which solved the problem. I now have acess to the django shell.
Since a while any python manage.py command that requires an input (removing null=True without providing default, recollecting static files...) does not accept said input. when I press enter it simply displays the carriage return char ^M in the console. I have no Idea how to debug this, as ctrl+ c simply gives tracebacks like these:
./manage.py makemigrations
You are trying to change the nullable field 'package' on company to non-nullable without a default; we cannot do that (the database needs something to populate existing rows).
Please select a fix:
1) Provide a one-off default now (will be set on all existing rows with a null value for this column)
2) Ignore for now, and let me handle existing rows with NULL myself (e.g. because you added a RunPython or RunSQL operation to handle NULL values in a previous data migration)
3) Quit, and let me add a default in models.py
Select an option: 1^M^M^M^C^CKeyboardInterrupt
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "./manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/Users/mac/.virtualenvs/mindance/lib/python3.6/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
utility.execute()
File "/Users/mac/.virtualenvs/mindance/lib/python3.6/site-packages/django/core/management/__init__.py", line 355, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/mac/.virtualenvs/mindance/lib/python3.6/site-packages/django/core/management/base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "/Users/mac/.virtualenvs/mindance/lib/python3.6/site-packages/django/core/management/base.py", line 330, in execute
output = self.handle(*args, **options)
File "/Users/mac/.virtualenvs/mindance/lib/python3.6/site-packages/django/core/management/commands/makemigrations.py", line 177, in handle
migration_name=self.migration_name,
File "/Users/mac/.virtualenvs/mindance/lib/python3.6/site-packages/django/db/migrations/autodetector.py", line 47, in changes
changes = self._detect_changes(convert_apps, graph)
File "/Users/mac/.virtualenvs/mindance/lib/python3.6/site-packages/django/db/migrations/autodetector.py", line 189, in _detect_changes
self.generate_altered_fields()
File "/Users/mac/.virtualenvs/mindance/lib/python3.6/site-packages/django/db/migrations/autodetector.py", line 920, in generate_altered_fields
new_default = self.questioner.ask_not_null_alteration(field_name, model_name)
File "/Users/mac/.virtualenvs/mindance/lib/python3.6/site-packages/django/db/migrations/questioner.py", line 182, in ask_not_null_alteration
"Quit, and let me add a default in models.py",
File "/Users/mac/.virtualenvs/mindance/lib/python3.6/site-packages/django/db/migrations/questioner.py", line 99, in _choice_input
result = input("Select an option: ")
SystemError: <built-in function input> returned a result with an error set
Any hints on how to approach this issue? I reinstalled my virtualenv. Maybe I should reinstall python?
Versions:
Python 3.6.1
Django==1.11.2
run this command stty sane in the ubuntu terminal first and then try to run the migrate with python manage.py migrate
I am trying to run the following command
python manage.py makemigrations
But, getting the error
ValueError: path is on mount 'C:', start on mount 'F:'
What can be the reason?
complete traceback:-
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "C:\Python34\lib\site-packages\django\core\management\__init__.py", line 367, in execute_from_command_line
utility.execute()
File "C:\Python34\lib\site-packages\django\core\management\__init__.py", line 359, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Python34\lib\site-packages\django\core\management\base.py", line 294, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Python34\lib\site-packages\django\core\management\base.py", line 345, in execute
output = self.handle(*args, **options)
File "C:\Python34\lib\site-packages\django\core\management\commands\makemigrations.py", line 189, in handle
self.write_migration_files(changes)
File "C:\Python34\lib\site-packages\django\core\management\commands\makemigrations.py", line 207, in write_migration_files
migration_string = os.path.relpath(writer.path)
File "C:\Python34\lib\ntpath.py", line 579, in relpath
raise ValueError(error)
ValueError: path is on mount 'C:', start on mount 'F:'
The error is occurring because Django is trying to find a relative path between 2 directories and they do not exist (since they are on different drives). This issue is mentioned here: https://bugs.python.org/issue7195. But this response helps to understand the problem: https://bugs.python.org/msg94780.
os.relpath does give you a relative path between two directories.
The problem you are encountering is that, on Windows, a relative path
doesn't even exist if the two directories are on different drives
(which is exactly what the error message says).
When I ran into this error, I was trying to make a migration file for my own app that is located on the F: drive. Running:
python.exe .\manage.py makemigrations
had Django scanning for every change. It located a change for djcelery. This is located in a virtual environment on my C: drive.
To fix this, I just added the app name when calling makemigrations:
python.exe .\manage.py makemigrations <<app_name>>
My current version of python is 2.7.10 and version of Django is 1.9.1, path.py is 8.1.2 but every time when I'm trying to invoke python shell by command:
$ python manage.py shell I'm getting a lot of errors and the ending of them looks like:
Error in sys.excepthook:
Traceback (most recent call last):
File "W:\SVN\vendors\python\win32\lib\site-packages\IPython\CrashHandler.py", line 157, in __call__
report.write(self.make_report(traceback))
File "W:\SVN\vendors\python\win32\lib\site-packages\IPython\CrashHandler.py", line 215, in make_report
rpt_add('BZR revision : %s \n\n' % Release.revision)
AttributeError: 'module' object has no attribute 'revision'
Original exception was:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "W:\SVN\vendors\python\win32\lib\site-packages\django\core\management\__init__.py", line 353, in execute_from_command_line
utility.execute()
File "W:\SVN\vendors\python\win32\lib\site-packages\django\core\management\__init__.py", line 345, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "W:\SVN\vendors\python\win32\lib\site-packages\django\core\management\base.py", line 348, in run_from_argv
self.execute(*args, **cmd_options)
File "W:\SVN\vendors\python\win32\lib\site-packages\django\core\management\base.py", line 399, in execute
output = self.handle(*args, **options)
File "W:\SVN\vendors\python\win32\lib\site-packages\django\core\management\commands\shell.py", line 69, in handle
self.run_shell(shell=options['interface'])
File "W:\SVN\vendors\python\win32\lib\site-packages\django\core\management\commands\shell.py", line 58, in run_shell
return getattr(self, shell)()
File "W:\SVN\vendors\python\win32\lib\site-packages\django\core\management\commands\shell.py", line 41, in ipython
ip()
File "W:\SVN\vendors\python\win32\lib\site-packages\django\core\management\commands\shell.py", line 22, in _ipython_pre_011
shell = IPShell(argv=[])
File "W:\SVN\vendors\python\win32\lib\site-packages\IPython\Shell.py", line 73, in __init__
debug=debug,shell_class=shell_class)
File "W:\SVN\vendors\python\win32\lib\site-packages\IPython\ipmaker.py", line 521, in make_IPython
IP.pre_config_initialization()
File "W:\SVN\vendors\python\win32\lib\site-packages\IPython\iplib.py", line 835, in pre_config_initialization
self.db = pickleshare.PickleShareDB(rc.ipythondir + "/db")
File "W:\SVN\vendors\python\win32\lib\site-packages\IPython\Extensions\pickleshare.py", line 53, in __init__
if not self.root.isdir():
TypeError: _isdir() takes exactly 1 argument (0 given)
How can I overcome the problem?
From doing a quick search, it looks like this error happens when both Django and IPython are installed, since apparently Django will attempt to use the IPython shell.
The first resource with someone who had a similar issue:
run python manage.py shell occurs errors
And in the link above, one of the comments on the OP's question suggested looking at this separate thread for answers:
https://superuser.com/questions/318655/error-running-ipython3-on-xp-typeerror-isdir-takes-exactly-1-argument-0-gi
The winning answer says the following:
Finally decided to give this another stab, and managed to get it to
work. The solution is a two-line change in the
ipython-0.11-py3.2.egg\IPython\utils\pickleshare.py file, line 52:
Before:
if not self.root.isdir():
self.root.makedirs()
After:
if not os.path.isdir(self.root):
os.makedirs(self.root)
Sorry to ask a noob question but I have no idea why this is happening.
I've just reinstalled Django 1.3, and am trying PyCharm for the first time. When I run python manage.py runserver from Terminal everything goes without a hitch, however if I try to runserver from within PyCharm I get the following:
Importing Django settings module settings
Traceback (most recent call last):
Validating models...
0 errors found
Django version 1.3, using settings 'glist.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
File "/Applications/PyCharm 1.2.1.app/helpers/pycharm/django_manage.py", line 19, in <module>
run_module(manage_file, None, '__main__')
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 180, in run_module
fname, loader, pkg_name)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/Users/goon/code/glist/manage.py", line 14, in <module>
execute_manager(settings)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", line 191, in run_from_argv
self.execute(*args, **options.__dict__)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", line 220, in execute
output = self.handle(*args, **options)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 67, in handle
self.run(*args, **options)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 76, in run
autoreload.main(self.inner_run, args, options)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/autoreload.py", line 131, in main
reloader(main_func, args, kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/autoreload.py", line 104, in python_reloader
reloader_thread()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/autoreload.py", line 83, in reloader_thread
ensure_echo_on()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/autoreload.py", line 77, in ensure_echo_on
attr_list = termios.tcgetattr(fd)
termios.error: (25, 'Inappropriate ioctl for device')
Process finished with exit code 1
Please note that this is all happening before I request any page from within the browser. And, as I said, I have no trouble running from Terminal. Any help would be greatly appreciated.
What version fo pycharm are you using ? Actually it`s a error in django 1.3. It will occur if you try to run django from any ide in reload mode. It can be fixed by patching django. Although PyCharm should automatically switch to no reload mode.
Read this : http://blogs.jetbrains.com/pycharm/2011/03/pycharm-1-2-1-release-candidate-py-test-2-0-buildout-1-5/
Apply the patch. Its Django 1.3.1 error. This worked for me on pYCharm 3.4.1
https://github.com/django/django/commit/3e7ce3c750