ImportError: No module named 'pymysql.cursors' - python-3.x

I am beginner in python and want to use database.I have followed following link for database access.
steps
The output of steps which i has used as following :
Command
pip3 -V
Result
pip 18.1 from /usr/local/lib/python3.5/dist-packages/pip (python 3.5)
Second Command
pip3 install PyMySQL
Result
Requirement already satisfied: PyMySQL in /usr/local/lib/python3.5/dist-packages/PyMySQL-0.9.2-py3.5.egg (0.9.2)
While i was using script to access database i got following error.
Traceback (most recent call last):
File "pymysql.py", line 2, in <module>
import pymysql.cursors
File "/var/www/cgi-bin/pymysql.py", line 2, in <module>
import pymysql.cursors
ImportError: No module named 'pymysql.cursors';
`enter code here`'pymysql' is not a package
Environment :
OS - Ubuntu 16.04
Python version - Python 3.5

Try the below command,
python3 -m pip install PyMySQL

Related

Import "ruamel.yaml" could not be resolved

I am just a beginner in python.
I have a requirement of converting a JSON Object into a YAML file and trying to import ruamel.yaml.
I did install the command pip3 install ruamel.yaml and my python list package shows that it's available.
site-packages % pip3 list
Package Version
------------------ ---------
certifi 2021.10.8
charset-normalizer 2.0.11
idna 3.3
pip 22.0.3
pytz 2021.3
PyYAML 6.0
requests 2.27.1
ruamel.yaml 0.17.21
ruamel.yaml.clib 0.2.6
setuptools 60.9.3
urllib3 1.26.8
Whereas when I am trying to import and use it in the python script it is giving me below error.
Import "ruamel.yaml" could not be resolved
Could someone please suggest how to resolve this.?
When Python cannot find a module you get an error looking like:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named ruamel.yaml
This might be because you are using some non-standard installation/execution environment, or because you try to run this from an editor. Some of those don't understand the concept of namespaces in Python.
It could also be that pip3 is not installing for the python that you are using to run the program. That is easy to check by installing some other package using pip3 and trying to import that.
In either case make sure you test your program running with the python that corresponds to pip3 ( using type pip3 or which pip3 resp type python ), or install using:
python -m pip install ruamel.yaml
and then run the program with python your_prog.py

Error in pdfminer library installation in conda environment

I installed "pdfminer" in virtual environment of conda.
I installed and reinstalled the library with following commands :
conda install -c conda-forge pdfminer
conda install -c conda-forge/label/cf201901 pdfminer
conda install -c conda-forge/label/cf202003 pdfminer
I got the same error all the time. It was like this:
/home/hamza/anaconda3/envs/my/bin/python /home/hamza/PycharmProjects/practice/pdf_info.py
20191125
Traceback (most recent call last):
File "/home/hamza/PycharmProjects/practice/pdf_info.py", line 67, in <module>
from pdfminer.high_level import extract_text
File "/home/hamza/anaconda3/envs/my/lib/python3.7/site-packages/pdfminer/high_level.py", line 14, in <module>
from .utils import open_filename
ImportError: cannot import name 'open_filename' from 'pdfminer.utils' (/home/hamza/anaconda3/envs/my/lib/python3.7/site-packages/pdfminer/utils.py)
Process finished with exit code 1
Is there any alternate way to install this library or what we can do this resolve this error

pdfkit is working on python2 but it's not working in python3

import pdfkit
Error: Traceback (most recent call last):
File "<stdin>", line 1, in <module> ImportError: No module named 'pdfkit'
when i use pdfkit in python2 then it works fine, but if i use in python3 it gives the above error
Packages for Python 2 and Python 3 are completely separate. You have to install any package for both Python versions separately. Try:
sudo python3 -m pip install pdfkit

numpy intalled with pip but not found (in virtualenv)

In an AWS EC2 instance, with Amazon Linux AMI 2016.09 distribution, I have installed numpy, inside my virtualenv where python 3.4 is the default version, with:
pip install numpy
It installs package numpy-1.12.1-cp34-cp34m-manylinux1_x86_64.whl without errors.
After that, in python I try to import it:
>>> import numpy
And I get:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'numpy'
Moreover, if I run pip freeze, numpy does not appear in the list.
Why is numpy not being found? and How to fix it?
Did you do this:
#:source .venv/bin/activate
.....
#:python
....
>>>pip3 install numpy
....
This works!

pip isn't working when importing something

To install pymongo for pypy3 2.1 Beta 1, I installed pip using the following commands:
wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
./pypy ez_setup.py --user
where pypy is the executable of pypy3 2.1 Beta 1. After that, pip and pip-3.2 will come to the current directory. But when running pip or pip-3.2, I get the error:
Traceback (most recent call first):
File "pip-3.2", line 5, in <module>
from pkg_resources import load_entry_point
zipimport.ZipImportError: pip==1.4.1
It seems that the problem comes from from pkg_resources import load_entry_point of the pip/pip-3.2. But this statement runs OK when I put it in pypy or python3 IDLE. What's the matter? How to solve this problem and proceed to install pymongo for pypy3 2.1 Beta 1? Thank you.
PS: I'm using Ubuntu. python3 is installed in the system. If u need any other information pertaining to solving the question, please comment.

Resources