I have successfully installed PyMySQL in my Ubuntu 16.04 OS using pip command:
debarati#debarati-hp:~$ pip install PyMySQL
Collecting PyMySQL
Downloading PyMySQL-0.8.0-py2.py3-none-any.whl (83kB)
100% |████████████████████████████████| 92kB 159kB/s
Installing collected packages: PyMySQL
Successfully installed PyMySQL-0.8.0
Still when I am trying to execute a Python file called view_rows.py , it's giving the following error:
debarati#debarati-hp:~$ python view_rows.py
Traceback (most recent call last):
File "view_rows.py", line 5, in <module>
import PyMySQL
ModuleNotFoundError: No module named 'PyMySQL'
But, this does not give any error:
debarati#debarati-hp:~$ import PyMySQL
This is my Python version:
debarati#debarati-hp:~$ python -V
Python 3.6.3 :: Anaconda custom (64-bit)
The package name is "PyMySQL"; you use the package name to install it. To use the installed package, you need to use the module name, which may not be the same. In this case, the module is named "pymysql" (all lower-case).
The import should be import pymysql.
https://pymysql.readthedocs.io/en/latest/py-modindex.html
Related
I would like to connect to Oracle database from VS Code. In the Terminal I ran
pip install cx_oracle
and it stated:
Requirement already satisfied: cx_oracle in c:\python38\lib\site-packages (8.1.0)
but when I ran the code: import cx_Oracle it returned:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-8-1e79d9171cfb> in <module>
----> 6 import cx_Oracle
ModuleNotFoundError: No module named 'cx_Oracle'
In Extensions in VS Code I entered cx_Oracle in the search bar and it showed No extensions found.
How to use 'cx_Oracle' in VS Code?
Update:
Changed the interpreter to python38 as seen in screenshot below but didn't seem to work.
Try to download the whl file of cx-Oracle from here.
For example download the file to F:/file.
Then use command pip install F:/file/cx_Oracle-8.1.0-cp38-cp38-win_amd64.whl to install.
[UPDATE] - An antivirus software installed on my computer was causing the issue. Disabling it solved the problem :)
I'm getting a weird error when I try to import psycopg2.
Using Python 3.7.7
Downloaded psycopg2 using pip
$ python -m pip install psycopg2
Collecting psycopg2
Using cached psycopg2-2.8.5-cp37-cp37m-win_amd64.whl (1.1 MB)
Installing collected packages: psycopg2
Successfully installed psycopg2-2.8.5
import psycopg2
if name =="main":
print("Hello World!")
Running the code gives me the below error:
$ python test2.py Traceback (most recent call last): File "test2.py", line 1, in <module>
import psycopg2
File "C:\Users\blah\AppData\Local\Programs\Python\Python37\lib\site-packages\psycopg2\__init__.py", line 51, in <module>
from psycopg2._psycopg import ( # noqa ImportError: dynamic module does not define module export function (PyInit__psycopg)
Have tried installing pscopg2-binary instead. Still getting the same error.
Any idea?
I have tried every answer I can find to install PyMySQL for example see below:
sudo pip install PyMySQL
Downloading/unpacking PyMySQL
Downloading PyMySQL-0.7.11-py2.py3-none-any.whl (78kB): 78kB downloaded
Installing collected packages: PyMySQL
Successfully installed PyMySQL
But still no luck, it just returns the following when .py script is run which uses pymysql:
python UpworkCode.py
Traceback (most recent call last):
File "UpworkCode.py", line 2, in <module>
import PyMySQL
ImportError: No module named PyMySQL
Please could someone help me out of this pit of despair thanks
Use import pymysql instead!In fact, the correct package name is pymysql, not PyMYSQL!
Remember,pip is not case sensitive, but python is!
After successful installation of the pybgg, when tried to run
$python test_pybbg.py
Got the following error message:
ImportError: No module named blpapi
MacBook:pfinance Allen$ which python
/Users/Allen/anaconda/bin/python
MacBook:pfinance Allen$ python test_pybbg.py
Traceback (most recent call last):
File "test_pybbg.py", line 2, in
import pybbg
File "/Users/Allen/anaconda/lib/python2.7/site-packages/pybbg/init.py", line 8, in
from .pybbg_k import Pybbg
File "/Users/Allen/anaconda/lib/python2.7/site-packages/pybbg/pybbg_k.py", line 8, in
import blpapi
ImportError: No module named blpapi
I used $pip list, but failed to see blpapi from the output list.
Any suggestions on how to fix my problem?
Thanks in advance
Ps. The followings show my installation log
MacBook:pfinance Allen$ pip install git+https://github.com/hubertrogers/pybbg
Collecting git+https://github.com/hubertrogers/pybbg
Cloning https://github.com/hubertrogers/pybbg to /private/var/folders/c6/7s88m85x0fj7l0zc52y_kcbh0000gn/T/pip-XagRDz-build
Installing collected packages: pybbg
Running setup.py install for pybbg ... done
Successfully installed pybbg-0.0.1
Based on the post I have set the library links properly;
MacBook:pfinance Allen$ echo $DYLD_LIBRARY_PATH
/Users/Allen/pfinance/blpapi_cpp_3.8.1.1/Darwin/
MacBook:pfinance Allen$ echo $BLPAPI_ROOT
/Users/Allen/pfinance/blpapi_cpp_3.8.1.1
I need to install Python 2.7 on a machine, from source, alongside the existing version on the machine (2.4). I have compiled and installed Python successfully, but when I try to run a script calling the MySQLDB module, it throws the following error:
[root#the-node1 bin]# interactive_recording_archive.py
Traceback (most recent call last):
File "/usr/local/bin/interactive_recording_archive.py", line 8, in <module>
import MySQLdb as mdb
ImportError: No module named MySQLdb
I have tried installing MySQLDB using the easy-install script but this fails to find any module by that name. I have MySQL installed and working on the machine.
What am I doing wrong?
The package is called MySQL-python:
easy_install MySQL-python
Do check the installation requirements; you have python and setuptools, but you need the mysql-devel package too.