Exception has occurred: ModuleNotFoundError even after pip install - python

I would like to use html2text in my python script, I've installed it via pip install html2text, and it is now in the %Roaming%\Python\Python310\Scripts.
I can also see it while checking what plugins I have installed and in the visual studio code it's green. However when I run the code this message appears:
This is how it looks in VS Studio Code

So I've found out the solution. It seemed to me like a bug and it was. I had somehow installed some extension from the Windows store - uninstall it, and you should be fine.

In the bottom right of the status bar in VS Code, it will show you which Python environment you're using. You'll need to make sure that you've selected the correct Python installation in VS Code by clicking the Python version in the status bar (make sure it matches with the Python version when you type python into the terminal). If that doesn't work, your Pip could be pointing to the wrong version (run pip -V to find out where it's pointing).

Related

Why doesn't import gym work; however, the command pip install gym was done and executed

I have went to the terminal and used,"pip install gym", and it successfully installed gym . When I go to use the, "import gym," command, I get an error when running the code at that line.
Exception has occurred: ModuleNotFoundError
No module named 'gym'
I have looked at other posts and they all say it should work after ruining,"pip install gym." Although mine successfully installed, it still doesn't work.
You need to verify that you are using the same version of python that you did pip install with. In VS Code, you can select the Python version in the upper right corner. Simply type "python --version" into the console to verify the version. You might want to use Anaconda because someone libraries like Tensorflow only fully-support Anaconda.
if you have pip installed it, there is no way that it will not work. Unless you've installed it to a virtual environment and running your program without it and vice versa. Or you've installed to a different version of python on your system.

visual studios cant find package i installed through pip

Visual Studio says I'm running Python 0.0 AND 3.10
Visual Studio is unable to find a package. I am able to run it in cmd using python.
I have had this problem before, but can't remember how I fixed it. I think I'm using the wrong version of python, but if that is the problem I don't know how to fix it.
Edit: using py -3.10 -m pip install package, instead of just pip install package seems to have worked.
Check the version in cmd and then if it is something above 3.7 or so you are good to go else reinstall python and if you are on Windows then check the box at bottom of the installation window of python which says "Add pip to path" something like that
Now in the VS Code
Hit Ctrl+Shift+p to open command palette and in that search for python interpreter and change it to plain one or you may choose
Select Python Interpreter
use the vscode console
First of all to check the packages insatalled in python you have to use the pip freeze.
pip freeze
This will help you to find out if the required package which you've installed is on the list or not.
If it is not present use the same console for:-
pip install <packageName>
for eg.
pip install django
then check the list agian

No module named 'odf' due to wrong Python version

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.

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.

pycharm interpreter using cygwin version python

I am running django python2.7 using Pycharm in windows.
Now I have some issue with redis queue not working in windows because of this
I am trying to do what this person did here. Use a cygwin version of python as pycharm interpreter.
(not sure if I downloaded all the packages or did correct steps)
I downloaded cygwin and install packages python2.7 + python-setuptools and then try to point my Pycharm interpreter to c:/cygwin/bin/python27.exe
see image
After that it seem ok and ask me to install packing tools pip, I clicked it and it give me this error:
see image
"Cannot start process, the working directory '\cygdrive\c\Users\User1G~1.SIS\AppData\Local\Temp\1\tmpYpudf2pycharm-management\pip-7.1.0' does not exist"
According to the error message it looks like pip can't be found... Are you sure you have installed pip?
Take a look here, how you can install pip: Installing Pip-3.2 on Cygwin
You can open a cygwin command line window and try to manually install the packages you want to.

Categories

Resources