ModuleNotFoundError: No module named 'hydra' - python

I'm trying to run a Python script but it gives an error immediately at the first line of code while trying importing hydra library via:
import hydra
The error i get is the following:
Traceback (most recent call last):
File "C:\Documenti\Python\01 Tool\02_Tool_Archive\calc_risk\src\main.py", line 3, in <module>
import hydra
ModuleNotFoundError: No module named 'hydra'
As the install via right click on the hydra does not work, i tried to google the error and found a possible solution via installing the hydra via pip install from the terminal - this is what i get after calling the pip install again after the first successfull installation:
PS C:\Documenti\Python\01 Tool> pip install hydra-core --upgrade
Requirement already satisfied: hydra-core in c:\users\mhlaca\appdata\local\programs\python\python310\lib\site-packages (1.2.0)
Requirement already satisfied: packaging in c:\users\mhlaca\appdata\local\programs\python\python310\lib\site-packages (from hydra-core) (21.3)
Requirement already satisfied: omegaconf~=2.2 in c:\users\mhlaca\appdata\local\programs\python\python310\lib\site-packages (from hydra-core) (2.3.0.dev0)
Requirement already satisfied: antlr4-python3-runtime==4.9.* in c:\users\mhlaca\appdata\local\programs\python\python310\lib\site-packages (from hydra-core) (4.9.3)
Requirement already satisfied: PyYAML>=5.1.0 in c:\users\mhlaca\appdata\local\programs\python\python310\lib\site-packages (from omegaconf~=2.2->hydra-core) (6.0)
Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in c:\users\mhlaca\appdata\local\programs\python\python310\lib\site-packages (from packaging->hydra-core) (3.0.9)
I'm currently stuck. What can I try next? Using Python 3.10.7 and pycharm as IDE, but also tried visual studio - same error.

Related

finnhub installation using pip

I've currently installation of python 3.10 [not conda dist]. I'm trying to import finnhub using both cmd but I'm confronted with the following error message:
C:\Users\Admin>python -m pip install finnhub
ERROR: Could not find a version that satisfies the requirement finnhub (from versions: none)
ERROR: No matching distribution found for finnhub
Any ideas on what I'm missing please? I've also tried to install this package using PyCharm but this results in the following error:
C:\Users\Admin\PycharmProjects\NewPython\venv\Scripts\python.exe C:/Users/Admin/PycharmProjects/NewPython/main.py
Traceback (most recent call last):
File "C:\Users\Admin\PycharmProjects\NewPython\main.py", line 1, in <module>
import finnhub
ModuleNotFoundError: No module named 'finnhub'
Process finished with exit code 1
I have added the python installation to PATH and the current version of pip is the latest version.
Many thanks in advance for your help.
Question update
In the meantime, I have spotted an old environment reference which has been now removed. This seems to allow the install of finnhub using
pip install finnhub--python
but not
pip install finnhub
Code below:
C:\Users\Admin>pip install finnhub
ERROR: Could not find a version that satisfies the requirement finnhub (from versions: none)
ERROR: No matching distribution found for finnhub
C:\Users\Admin>pip install finnhub--python
Requirement already satisfied: finnhub--python in c:\users\admin\appdata\local\programs\python\python310\lib\site-packages (2.4.13)
Requirement already satisfied: requests>=2.22.0 in c:\users\admin\appdata\local\programs\python\python310\lib\site-packages (from finnhub--python) (2.28.1)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\users\admin\appdata\local\programs\python\python310\lib\site-packages (from requests>=2.22.0->finnhub--python) (1.26.10)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\admin\appdata\local\programs\python\python310\lib\site-packages (from requests>=2.22.0->finnhub--python) (2022.6.15)
Requirement already satisfied: idna<4,>=2.5 in c:\users\admin\appdata\local\programs\python\python310\lib\site-packages (from requests>=2.22.0->finnhub--python) (3.3)
Requirement already satisfied: charset-normalizer<3,>=2 in c:\users\admin\appdata\local\programs\python\python310\lib\site-packages (from requests>=2.22.0->finnhub--python) (2.1.0)
C:\Users\Admin>
When using PyCharm to try to access this from the IDE, I am now confronted with:
C:\Users\Admin\PycharmProjects\pythonProject2\venv\Scripts\python.exe C:/Users/Admin/PycharmProjects/pythonProject2/main.py
Traceback (most recent call last):
File "C:\Users\Admin\PycharmProjects\pythonProject2\main.py", line 1, in <module>
import finnhub
ModuleNotFoundError: No module named 'finnhub'
Process finished with exit code 1
From the the section "Installation" of the package's documentation:
pip install finnhub-python
In this command, it becomes clear that you have installed finhub globally,
C:\Users\Admin>pip install finnhub--python
Requirement already satisfied: finnhub--python in c:\users\admin\appdata\local\programs\python\python310\lib\site-packages (2.4.13)
But when running your script your command looks like this
C:\Users\Admin\PycharmProjects\NewPython\venv\Scripts\python.exe C:/Users/Admin/PycharmProjects/NewPython/main.py
So you are using a virtual environment for your project in which finnhub is probably not installed yet.
Try:
C:\Users\Admin\PycharmProjects\NewPython\venv\Scripts\python.exe -m pip install finnhub-python
Alternatively, you can use pycharm as well
With your project open go to File
Select Settings->Project->Python Interpreter
You should see a list of packages and their version. Hit the little + button above it
Search for finnhub-python, select it and hit Install Package

Python: already install package but can't use (sklearn)

I have already installed sklearn and scikit-learn, the version of sklearn showed 0.0(use pip show instr.)
I've tried many ways to install or update packages, but when I ran the code it shows:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import sklearn
ModuleNotFoundError: No module named 'sklearn'
when I install again, it shows:
Requirement already satisfied: sklearn in c:\users\user\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages (0.0)
Requirement already satisfied: scikit-learn in c:\users\user\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages (from sklearn) (1.0.2)
Requirement already satisfied: numpy>=1.14.6 in c:\users\user\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages (from scikit-learn->sklearn) (1.22.3)
Requirement already satisfied: scipy>=1.1.0 in c:\users\user\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages (from scikit-learn->sklearn) (1.8.0)
Requirement already satisfied: threadpoolctl>=2.0.0 in c:\users\user\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages (from scikit-learn->sklearn) (3.1.0)
Requirement already satisfied: joblib>=0.11 in c:\users\user\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages (from scikit-learn->sklearn) (1.1.0)
can anyone tell me how to deal with it?
thanks!!!
You can check whether the virtual environment installed sklearn is consistent with the one used for your code.
thanks for everyone!
I found that there was the error on the environment variables, it links to old version of python that i havn't deleted, I reinstall python and set the right path, and it works!
You can check which environment you installed that package? Example, with Miniconda, and if I have more than 1 env then I will switch to the specific env, and activate it and install lib.
Then you need to check what env you setup in your development tool (ex: Visual Code).

Pandas Python Program runs on Python3, 3.8 but not 3.6

Whenever I run the command python3.6 Check.py, I get the following error,
Pandas Error
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pandas/init.py", line 30, in
from pandas._libs import hashtable as _hashtable, lib as _lib, tslib as _tslib
File "/usr/lib/python3/dist-packages/pandas/_libs/init.py", line 3, in
from .tslibs import (
File "/usr/lib/python3/dist-packages/pandas/_libs/tslibs/init.py", line 3, in
from .conversion import localize_pydatetime, normalize_date
ModuleNotFoundError: No module named 'pandas._libs.tslibs.conversion'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
​File "Check.py", line 2, in
​import pandas as pd
​File "/usr/lib/python3/dist-packages/pandas/init.py", line 38, in
​"the C extensions first.".format(module)
ImportError: C extension: No module named 'pandas._libs.tslibs.conversion' not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --inplace --force' to build the C extensions first.
I quickly google the error and find this link: No module named 'pandas._libs.tslib'
I uninstall pandas:
uninstall message
Found existing installation: pandas 1.3.3
Uninstalling pandas-1.3.3:
Would remove:
/u/riker/u97/pmohanty/.local/lib/python3.8/site-packages/pandas-1.3.3.dist-info/*
/u/riker/u97/pmohanty/.local/lib/python3.8/site-packages/pandas/*
Proceed (y/n)? y
Successfully uninstalled pandas-1.3.3
I reinstall it:
reinstall message
Requirement already satisfied: pandas in /usr/lib/python3/dist-packages (0.25.3)
I upgrade it too:
upgrade message
Collecting pandas
Using cached pandas-1.3.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.5 MB)
Requirement already satisfied, skipping upgrade: numpy>=1.17.3 in /u/riker/u97/pmohanty/.local/lib/python3.8/site-packages (from pandas) (1.21.2)
Requirement already satisfied, skipping upgrade: pytz>=2017.3 in /u/riker/u97/pmohanty/.local/lib/python3.8/site-packages (from pandas) (2021.1)
Requirement already satisfied, skipping upgrade: python-dateutil>=2.7.3 in /u/riker/u97/pmohanty/.local/lib/python3.8/site-packages (from pandas) (2.8.2)
Requirement already satisfied, skipping upgrade: six>=1.5 in /u/riker/u97/pmohanty/.local/lib/python3.8/site-packages (from python-dateutil>=2.7.3->pandas) (1.16.0)
Installing collected packages: pandas
Successfully installed pandas-1.3.3
Despite following the steps my file won't run.
Strangely it works for python3, python3.8, but not for python3.6.
python3 --version outputs 3.8.10
python3.6 --version outputs 3.6.9
pip --version outputs pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)
I am new to python and pandas and stackoverflow. Any help is appreciated.
PS: I need to get it to work in 3.6 :'(
If you really need it to work in python 3.6, you need to install it for python 3.6:
python3.6 -m pip install pandas
See e.g. this article for a discussion of why this works.

ModuleNotFoundError: No module named 'requests' - can not seem to solve in VS Code (Win 10)

I have looked at similar errors and the fixes I tried have not removed this error (yet).
Package Version
-------------- ---------
beautifulsoup4 4.9.2
certifi 2020.6.20
chardet 3.0.4
idna 2.10
lxml 4.5.2
pip 20.2.3
requests 2.24.0
setuptools 49.2.1
soupsieve 2.0.1
urllib3 1.25.10
There's my current installs which I got from the terminal in VS Code. So, from what I can see, it is all there.
When I run from inside VS Code (the play button top right) I get this error:
[local address of file], line 3, in <module>
import requests
ModuleNotFoundError: No module named 'requests'
Further information *edit
I did install requests this way from the VS Code Terminal window:
python -m pip install requests
The output states:
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: requests in c:\users\[user]\appdata\roaming\python\python38\site-packages (2.24.0)
Requirement already satisfied: idna<3,>=2.5 in c:\users\[user]\appdata\roaming\python\python38\site-packages (from requests) (2.10)
Requirement already satisfied: chardet<4,>=3.0.2 in c:\users\[user]\appdata\roaming\python\python38\site-packages (from requests) (3.0.4)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in c:\users\[user]\appdata\roaming\python\python38\site-packages (from requests) (1.25.10)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\[user]\appdata\roaming\python\python38\site-packages (from requests) (2020.6.20)
Any ideas on fixing this or a set of routine troublecheckers? Thanks kindly
You need to select the python interpreter to be the same of your current environment.
do
which python
/your_path/bin/python
That will give you the path, make sure the Python interpreter on your left button (at VSC) matches the same path, if not make it match.

Why am i unable to load wordcloud in spyder (v 3.3.4)?

Whatever I do, I just cannot use wordcloud in Anaconda - spyder
import wordcloud
Traceback (most recent call last):
File "<ipython-input-104-dc1828f2a80e>", line 1, in <module>
import wordcloud
ModuleNotFoundError: No module named 'wordcloud'
After doing some research, I realised that I need to install packages through shell program. So I installed wordcloud using pip command
C:\Users\1025990\AppData\Local\Programs\Python\Python37-32\Scripts>pip install wordcloud
Collecting wordcloud
Using cached https://files.pythonhosted.org/packages/d4/95/d260ce89441d1f28192fa5a0a016f547829517b11cabe0079ab91c56f6cd/wordcloud-1.5.0.tar.gz
Requirement already satisfied: numpy>=1.6.1 in c:\users\1025990\appdata\local\programs\python\python37-32\lib\site-packages (from wordcloud) (1.16.4)
Requirement already satisfied: pillow in c:\users\1025990\appdata\local\programs\python\python37-32\lib\site-packages (from wordcloud) (6.0.0)
Building wheels for collected packages: wordcloud
Building wheel for wordcloud (setup.py) ... done
Stored in directory: C:\Users\1025990\AppData\Local\pip\Cache\wheels\0a\24\57\899dc50402fef8c355561bcfadfe36879def229e6d97424281
Successfully built wordcloud
Installing collected packages: wordcloud
WARNING: The script wordcloud_cli.exe is installed in 'c:\users\1025990\appdata\local\programs\python\python37-32\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed wordcloud-1.5.0
I understand that the warnings have nothing to do with the installation as changing the environment variables will eliminate it. I have done that (but not posting here)
After doing that I executed the shell command again
C:\Users\1025990\AppData\Local\Programs\Python\Python37-32\Scripts>pip install wordcloud
Requirement already satisfied: wordcloud in c:\users\1025990\appdata\local\programs\python\python37-32\lib\site-packages (1.5.0)
Requirement already satisfied: numpy>=1.6.1 in c:\users\1025990\appdata\local\programs\python\python37-32\lib\site-packages (from wordcloud) (1.16.4)
Requirement already satisfied: pillow in c:\users\1025990\appdata\local\programs\python\python37-32\lib\site-packages (from wordcloud) (6.0.0)
I updated the setup tools in the shell as well
C:\Users\1025990\AppData\Local\Programs\Python\Python37-32\Scripts>pip install -U setuptools
Requirement already up-to-date: setuptools in c:\users\1025990\appdata\local\programs\python\python37-32\lib\site-packages (41.0.1)
Now I check whether I can use wordcloud in spyder, so I run the command again
from wordcloud import WordCloud
Traceback (most recent call last):
File "<ipython-input-105-021e0a03a31f>", line 1, in <module>
from wordcloud import WordCloud
ModuleNotFoundError: No module named 'wordcloud'
I don't understand what I am missing. Please help!
is it possible that you have multiple python instances and installed it to another one than you are actually using? That's a common cause for this kind of problem.
get your actual version in your python console via import sys print(sys.executable) and check the site-package folder of this path for your module.

Categories

Resources