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
Related
I was able to install xgboost on my mac and have it so that I can import the module without any errors. However I cannot use it. When I try to import XGBRegressor. I get the following error :
cannot import name 'XGBRegressor' from 'xgboost' (unknown location).
Some of the support for this type of problem says that there may be more than one xgboost location, and that python is selecting the incorrect xgboost, however I have not been able to find how to fix this problem.
When I print the xgboost.__file__ location, it returns 'None'. However I know its in the site-packages folder in my python path.
I have python 3.9
Maybe this.
conda install -c conda-forge xgboost=0.6a2
Then, restart Spyder and re-run!
I am receiving this error from command prompt: ModuleNotFoundError: No module named 'pickle' running in python 3.7,
I have it setup like this:
import pickle as thisPickle
What can be the reason why I having this import issue, appreciate any help. Thanks.
pickle is a part of the Standard Library and is pre-included in the Python package. There should not be a reason that it does not work. Make sure that no other versions of python exist on your computer. The command prompt may be using outdated versions that still exist. Also, see if other modules install correctly on your machine.
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
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)
I am using python 3.5.2 on windows10 machine and having problems running a py script.
I am getting this error: 'psutil has no attribute process_iter' if either use psutil.process_iter() or psutil.process.get_list().
I have psutil 5.4.3 installed.
Downloaded and tried this file https://pypi.python.org/pypi/psutil.. no luck
Here is the code:
import psutil
def processcheck(seekitem):
for proc in psutil.process_iter():
#for proc in psutil.get_process_list():
if proc.name() == seekitem:
....
for process in machine_process:
processcheck(process)
Any idea how can you get around this?
It works in Linux though.
Thank you.
I had this problem when my script was named psutil.py
Just rename your file if you have the same issue.