I am having trouble in running a flask file that is manager.py on Windows 10. Although I installed requirements, it still aborts an import error.What's funny is the errors are different in PyCharm and cmd. And I activated the same virtual environment.I will appreciate it if someone can help me!
In PyCharm:
Traceback (most recent call last):
File "C:/Users/Administrator/Desktop/Online-serial-debugging/manage.py", line 6, in <module>
from app import create_app
File "C:\Users\Administrator\Desktop\Online-serial-debugging\app\__init__.py", line 2, in <module>
from flask.ext.twisted import twisted
File "C:\Users\Administrator\Desktop\online\Online-serial-debugging\enve\lib\site-packages\flask\exthook.py", line 87, in load_module
raise ImportError('No module named %s' % fullname)
ImportError: No module named flask.ext.twisted.twisted
Process finished with exit code 1
In CMD:
(enve) C:\Users\Administrator\Desktop\online\Online-serial-debugging>python manage.py
Traceback (most recent call last):
File "manage.py", line 5, in <module>
from flask.ext.script import Manager
ImportError: No module named flask.ext.script
Here are my requirments.txt:
construct==2.5.2
dominate==2.1.16
Flask==0.10.1
Flask-Bootstrap==3.3.5.3
Flask-Moment==0.5.0
Flask-Twisted==0.1.1
Flask-Script==2.0.5
itsdangerous==0.24
Jinja2==2.7.3
MarkupSafe==0.23
observable==0.1.0
pyserial==2.7
six==1.10.0
Twisted==15.4.0
txsockjs==1.2.2
pypiwin32
Werkzeug==0.10.4
zope.interface==4.1.2
Please fix your import statement as follows, and could you try?
from flask_script import Manager
EDIT
Sorry, even using flask.ext.{}, it seems still works.
If you run the following command, what come back?
pip install Flask-Script==2.0.5
It means that 'Flask-Script' was not installed, check your 'pip freeze'.
Was there any error when installing the requirements? If so, try to identify the issue.
Try installing it:
$ pip install Flask-Script
OK. The problem is solved.orz. My command line is :
python manage.py
Actually, I used the Python interpreter in system path by mistake.And I run this command :
./enve/Scripts/python.exe manage.py
There are no import errors again, thank you who answered me still.
Related
apologies if this question has been asked a ton, I'm sure it has, and I've been trying for days to figure this out, but I can't wrap my head around it. I've been developing in Python for over 1.5 years, so I'm not a complete beginner.
I can't get Django to work in my command prompt. An example is, when I try to use py .\manage.py makemigrations this is what I get:
Traceback (most recent call last):
File ".\manage.py", line 11, in main
from django.core.management import execute_from_command_line
ModuleNotFoundError: No module named 'django'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File ".\manage.py", line 22, in <module>
main()
File ".\manage.py", line 13, in main
raise ImportError(
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?
Now, I can see what the error says. The thing is my virtual environment is activated and it has Django installed, as seen here. Moreover, even if I executed outside my venv, it still doesn't work, even though I have all necessary Python directories in my PATH, as seen here.
I have verified that django-admin is installed on both my venv and my system, as well as Django itself, since I can import it on my Python Console. The version is 3.1.7. I have also tried reinstalling Django and it didn't work.
Another error I get, when I attempt to run Django console through PyCharm is this:
Traceback (most recent call last):
File "<input>", line 6, in <module>
File "C:\Users\user\AppData\Roaming\Python\Python39\site-packages\django\__init__.py", line 19, in setup
configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
File "C:\Users\user\AppData\Roaming\Python\Python39\site-packages\django\conf\__init__.py", line 82, in __getattr__
self._setup(name)
File "C:\Users\user\AppData\Roaming\Python\Python39\site-packages\django\conf\__init__.py", line 63, in _setup
raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: Requested setting LOGGING_CONFIG, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
I hope this helps you come up with any idea. Could anyone please share any insight on why I'm getting this? I would greatly appreciate it.
Edit: I have installed Django through PIP:
py -m pip install django
py -m pip install djangorestframework
py -m pip install django-admin
Also, Django is imported correctly from the Python Console within the venv:
>>> import django
>>> django
<module 'django' from 'C:\\Users\\user\\AppData\\Roaming\\Python\\Python39\\site-packages\\django\\__init__.py'>
in cmd to create a virtualenv
python -m venv virtualenv_name
to enable virtualenv
virtualenv_name\scripts\activate.bat
then
pip install django
and to create a project
django-admin startproject projectname
to run the project
cd projectname
python manage.py runserver
And Jinja2 modules Requirement already satisfied
Traceback (most recent call last):
File "/usr/bin/ansible", line 60, in <module>
import ansible.constants as C
File "/usr/lib/python3.7/site-packages/ansible/constants.py", line 12, in <module>
from jinja2 import Template
ModuleNotFoundError: No module named 'jinja2'
This looks like a broken install. A dependency is missing. Try:
pip3 install jinja2
This is not really supposed to happen when you install ansible "normally". If the above does not fix your problem, I suggest you reinstall ansible from scratch on your system
I'm trying to work on python3 and using mac. I have installed pyobjc-core and pyobjc, but the error said Quartz not found. I'm very new to this kind of installing. Is there any solution?
Here is my error from pycharm:
Traceback (most recent call last):
File "/Users/Thyme/PycharmProjects/DinosourBot/venv/lib/python3.6/site-packages/pyautogui/_pyautogui_osx.py", line 5, in <module>
import Quartz
ModuleNotFoundError: No module named 'Quartz'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/Thyme/PycharmProjects/DinosourBot/Bot.py", line 2, in <module>
import pyautogui
File "/Users/Thyme/PycharmProjects/DinosourBot/venv/lib/python3.6/site-packages/pyautogui/__init__.py", line 110, in <module>
from . import _pyautogui_osx as platformModule
File "/Users/Thyme/PycharmProjects/DinosourBot/venv/lib/python3.6/site-packages/pyautogui/_pyautogui_osx.py", line 7, in <module>
assert False, "You must first install pyobjc-core and pyobjc: https://pyautogui.readthedocs.io/en/latest/install.html"
AssertionError: You must first install pyobjc-core and pyobjc: https://pyautogui.readthedocs.io/en/latest/install.html
Process finished with exit code 1
In case anyone stumbles here use:
pip install pyobjc-framework-Quartz
I have solved the problem by
installing pyobjc-framework-Quartz,
it's provided by pycharm
I'd suggest it's best to install all of pyObjC, rather than just specific frameworks. Invariably, if you're working with Quartz, you're going to need various CoreFoundation objects and constants at the very least. To say nothing of AppKit, or other frameworks, depending on what you're doing.
pip install pyobjc (or pip3) should install everything and let you import Quartz. (It works for me on several pythons!)
According to the documentation of rope-vim plugin I install python-rope and python-ropemode mode packages. However when I try to open some file using vim I get following ImportError:
Error detected while processing function LoadRope:
line 4:
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named ropevim
I have found the ropevim module is already in plugin's directory but when I had tried to import it:
python -c "import ropevim"
I get another ImportError:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "ropevim.py", line 10, in <module>
import vim
ImportError: No module named vim
Have I miss any package? Some ideas? Thank you for your help.
Install ropevim using pip install ropevim
ropevim is currently a Python 2 project.
pip2 install --user --update ropevim
I know it might not be the answer you're looking for, but I'm using klen/python-mode plugin with rope included and it's working like a charm.
I'm also using Vim-Plug to manage my plugins and it's as easy as:
Plug 'klen/python-mode', { 'for': ['python'] }
Here is my .vimrc
Hope this helps! :)
I'm trying to install setuptools 0.9.7 with Python 3.3. I try to run "python setup.py", and also "python setup.py install" from a cmd window in a directory separate from my default python dir, and get back:
Traceback (most recent call last):
File "setup.py", line 5 in ?
import textwrap
ImportError: No module named textwrap
...even though I checked \Lib\ and textwrap.py is there. So then I copied textwrap.py to the directory I was trying to install setuptools from, and then get:
Traceback
File "setup.py", line 5, in ?
import textwrap
File "textwrap.py", line 404
yield (prefix + line if predicate(line) else line)
SyntaxError
...even though I can import textwrap.py just fine while working in the default Python directory. So I'm at a loss. I should say that I've tried to install two other modules and have received similar import errors, I was hoping setuptools would fix that. Any ideas?