ScreenGrab of error when trying to import db I created
You either need to install Flask from pip, or something similar, or Python is not able to find the location of Flask if it is, in fact, installed.
At your Python prompt, try this to see where it is looking for libraries:
>> import sys
>> print (sys.path)
Related
i installed flask in the cmd using the pip install flask command and i also tested it in the cmd and it works.
But when i go to pycharm all the modules i download using pip are for some reason in lib/site_packages
instead of just being in site_packages.the lib folder
and then i do "from flask import Flask"
and it says that " cannot import name 'Flask' from 'flask' (C:\Users\User\PycharmProjects\pythonProject1\flask.py)"
the error
there is no Flask in flask
Change the py file name to anything else. naming your flask file as flask.py will create a namespace conflict.
Here is my code:
from tabula import wrapper
df = wrapper.read_pdf('singapore.pdf')
But it gives following error:
ImportError: cannot import name 'wrapper'
I tried it on ubuntu and it works fine there but on Windows I am unable to use this code, as it always gives the above error. I installed tabula by using this command:
pip3 install tabula-py
Here is how I resolved it, you need to add java path to environment variables. More details can be found here:
https://tabula-py.readthedocs.io/en/latest/getting_started.html#get-tabula-py-working-windows-10
I'm trying to run a program which connects to all databases(mysql,sqlite) and fetch data from it .
Python version - 3.6.8
Since the code is too long ,i'm showing only particular snippets.
def show_columns_mysql(cursor,tbname):
cursor.execute("""show columns from %s"""%(tbname))
rs=cursor.fetchall()
colname=[]
for i in rs:
colname.append(i[0])
return colname
There is no problem or issue if i exexute the program in normal python environment . When i try to execute this in virtual environment ,it shows me No module named 'cPickle' .
I have tried all the solutions but none solved my problem .
What was the problem ?
There is no cPickle in Python 3. Just import pickle. pickle will automatically use the C accelerator.
Install pickle. Then do:
import pickle as cPickle
I am trying to run my Flask application with an Apache server using mod_wsgi, and it has been a bumpy road, to say the least.
It has been suggested that I should try to run my app's .wsgi file using Python to make sure it is working.
This is the contents of the file:
#!/usr/bin/python
activate_this = '/var/www/Giveaway/Giveaway/venv/bin/activate_this.py'
with open(activate_this) as f:
code = compile(f.read(), "somefile.py", 'exec')
exec(code)
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/Giveaways/")
from Giveaways import application
application.secret_key = 'Add your secret key'
However, when I run it, I get this error:
ImportError: No module named 'zlib'
And no, I am not using some homebrewed version of Python - I installed Python 3 via apt-get.
Thanks for any help.
does the contents of somefile.py include the gzip package? in which case you may have to install gzip package via pip or similar
I work with ubuntu 12.04 and I want to know whether Django is currently installed. I tried it like this at first:
$ python
>>> import django
>>> django
but I want to do it in the terminal. I don't want to use dpkg because the user might have installed it with python-pip. I already tried find and whereis but that didn't work either.
Write simple script using python:
#!/usr/bin/python
import sys
import os
try:
import django
print "found"
print "path={0}".format(os.path.dirname(django.__file__))
sys.exit(0)
except ImportError:
print "not found"
sys.exit(0)
then run script and check for exit code
$ python script.py
$ echo $?
You should have a look at this question: [How do I find the location of Python module sources?][1]