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.
Related
[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?
A similar report was posted, but the suggested solutions do not work.
---- from Jupyter ----
Import psycopg2
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-2-7d2da0a5d979> in <module>
----> 1 import psycopg2
ModuleNotFoundError: No module named 'psycopg2'
If I run python3 from Mac terminal and then import psycopg2 that works.
If I run python3 from Jupyterlab terminal this does not work. I get the following error after running import pyscopg2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/psycopg2/__init__.py", line 50, in <module>
from psycopg2._psycopg import ( # noqa
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/psycopg2/_psycopg.cpython-38-darwin.so, 2): Library not loaded: #rpath/libssl.1.1.dylib
Referenced from: /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/psycopg2/_psycopg.cpython-38-darwin.so
Reason: image not found
echo $PATH from Mac terminal is
/Users/greg/opt/miniconda3/bin:/Users/greg/opt/anaconda3/condabin:/Library/Frameworks/Python.framework/Versions/3.8/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
echo $PATH from Jupyterlab terminal is
/Library/Frameworks/Python.framework/Versions/3.8/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/greg/opt/miniconda3/bin:/Users/greg/opt/anaconda3/condabin
These look the same, just in a different order.
I have tried pip install psycopg2 both with and without the binary option.Either way, it says already satisfied.
I have tried
conda install -c anaconda psycopg2
Also tried installing postgresql both from the postgresql.org, and brew install psycopg2. Both worked, but no luck with Jupyterlab.
try installing the package using: pip install psycopg2-binary. This should work.
For more information, visit: https://www.psycopg.org/docs/install.html
I am trying to use the zmq Python library but it is not recognized and I have already installed it by using the following command:
pip3 install pyzmq
I am using PyCharm IDE.
The run output gives me this error:
Traceback (most recent call last):
File "C:/Users/Operações/Desktop/Testes/teste.py", line 2, in <module>
import zmq
ModuleNotFoundError: No module named 'zmq'
Does anyone can help me with this?
Instead of using pip, try installing pyzmq from File/Settings in PyCharm.
Open the Settings/Preferences
Navigate to Project: -> Python Interpreter
Klick the + at the bottom of the list
Search for your package of choice and hit Install Package
For more details on installing/uninstalling packages in PyCharm:
https://www.jetbrains.com/help/pycharm/installing-uninstalling-and-upgrading-packages.html
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
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!