Pycharm Python3 Flask Module not Found Error - python

I'm a fairly new programmer I installed flask through pip and was trying to run it in Pycharm, it wouldn't work, so I downloaded Flask 1.02 on Pycharm, it then gave me some error messages which I will include in some pictures. This has been driving me crazy, if anyone can help me fix this I would truly appreciate it!
Error message!
Edit these are the error messages:
Traceback (most recent call last):
File "/Users/Farhan/PycharmProjects/Helloworld/fuck_you.py", line 1, in <module>
from flask import Flask
File "/Users/Farhan/PycharmProjects/Helloworld/venv/lib/python3.6/site-packages/flask/__init__.py", line 17, in <module>
from werkzeug.exceptions import abort
File "/Users/Farhan/PycharmProjects/Helloworld/venv/lib/python3.6/site-packages/werkzeug/__init__.py", line 151, in <module>
__import__('werkzeug.exceptions')
File "/Users/Farhan/PycharmProjects/Helloworld/venv/lib/python3.6/site-packages/werkzeug/exceptions.py", line 67, in <module>
from werkzeug._internal import _get_environ
File "/Users/Farhan/PycharmProjects/Helloworld/venv/lib/python3.6/site-packages/werkzeug/_internal.py", line 30, in <module>
string.digits +
AttributeError: module 'string' has no attribute 'ascii_letters'

I found an answer! So, I previously tried to install flask on the virtualenv on pycharm before, but this time I created a new file and a new project within that file, and reinstalled flask on Pycharm with pip install flask, and surprisingly it worked.

Related

Setting up Modelview with Flask-Admin causes ImportError [duplicate]

I am working on a small flask API using flask-admin and flask-sqlalchemy. The api runs well but whenever I install a new package I am faced with an error.
Error: While importing 'app', an ImportError was raised:
Traceback (most recent call last):
File "/Users/brandoncreed/.local/share/virtualenvs/management-System-Wyc_ba1N/lib/python3.8/site-packages/flask/cli.py", line 218, in locate_app
__import__(module_name)
File "/Users/brandoncreed/Desktop/Brandon Coding Projects/management-System/src/app.py", line 12, in <module>
from api.admin import setup_admin
File "/Users/brandoncreed/Desktop/Brandon Coding Projects/management-System/src/api/admin.py", line 5, in <module>
from flask_admin.contrib.sqla import ModelView
File "/Users/brandoncreed/.local/share/virtualenvs/management-System-Wyc_ba1N/lib/python3.8/site-packages/flask_admin/contrib/sqla/__init__.py", line 2, in <module>
from .view import ModelView
File "/Users/brandoncreed/.local/share/virtualenvs/management-System-Wyc_ba1N/lib/python3.8/site-packages/flask_admin/contrib/sqla/view.py", line 18, in <module>
from flask_admin.contrib.sqla.tools import is_relationship
File "/Users/brandoncreed/.local/share/virtualenvs/management-System-Wyc_ba1N/lib/python3.8/site-packages/flask_admin/contrib/sqla/tools.py", line 11, in <module>
from sqlalchemy.ext.associationproxy import ASSOCIATION_PROXY
ImportError: cannot import name 'ASSOCIATION_PROXY' from 'sqlalchemy.ext.associationproxy' (/Users/brandoncreed/.local/share/virtualenvs/management-System-Wyc_ba1N/lib/python3.8/site-packages/sqlalchemy/ext/associationproxy.py)
I am not sure what is causing this but it seems there is a conflict between flask_admin and sqlalchemy after the new package is installed. I deleted the pipfile.lock in my virtual environment and ran pipenv install to see if the new file would work but it did not. I also tried uninstalling the new package to see if it would resolve the issue but the same error still persists. I am wondering if it was to do with updating either flask-admin or sqlalchemy.
Flask-Admin has not yet been updated to work with SQLAlchemy 2.0. The is an open issue for this specific problem. The recommended workaround is to install an earlier version of SQSLALchemy, for example:
python3 -m pip install --upgrade 'sqlalchemy<2.0'

Import cv2 Error in google cloud virtual machine

I am currently trying to run a python script on a GCE virtual machine. However, I keep getting an error when using 'import cv2':
Traceback (most recent call last):
File "train.py", line 12, in <module> from deeplab.datasets import DataSetTrain, DataSetVal
File "/jet/prs/workspace/FYP-Project/Pytorch-Deeplab-master/deeplab/datasets.py", line 10, in <module>
import cv2
File "/jet/prs/workspace/lib/python3.6/site-packages/cv2/__init__.py", line 3, in <module>
from .cv2 import *
ImportError: libgthread-2.0.so.0: cannot open shared object file: No such file or directory
The problem with this is that I have checked that the directory the file being referenced is present. I have installed and reinstalled cv2, however nothing seems to be working. None of the other modules that i installed using pip have this issue, it seems to only occur with cv2.

Why i got that problems when i run my script?

Hi, is there a solution for this error code ?
Traceback (most recent call last):
File "./weevely.py", line 2, in <module>
from core.terminal import Terminal
File "/Users/ismailtaibi/Desktop/isdo/scripts/weevely/core/terminal.py", line 6, in <module>
from core.module import Status
File "/Users/ismailtaibi/Desktop/isdo/scripts/weevely/core/module.py", line 14, in <module>
from core.vectorlist import VectorList
File "/Users/ismailtaibi/Desktop/isdo/scripts/weevely/core/vectorlist.py", line 15, in <module>
from core.vectors import Os
File "/Users/ismailtaibi/Desktop/isdo/scripts/weevely/core/vectors.py", line 11, in <module>
from mako.template import Template
ImportError: No module named mako.template
Thanks.
The answer is pretty self explainatory and with a google search you could have solved everything in seconds.
Here you have a how to install pip if you don`t have it: How do I install pip on macOS or OS X?
After this type in the terminal:
pip install Mako
as stated in the official website: http://www.makotemplates.org/download.html
If this doesn`t work you can manually download the Mako package here:
https://pypi.python.org/pypi/Mako/
Please, also read this carefully:
https://stackoverflow.com/help/how-to-ask

Python/Flask error: “ImportError: cannot import name _compare_digest”

I run linux mint 17.2 XCFE on my computer.
My issue is nearly identical to the one found in this thread, except I tried all of the solutions offered and none worked. It's worth noting that as a result of me trying to fiddle with python, my machine now runs 2.7.8 and the venv runs 2.7.6, which is easy to fix but might be relevant.
I also consulted this and this, and tried changing the name of file called operator and a different virtualenv command as suggested in those, but nothing worked. (Note: I then changed the name of that file back to operator just because since that wasn't the problem I'd rather not mess with it).
When I try to run a very simple script for flask newbs I keep encountering the same error.
(venv)joshua#joshua-ThinkPad-Edge-E430 ~/website/projects/helloapp $ python hello.py
Traceback (most recent call last):
File "hello.py", line 1, in <module>
from flask import Flask
File "/home/joshua/website/projects/helloapp/venv/lib/python2.7/site-packages/flask/__init__.py", line 21, in <module>
from .app import Flask, Request, Response
File "/home/joshua/website/projects/helloapp/venv/lib/python2.7/site-packages/flask/app.py", line 26, in <module>
from . import json
File "/home/joshua/website/projects/helloapp/venv/lib/python2.7/site-packages/flask/json.py", line 25, in <module>
from itsdangerous import json as _json
File "/home/joshua/website/projects/helloapp/venv/lib/python2.7/site-packages/itsdangerous.py", line 14, in <module>
import hmac
File "/home/joshua/anaconda/lib/python2.7/hmac.py", line 8, in <module>
from operator import _compare_digest as compare_digest
ImportError: cannot import name _compare_digest
I have been trying to figure out a solution on my own for hours but I've had no luck. I think it might have to do with Anaconda but I'm not sure what could be done if that's the case.
As it turns out the issue was that the hmac.py file had a reference to a method that it appears no longer existed. I disabled that reference with '#' (just incase it turns out it was important) and it started working.

Python requests_ntlm import error

Hello i am receiving the following error when i try to import the requests_ntlm package. I installed the package with easy_install requests-ntlm. I am trying to use this library so that I can log onto an aspx.net webserver with www-authenticate: negotatiate NTLM response header using python. Appreciate any help solving this issue let me know if I need to provide more information. Thanks!
Traceback (most recent call last):
File "SHS.py", line 2, in <module>
from requests_ntlm import HttpNtlmAuth
File "build\bdist.win-amd64\egg\requests_ntlm\__init__.py", line 1, in <module
>
File "build\bdist.win-amd64\egg\requests_ntlm\requests_ntlm.py", line 4, in <m
odule>
File "C:\python27\lib\site-packages\python_ntlm3-1.0.1-py2.7.egg\ntlm3\__init_
_.py", line 2, in <module>
from . import HTTPNtlmAuthHandler # noqa
File "C:\python27\lib\site-packages\python_ntlm3-1.0.1-py2.7.egg\ntlm3\HTTPNtl
mAuthHandler.py", line 20, in <module>
from . import ntlm
File "C:\python27\lib\site-packages\python_ntlm3-1.0.1-py2.7.egg\ntlm3\ntlm.py
", line 25, in <module>
from . import des
File "C:\python27\lib\site-packages\python_ntlm3-1.0.1-py2.7.egg\ntlm3\des.py"
, line 19, in <module>
from . import des_c
File "C:\python27\lib\site-packages\python_ntlm3-1.0.1-py2.7.egg\ntlm3\des_c.p
y", line 19, in <module>
from .des_data import des_SPtrans, des_skb
File "C:\python27\lib\site-packages\python_ntlm3-1.0.1-py2.7.egg\ntlm3\des_dat
a.py", line 25, in <module>
U32(0x00820200), U32(0x00020000), U32(0x80800000), U32(0x80820200),
File "C:\python27\lib\site-packages\python_ntlm3-1.0.1-py2.7.egg\ntlm3\U32.py"
, line 32, in __init__
value = six.byte2int(value)
File "C:\python27\lib\site-packages\six-1.8.0-py2.7.egg\six.py", line 605, in
byte2int
return ord(bs[0])
TypeError: 'long' object is not subscriptable
Sorry about that! Package maintainer here.
It looks like it was a problem with Windows. I just released v1.0.2 which fixes this and added Appveyor support to catch these problems in future.
Edit: On a Windows PC you probably hit the error with pip HttpNtlmAuth to fix it you will need to pip requests_ntlm to get v1.0.2.
Not an answer, however:
I've opened a GitHub issue for this bug: https://github.com/trustrachel/python-ntlm3/issues/6 .
Currently the workaround is to use requests-ntlm version 0.0.3.
I also struggled with this problem when I am on
Python 3.7.0
requests-ntlm==1.1.0
Finally SOLVED with different version
Python 3.7.0
requests-ntlm==0.1.0
I had the same issue while connecting to SharePoint using SSO(Single Sign-On)
The following statement solved my problem:
pip install requests_ntlm

Categories

Resources