On Windows 10, I've installed Python 3.7.3. I wanted to add the plot module via pip install matplotlib and it seemed to work OK (giving success result), but when trying to import the library with import matplotlib.pyplot as plt it fails saying the specified module could not be found.
I've tried py -m pip install... and also python -m pip install... none seemed to fix the issue I had.
Here's how I tried to install the module :
c:\Users\Michael\Documents>pip install matplotlib
Collecting matplotlib
Using cached https://files.pythonhosted.org/packages/76/e2/f87bf36a2a460857ec9c28535e00102eb6908a727e427adc6427c5dc5453/matplotlib-3.1.0-cp37-cp37m-win32.whl
Collecting pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 (from matplotlib)
Using cached https://files.pythonhosted.org/packages/dd/d9/3ec19e966301a6e25769976999bd7bbe552016f0d32b577dc9d63d2e0c49/pyparsing-2.4.0-py2.py3-none-any.whl
Collecting python-dateutil>=2.1 (from matplotlib)
Using cached https://files.pythonhosted.org/packages/41/17/c62faccbfbd163c7f57f3844689e3a78bae1f403648a6afb1d0866d87fbb/python_dateutil-2.8.0-py2.py3-none-any.whl
Collecting kiwisolver>=1.0.1 (from matplotlib)
Using cached https://files.pythonhosted.org/packages/20/6a/e5fff2ed776ab0cd11d7c1d5d3e5e549952464a6f1b9084b7ecbd8341352/kiwisolver-1.1.0-cp37-none-win32.whl
Requirement already satisfied: numpy>=1.11 in c:\program files (x86)\python37-32\lib\site-packages (from matplotlib) (1.16.3)
Collecting cycler>=0.10 (from matplotlib)
Using cached https://files.pythonhosted.org/packages/f7/d2/e07d3ebb2bd7af696440ce7e754c59dd546ffe1bbe732c8ab68b9c834e61/cycler-0.10.0-py2.py3-none-any.whl
Collecting six>=1.5 (from python-dateutil>=2.1->matplotlib)
Using cached https://files.pythonhosted.org/packages/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl
Requirement already satisfied: setuptools in c:\program files (x86)\python37-32\lib\site-packages (from kiwisolver>=1.0.1->matplotlib) (40.8.0)
Installing collected packages: pyparsing, six, python-dateutil, kiwisolver, cycler, matplotlib
Successfully installed cycler-0.10.0 kiwisolver-1.1.0 matplotlib-3.1.0 pyparsing-2.4.0 python-dateutil-2.8.0 six-1.12.0
You are using pip version 19.0.3, however version 19.1.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
Here the path on my computer which includes the python:
c:\Users\Michael\Documents>path
PATH=C:\Program Files (x86)\Python37-32\Scripts\;C:\Program Files (x86)\Python37-32\;....
Here's the error I'm getting (either from idle or from CMD after starting python):
>>> import matplotlib.pyplot as plt
Traceback (most recent call last):
File "<pyshell#61>", line 1, in <module>
import matplotlib.pyplot as plt
File "C:\Program Files (x86)\Python37-32\lib\site-packages\matplotlib\__init__.py", line 200, in <module>
_check_versions()
File "C:\Program Files (x86)\Python37-32\lib\site-packages\matplotlib\__init__.py", line 194, in _check_versions
module = importlib.import_module(modname)
File "C:\Program Files (x86)\Python37-32\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: DLL load failed: The specified module could not be found.
Looks like this package depends on some C++ libraries which I was missing on my (new) computer, because it worked fine and problem has been resolved after I installed visual C++ 2015 from https://www.microsoft.com/en-in/download/details.aspx?id=48145
Thanks to the post on
DLL load failed: The specified module could not be found. in matplotlib program
Related
import nltk
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/code.py", line 90, in runcode
exec(code, self.locals)
File "<input>", line 1, in <module>
File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
ModuleNotFoundError: No module named 'nltk'
This is the error that I get from running PyCharm 2021.3.2 (Community Edition).
However, when I go to my terminal and try
pip3 install nltk
I see that
Requirement already satisfied: nltk in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (3.7)
Requirement already satisfied: click in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from nltk) (8.1.3)
Requirement already satisfied: regex>=2021.8.3 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from nltk) (2022.9.13)
Requirement already satisfied: joblib in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from nltk) (1.2.0)
Requirement already satisfied: tqdm in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from nltk) (4.64.1)
So it seems that I've already installed nltk? But why is PyCharm still giving me that error? I'm using macOS Monterey 12.6 if that helps with anything.
Some things to try:
On your terminal, check which on which python environment you're using your script. It's a common source of headaches that using python 2.7 and python 3.x would not work for packages only installed with either pip or pip3. On the terminal do
python --version
and (if available)
python3 --version
And check if you can make it work after installing the same package with pip (as opposed to pip3).
using conda as a package manager can lead to millions of conflicts across your system. Are you by any chance using conda/anaconda? If so, you should try intalling the package with conda instead of pip.
check that whatever python you're using, it can reach the location of wherever you installled PyCharm.
Check if your package was installed locally as opposed as globally. For the former, do pip list on your terminal. For the latter, do pip list --user instead.
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.
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
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.
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.