I'm currently working in VS code; wanting to interact with an .mdb file.
File "d:/UDtools/CostEstimator/vsWorkspace/pyOdbcv1.py", line 1, in <module>
import pyodbc
ModuleNotFoundError: No module named 'pyodbc'
pip installed in cmd, pip installed again in VS terminal: Requirement already satisfied.
I'm a bit new to this.
The reason is that the module "pyodbc" you installed is not installed in the VSCode environment you are currently using.
Check the installation tool "pip". When we use 'pip' to install a module, the source of 'pip' determines where the module exists. Use "pip --version" to check if it comes from the current environment:
(If not, please use the shortcut key Ctrl+Shift+` to open a new VSCode terminal, VSCode will automatically enter the current environment.)
Install the module. Use 'pip' to install the module in the currently selected environment: "pip install pyodbc" or "pip3 install pyodbc"
Check the installation package. "pip list":
Run:
More: Environment in VSCode.
If you are using the python extension to run you files. Then you are using python in a virtual envirnment to run python and not the system python. so even if you installed a package, as long as you did not install it in the venv python vs code won't find it.
To test this run your .py file from the command line and see if you get the same error.
if you don't then reconfigure you python interpreter in vs code or install the package in the vnev.
Related
I seem to be facing this error continuously despite:
Installing the mysql-connector via "python -m pip install mysql-connector-python"
Installing the MySQL package via "pip install MySQL"
I have confirmed that I have installed the package as it says "Requirement already satisfied everytime I run it again in the terminal". Additionally, I have tried installing and reinstalling the package as well.
But all the results are the same. Each time I run my script and try to "import mysql.connector", I always get the ModuleNotFoundError: No module named 'mysql' error
Would greatly appreciate some help. Thank you very much
Do you use virtual environments? If it is a virtual environment, please copy the contents in the expansion package folder of the virtual environment to the package folder under python.
If you have two versions of Python in your system, you may also encounter this problem. "CTRL+SHIFT+P" and choose the correct interpreter.
You can use the following method to check and see where pip installed the package:
pip show MySQL
I am using Python 3.9 on Windows 10 which I downloaded directly from the Microsoft Store.
I tried running a script in PowerShell: Bash *.sh
This script is supposed to tell my computer to execute a .py script which uses scipy.io and many other modules.
Then I received this error:
ModuleNotFoundError: No module named 'scipy'
My strategy was to make sure pip was up to date, then use it to install the desired packages, then run some commands to see if the packages were installed.
I ran this command to update pip:
python3 -m pip install --upgrade pip
I ran this command to get some modules:
python -m pip install --user numpy scipy matplotlib ipython jupyter pandas sympy nose
I also tried this command just in case:
pip install scipy
and got the result:
Requirement already satisfied ...
I ran the command pip list to make sure scipy was in the list (and it was there).
Then I ran the command python and my prompt changed to ">>>" and entered import scipy and did not receive any errors.
I am very confused as to how I have scipy installed yet have my script tell me it isn't there. Please help!
From what you have posted it looks like you have more than one python environment path in your system, because of which when you are installing these libraries they are installed at certain location while when you run the bash script it is using some other python location.
Try using these commands in both your terminal (cmd in windows) as well as in you bash script:
import sys
print(sys.path)
This will give you the python environment path (location where your python libraries are present), then compare both the path you get from your terminal as well as bash. Add the path you got from the terminal to your global environment in order to make sure the same python version is used everywhere.
You can also refer to this: Python modules not found over terminal but on python shell, Linux
I had the same issue. You might have multiple versions of python and you only installed scipy on the one you are not using
OR
you are using an IDE which has the option to use packages you install that are not by default in python. Pycharm has that. When you make a new project, it has a tick option saying "Inherit global site-packages" which means it will use additional packages you have installed any.
I've installed a module named rauth through terminal with pip3 install rauth command but when I import the module and run the code on Visual Studio Code with python3 interpreter, it gives ModuleNotFoundError: No module named 'rauth' error. But it is indeed installed and I can use it in Anaconda. The package file is stored here.
/Users/puffedricecracker/anaconda3/lib/python3.7/site-packages/rauth
And it seems like all my pip installed packages are stored in that path, but those are imported outside Anaconda with no problem. Tried several other commands as google search suggested.
• pip install instead of pip3 install
• python -m pip install
• python3 -m pip install
Let me know if there is any other information needed to be specified.
this is due to the module is installed into site-packages in Anaconda but not Visual Studio. Can you check if the module exists in Visual Studio folder? Another way to test it is to open Python IDLE and run the import, it should also return an error.
I don't know if this could be an universal solution but there was a way to set where to install a package using pip.
In python shell, find where your python modules usually go. It seemed like most of pip installed packages were installed in the second path so I chose that.
>>> import re
>>> print(re.__file__)
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/re.py
>>> import sqlalchemy
>>> print(sqlalchemy.__file__)
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/sqlalchemy/__init__.py
Uninstall the package using pip uninstall packagename
Reinstall with a path name.
pip install packagename -t /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages
(In fact, just copy pasting package files (in my case, they were rauth, rauth-0.7.3.dist-info) from anaconda package path in the post worked.)
I have python 2.7.10 installed on windows and I am trying to install Django on the commandline with the following command:
C:/users/user/myproject> python pip install django
This displays the following error:
python: can't open file 'pip' [Errno 2] No such file or directory
Python is installed in C:\Python27 and the PATH environment variable is also set to that.
Why is pip not working?
Since Python 2.7.9 pip is included when python is installed.
However the scripts subfolder of your python installation might not be added to your PATH environment variable, and hence inaccessible by just typing pip install. However as long as your python executable is on the path, you can use the python -m flag to execute the pip module as a script:
python -m pip install SomePackage
This should work from the command line as long as python is on PATH.
If you would like to use pip directly from the cmd.exe prompt you need to add the scripts directory to your PATH environment variable:
SET PATH=%PATH%;C:\Python27\scripts
Some times in windows it especially needs Microsoft visual c++ compiler. If such error persists you can verify the log file and If needed you can download here
http://aka.ms/vcpython27
I need help getting ghost.py to be recognised by ipython notebook which i run from c/python27/scripts
I also installed pyQt4 via a binary from chris gohlke but which also isn't being recognised by my ipython installation under windows.
i downloaded zip from github extracted to a folder inside c/python27/scripts directory and installed it via command prompt
python install setup.py
but when I import ghost and try and use it my Ipython it is not recognised.
update: pyQt4 is not being recognised even though it's installed under c/python27/lib/site-pacakges, and the path is in the variable name