No module named 'odf' due to wrong Python version - python

I have many different versions of Python, but a version that I use and that terminal show me if use command Python – version is 3.10.0.
When I use command pip list I got a big list of library, including the one I recently installed odfpy.
I open VsCode, choose Python version 3.10.0 and try to import odf but...
ModuleNotFoundError: No module named 'odf'
For sure I need to set something on VsCode or change some configuration in Linux but I cannot find a normal explanation of how to solve this issue.
If I change the Python version in VsCode with 3.8.10, odfpy (and also Django just installed) is recognized. So I suppose that, even if the Python version selected on the terminal is 3.10.0, when I pip install something, is installed on version 3.8.10. How do you manage this?

Please check which pip you are using through the command of pip --version.
After you switch the python interpreter in the VSCode, please create a new terminal, and make sure it has activated the environment you have selected.

I also use VS code and use Python 3.10 and i had try to download the odfpy which has gone alright, i use the command python -m pip install odfpy
try and see if it work for you though.
If it does not work, maybe try and create a virtual environment if you haven't created it yet.

In my case i was getting same error while using import-export django module. Installing odf library didn't worked got same error. I resolve this issue by simply pip install tablib==0.14.0.

Related

Unable to import numpy/pandas/matplotlib packages in VScode

I have used widely used packages(installed via pip) for a while in Jupyter notebook without any issues. I tried to do Python coding in VScode,but it somehow cannot load those packages.
I have tried changing python interpreter, but it did solve the issue. Does anyone know how to resolve this issue?
First make sure that you have the python interpreter installed on your computer. In your vscode UI you should see a terminal. You can install and upgrade pip through there if needed by using these commands:
pip install --upgrade pip
From here you should be able to import using pip commands.
Hi you can use terminal for installation.
otherwise you can anaconda iDE its very good tool and user friendly.

My VS Code dont recognize the pip packages

Despite im used to program stuff, im new in Python so i decide to learn by myself.
So, i install VS code and python. At the moment i tryied to use stuff like tensorflow, is showing an error saying that my imports are missing.
I've already tryed to install everything again, search for a solution online and nothing worked.
If someone knows anything about how to fix this i'd be greatfull.
Whether there are multiple versions of python in your environment, which will make the pip installed in one version of python instead of the python you are using.
Use shortcuts "Ctrl+shift+P" and type "Python: Select Interpreter" to choose the correct python. Then use pip install packagename to reinstall the package which you need.
Generally, we recommend people new to python to use the conda virtual environment.
Confirm you have downloaded python correctly:
Open terminal
Run python --version
(if that doesn't work try python3 --version

How can I download SciPy on Python (PyCharm app)? [duplicate]

I am using python 3.6.5 with PyCharm.
While trying to install any package, it gives the error
"Try to run this command from the system terminal. Make sure that you use the correct version of 'pip' installed for your Python interpreter located at 'C:\projectPath\venv\Scripts\python.exe'"
Project path and actual python installed paths are different.
In settings of PyCharm, pip version is 19.0.3 and latest version is 19.3.1
Also, "python -m pip --version" from command prompt says pip version is 9.0.3
What do I do?
I imagine that you have more than one Python installed in your system.
you should go to Pycharm --> file> settings> project>project interpreter.
you should find the other Python instance on your system and try to change your interpreter to that one.
if it does not appear in the list click on the button that looks like star in front of the project interpreter.
I had the same problem.
I realized that I installed one python by myself and another is installed while installing PyCharm.
After changing my interpreter I do not receive that error anymore.
This error occurred to me too when using PyCharm, and trying to install MeCab in it. And by choosing mecab-python3 instead of just mecab (which is what is for Python2 I assume...).
You might install the package compatible to the Python version used in the package, but not to yours, which is that PyCharm refers to'dir:\projectPath\venv\Scripts\python.exe' . So you should choose the different version of the package, or change interpreter to another.
I got the same error along with no such option: --build-dir after upgrading pip from PyCharm's (2020.1 #PY-201.6668.115) terminal (PyCharm didn't allow me to do so from interpreter's settings).
Turned out older versions of PyCharm rely on --build-dir which was removed in newer versions of pip. To resolve the issue I had to downgrade pip.
Solution was found here
Faced same issue after trying to change the file path.
Tried changing the interpreter location but it dint work for me. so I uninstalled pycharm and re-installed it. working fine now.
I faced the same problem on Windows-10 (PyCharm 2020.1.2 version) when installing h5py package. I didn't want to change my interpreter as that will raise other compatibility errors in my code.
In my case:
What didn't work: upgrading the pip
What worked: I chose old h5py version-2.10 (instead of the latest h5py version selected by default by PyCharm) and it worked.
Mentioning just in case if this works for someone. Uninstalling both Python and Pycharm is too much to do for this error (in my opinion).
File-> settings
searching for project -> and choosing "python interpreter"
in "python interpreter" tab choosing "show all"
pressing in the left down side on "+" (add)
adding the right direction of python installed place and press "ok"
removing the previous version
I faced the same error while using Python 3.7.5 and Pycharm 2019.1.2 for my Django project.
It also causes failure in execution of many other python commands, and is not caused by environment variables or path.
I guess it's because some python files are broken or corrupted.
The easiest and fastest way I found to get out of this was :-
Uninstall Python.
Uninstall Pycharm.
And Reinstall latest versions of both.
I had the same problem and but see solution uninstall IDLE python and pycharm and install least version
Uninstall Python.
Uninstall Pycharm.
And Reinstall latest versions of both.

Installing and using npTDMS with Spyder - anaconda3

I have successfully installed npTDMS as seen here:
https://pypi.org/project/npTDMS/
If I try to install with command line using either pip or conda I get a message confirming it is already installed, and I see the package at D:\Users\username\anaconda3\pkgs.
On Spyder I have tried using the PYTHON path manager (in the tools menu) to add both:
D:\Users\username\anaconda3\pkgs\nptdms-1.2.0-pyhd8ed1ab_0
D:\Users\username\anaconda3\pkgs\nptdms-1.2.0-pyhd8ed1ab_0\site-packages\nptdms
As far as I understand this should be enough to use the npTDMS package, however when I try to import I get a ModuleNotFoundError: No module named 'nptdms'.
I'm fairly new to python overall so maybe there is a simple thing I am missing.
This issue comes when there are multiple versions of python or any package you are running at current time. The same issue was with me too when the IDLE was not able to detect the position of where the package is installed.
My suggestion is that uninstall all the versions of python and the module you are using and install them again. Otherwise shift to any other IDLE, in my recommendation - Visual Studio Code.

problem installing and importing modules in python

I am installing python on windows10 and trying to install the opencv and numpy extentions in the command window. I get no error installing them and it says it is successfully installed. But when I try to check the installation and import cv2 it does not recognize it and give me the error: no module named cv2.
can anybody help me with this problem? Is there something wrong in installation process or do I need to install something else?
I checked the newest version of each and used the compatible one with my system.
Thanks.
One solution could be that you have 2 versions of python. So, go to the specific python's scripts directory and run: pip install numpy
If that too doesn't work, you can find the answers to this question on Why can't I import opencv3 even though the package is installed?, as stated by #Cut7er.
I have tried the solutions given to the above stated question myself also. But, they didn't work for me. So, another thing that you could try to use is this IDE called PyCharm. It ofcourse is much more beautiful that the IDLE, but it also has an inbuilt GUI controlled installation of binaries or packages. That would make things a lot easier. I have faced a lot of issues with packages for python and this IDE made things a lot easier. You can find it on https://www.jetbrains.com/pycharm/download/#section=windows.
You can also use anaconda. But, I found it a little difficult to use since, it has similar issues.
EDIT:
Seems like you are using PyCharm. But, you are installing libraries from your command prompt. So, see the answer to: ImportError: No module named 'bottle' - PyCharm. This answer guides you through how to install a certain library through your PyCharm window itself. So,
1) Go to Files>Settings
2) Search for "Interpreter" from the searching tab. Open the interpreter
3) You can now see a plus sign on the right. A click on it will open up a section on the left.
4) In the searching tab, search for numpy or opencv. Click on whichever module you want to install. And then click on the "install package" button on the bottom left. This will install the package for you.
5) Then click save. And run your file that says import cv/cv2.
This should probably do the trick.
Hope it helps!
Is it possible that you have 2 versions of python on your machine and your native pip is pointing to the other one? (e.g. you pip install opencv which installs opencv for python 2, but you are using python 3). If this is so, then use pip3 install opencv
I removed the Anaconda version on my machine, so I just have python 3.7 installed. I removed the python interpreter(Pycharm) and installed it again and the problem got fixed somehow!
I suspect you have two versions of python and the one you're using doesn't have opencv on it, because pip pointed to the wrong one.
A pragmatic solution assuming you're using the python version with conda is to just use conda to install cv2:
conda install -c menpo opencv
A more careful solution is to figure out how to get the pip that points to the python version you're using. On linux I can check that my pip points to my python like this:
:~$ which python
/home/kpierce/anaconda3/bin/python
:~$ which pip
/home/kpierce/anaconda3/bin/pip
So you see the pip and python versions are associated. On windows I suspect you do an analogous thing on the command line like
where python
where pip
And if they don't match, you might try
where python
where pip3
to see if those match. You need to use the pip that points to the correct python version. You can view the python version by entering the python interpreter and running
import sys
sys.version

Categories

Resources