i'm having this error problem, i have ran this script in jupyter notebook in base (root) environment, the log said that gensim library has been installed and i have run the command !pip install gensim before i import it, but it still can not be imported, and the error said ModuleNotFoundError: No module named 'gensim'
!pip install gensim
import gensim
from gensim.models import KeyedVectors
model = KeyedVectors.load('model_fasttext2.vec')
model.vector_size
------------------------------------------------------------------------
Requirement already satisfied: gensim in c:\users\ip-03\anaconda3\lib\site-packages (3.8.1)
Requirement already satisfied: scipy>=0.18.1 in c:\users\ip-03\anaconda3\lib\site-packages (from gensim) (1.4.1)
Requirement already satisfied: six>=1.5.0 in c:\users\ip-03\anaconda3\lib\site-packages (from gensim) (1.14.0)
Requirement already satisfied: smart-open>=1.8.1 in c:\users\ip-03\anaconda3\lib\site-packages (from gensim) (1.9.0)
Requirement already satisfied: numpy>=1.11.3 in c:\users\ip-03\anaconda3\lib\site-packages (from gensim) (1.18.1)
Requirement already satisfied: boto>=2.32 in c:\users\ip-03\anaconda3\lib\site-packages (from smart-open>=1.8.1->gensim) (2.49.0)
Requirement already satisfied: boto3 in c:\users\ip-03\anaconda3\lib\site-packages (from smart-open>=1.8.1->gensim) (1.12.3)
Requirement already satisfied: bz2file in c:\users\ip-03\anaconda3\lib\site-packages (from smart-open>=1.8.1->gensim) (0.98)
Requirement already satisfied: requests in c:\users\ip-03\anaconda3\lib\site-packages (from smart-open>=1.8.1->gensim) (2.22.0)
Requirement already satisfied: s3transfer<0.4.0,>=0.3.0 in c:\users\ip-03\anaconda3\lib\site-packages (from boto3->smart-open>=1.8.1->gensim) (0.3.3)
Requirement already satisfied: botocore<1.16.0,>=1.15.3 in c:\users\ip-03\anaconda3\lib\site-packages (from boto3->smart-open>=1.8.1->gensim) (1.15.3)
Requirement already satisfied: jmespath<1.0.0,>=0.7.1 in c:\users\ip-03\anaconda3\lib\site-packages (from boto3->smart-open>=1.8.1->gensim) (0.9.4)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\ip-03\anaconda3\lib\site-packages (from requests->smart-open>=1.8.1->gensim) (2019.11.28)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in c:\users\ip-03\anaconda3\lib\site-packages (from requests->smart-open>=1.8.1->gensim) (3.0.4)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in c:\users\ip-03\anaconda3\lib\site-packages (from requests->smart-open>=1.8.1->gensim) (1.25.8)
Requirement already satisfied: idna<2.9,>=2.5 in c:\users\ip-03\anaconda3\lib\site-packages (from requests->smart-open>=1.8.1->gensim) (2.8)
Requirement already satisfied: python-dateutil<3.0.0,>=2.1 in c:\users\ip-03\anaconda3\lib\site-packages (from botocore<1.16.0,>=1.15.3->boto3->smart-open>=1.8.1->gensim) (2.8.1)
Requirement already satisfied: docutils<0.16,>=0.10 in c:\users\ip-03\anaconda3\lib\site-packages (from botocore<1.16.0,>=1.15.3->boto3->smart-open>=1.8.1->gensim) (0.15.2)
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-10-ee4a48d372cd> in <module>
1 get_ipython().system('pip install gensim')
----> 2 import gensim
3 from gensim.models import KeyedVectors
4 model = KeyedVectors.load('model_fasttext2.vec')
5 model.vector_size
ModuleNotFoundError: No module named 'gensim'
Is there anyone who can help this problem? i will really appreciate your help, it will help my thesis work, thank you for your attention
It may be that your jupyter lab maybe running the base kernel and not the kernel of the virtual environment.
Check by doing the following:
import sys
sys.executable
into my notebook and got the result
'/anaconda3/bin/python'
If you get the above instead of the below then that means you're using the wrong kernel.
'/anaconda3/envs/myenv/bin/python'
You can solve it by creating a new iPython kernel for your new environment. Read more here.
conda install -n myenv ipython
conda activate myenv
python -m ipykernel install --user --name myenv --display-name "Python (myenv)"
```Then, to run Jupyter Lab in the new environment:
Related
I'm using mysql with flask for developing a basic website and I'm getting ModuleNotFound error even if I have the module installed. Can someone solve this ?
File "c:/Users/prshi/Desktop/Py files/FLASK app/app.py", line 3, in <module>
from flask_mysqldb import MySQL
ModuleNotFoundError: No module named 'flask_mysqldb'
PS C:\Users\prshi\Desktop\Py files\FLASK app> pip install flask-mysqldb
Requirement already satisfied: flask-mysqldb in c:\python39\lib\site-packages (0.2.0)
Requirement already satisfied: Flask>=0.10 in c:\python39\lib\site-packages (from flask-mysqldb) (1.1.2)
Requirement already satisfied: mysqlclient in c:\python39\lib\site-packages (from flask-mysqldb) (1.4.6)
Requirement already satisfied: Werkzeug>=0.15 in c:\python39\lib\site-packages (from Flask>=0.10->flask-mysqldb) (1.0.1)
Requirement already satisfied: Jinja2>=2.10.1 in c:\python39\lib\site-packages (from Flask>=0.10->flask-mysqldb) (2.11.2)
Requirement already satisfied: itsdangerous>=0.24 in c:\python39\lib\site-packages (from Flask>=0.10->flask-mysqldb) (1.1.0)
Requirement already satisfied: click>=5.1 in c:\python39\lib\site-packages (from Flask>=0.10->flask-mysqldb) (7.1.2)
Requirement already satisfied: MarkupSafe>=0.23 in c:\python39\lib\site-packages (from Jinja2>=2.10.1->Flask>=0.10->flask-mysqldb) (1.1.1)
PS C:\Users\prshi\Desktop\Py files\FLASK app>
This a common python path issue, to make sure it isn't your case, type :
import sys
print(sys.path)
and check if it contains:
/usr/local/lib64/python3.6/site-packages
The problem is that you install the package using pip somewhere, and you're trying to import it from somewhere else where it's not installed. The trick to solve it is by running this command :
export PYTHONPATH=$PYTHONPATH:/path/to/your/modules
I am using python 3.6.0, when importing the sklearn, it shows No module named 'sklearn'.
But I have installed the package in the interpreter, what can I do?
Thanks!
(env) (base) MacBook:$ pip3 install sklearn
Requirement already satisfied: sklearn in ./env/lib/python3.6/site-packages (0.0)
Requirement already satisfied: scikit-learn in ./env/lib/python3.6/site-packages (from sklearn) (0.23.2)
Requirement already satisfied: threadpoolctl>=2.0.0 in ./env/lib/python3.6/site-packages (from scikit-learn->sklearn) (2.1.0)
Requirement already satisfied: numpy>=1.13.3 in ./env/lib/python3.6/site-packages (from scikit-learn->sklearn) (1.19.1)
Requirement already satisfied: joblib>=0.11 in ./env/lib/python3.6/site-packages (from scikit-learn->sklearn) (0.16.0)
Requirement already satisfied: scipy>=0.19.1 in ./env/lib/python3.6/site-packages (from scikit-learn->sklearn) (1.5.2)
I get this error when I try to call a geospark module
from geospark.register import GeoSparkRegistrator
ModuleNotFoundError: No module named 'geospark'
However if I do
pip install geospark
I get
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: geospark in /usr/local/lib/python3.6/dist-packages (1.3.0)
Requirement already satisfied: pyspark in /usr/local/lib/python3.6/dist-packages (from geospark) (2.4.5)
Requirement already satisfied: shapely in /usr/local/lib/python3.6/dist-packages (from geospark) (1.7.0)
Requirement already satisfied: findspark in /usr/local/lib/python3.6/dist-packages (from geospark) (1.3.0)
Requirement already satisfied: attrs in /usr/local/lib/python3.6/dist-packages (from geospark) (19.3.0)
Requirement already satisfied: py4j==0.10.7 in /usr/local/lib/python3.6/dist-packages (from pyspark->geospark) (0.10.7)
I'm still trying to master the science of installing packages via pip. When I run pip to install geocoder, I get the following:
(base) C:\Users\MBSanders>python -m pip install geocoder
Requirement already satisfied: geocoder in c:\programdata\anaconda3\lib\site-packages (1.38.1)
Requirement already satisfied: requests in c:\programdata\anaconda3\lib\site-packages (from geocoder) (2.21.0)
Requirement already satisfied: future in c:\programdata\anaconda3\lib\site-packages (from geocoder) (0.17.1)
Requirement already satisfied: click in c:\programdata\anaconda3\lib\site-packages (from geocoder) (7.0)
Requirement already satisfied: six in c:\programdata\anaconda3\lib\site-packages (from geocoder) (1.12.0)
Requirement already satisfied: ratelim in c:\programdata\anaconda3\lib\site-packages (from geocoder) (0.1.6)
Requirement already satisfied: certifi>=2017.4.17 in c:\programdata\anaconda3\lib\site-packages (from requests->geocoder) (2019.3.9)
Requirement already satisfied: idna<2.9,>=2.5 in c:\programdata\anaconda3\lib\site-packages (from requests->geocoder) (2.8)
Requirement already satisfied: urllib3<1.25,>=1.21.1 in c:\programdata\anaconda3\lib\site-packages (from requests->geocoder) (1.24.1)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in c:\programdata\anaconda3\lib\site-packages (from requests->geocoder) (3.0.4)
Requirement already satisfied: decorator in c:\programdata\anaconda3\lib\site-packages (from ratelim->geocoder) (4.4.0)
When I run
os.getcwd()
in spyder/python, I get
'C:\\Users\\MBSanders'
My question is, why do I get
ModuleNotFoundError: No module named 'geocoder'
When I run
import geocoder
I'm somewhat new to python. Please let me know if additional info is needed to trouble shoot. I'm within a federal agency so I do not have admin rights.
When I run sys.path in the console, I get
sys.path
Out[12]:
['F:\\Users\\MBSanders',
'C:\\Users\\MBSanders\\AppData\\Local\\Continuum\\anaconda3\\python37.zip',
'C:\\Users\\MBSanders\\AppData\\Local\\Continuum\\anaconda3\\DLLs',
'C:\\Users\\MBSanders\\AppData\\Local\\Continuum\\anaconda3\\lib',
'C:\\Users\\MBSanders\\AppData\\Local\\Continuum\\anaconda3',
'',
'C:\\Users\\MBSanders\\AppData\\Roaming\\Python\\Python37\\site-packages',
'C:\\Users\\MBSanders\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages',
'C:\\Users\\MBSanders\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\win32',
'C:\\Users\\MBSanders\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\win32\\lib',
'C:\\Users\\MBSanders\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\Pythonwin',
'C:\\Users\\MBSanders\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\IPython\\extensions',
'F:\\Users\\MBSanders\\.ipython']
Assuming you're running python on the terminal, and python is the command you're using to run it, try doing python -m pip install geocoder. That'll install it for the python build you want to use. Or if you know the full path to the python build you're using, you can do something similar like /path/to/python -m pip install geocoder.
if you are using python 3.7 or 3.8 you may need to pip3.7 or pip3.8 install if you OS is recognizing a 2.x version as default
I have an environment of Anaconda (apart of root) and I'm trying to install this two libraries with no success. I tried:
Install libraries by the environment tools of Anaconda Navigator with
'Multiple Errors Encountered.' error. Could I get more info about it? The options that I saw didn't say anything more.
'Multiple Errors Encountered.'
Install Jupyter with the install option of the apps of Anaconda Navigator with the same error too
'Multiple Errors Encountered.'
Install with conda install jupyter and conda install matplotlib in the console and cd where the environment is located. The console
made its process and it said that both libraries were already
installed. I check it in the libraries list of Anaconda Navigator and
it doesn't appear.
(base) C:\Users...>cd C:\Users\Alvaro\Anaconda3\envs\tensorflow
(base) C:\Users...\Anaconda3\envs\tensorflow>conda install
matplotlib Solving environment: done
All requested packages already installed.
(base) C:\Users\Alvaro\Anaconda3\envs\tensorflow>conda install jupyter
Solving environment: done
All requested packages already installed.
Install with pip install jupyter and pip install matplotlib with the similar result than conda install option.
(base) C:\Users\Alvaro\Anaconda3\envs\tensorflow>pip install jupyter Requirement already satisfied: jupyter in
c:\users\alvaro\anaconda3\lib\site-packages (1.0.0) Requirement
already satisfied: notebook in
c:\users\alvaro\anaconda3\lib\site-packages (from jupyter) (5.5.0)
Requirement already satisfied: qtconsole in
c:\users\alvaro\anaconda3\lib\site-packages (from jupyter) (4.3.1)
Requirement already satisfied: jupyter-console in
c:\users\alvaro\anaconda3\lib\site-packages (from jupyter) (5.2.0)
Requirement already satisfied: nbconvert in
c:\users\alvaro\anaconda3\lib\site-packages (from jupyter) (5.3.1)
Requirement already satisfied: ipykernel in
c:\users\alvaro\anaconda3\lib\site-packages (from jupyter) (4.8.2)
Requirement already satisfied: ipywidgets in
c:\users\alvaro\anaconda3\lib\site-packages (from jupyter) (7.2.1)
Requirement already satisfied: jupyter-client>=5.2.0 in
c:\users\alvaro\anaconda3\lib\site-packages (from notebook->jupyter)
(5.2.3) Requirement already satisfied: nbformat in
c:\users\alvaro\anaconda3\lib\site-packages (from notebook->jupyter)
(4.4.0) Requirement already satisfied: ipython-genutils in
c:\users\alvaro\anaconda3\lib\site-packages (from notebook->jupyter)
(0.2.0) Requirement already satisfied: Send2Trash in
c:\users\alvaro\anaconda3\lib\site-packages (from notebook->jupyter)
(1.5.0) Requirement already satisfied: traitlets>=4.2.1 in
c:\users\alvaro\anaconda3\lib\site-packages (from notebook->jupyter)
(4.3.2) Requirement already satisfied: terminado>=0.8.1 in
c:\users\alvaro\anaconda3\lib\site-packages (from notebook->jupyter)
(0.8.1) Requirement already satisfied: jinja2 in
c:\users\alvaro\anaconda3\lib\site-packages (from notebook->jupyter)
(2.10) Requirement already satisfied: jupyter-core>=4.4.0 in
c:\users\alvaro\anaconda3\lib\site-packages (from notebook->jupyter)
(4.4.0) Requirement already satisfied: tornado>=4 in
c:\users\alvaro\anaconda3\lib\site-packages (from notebook->jupyter)
(5.0.2) Requirement already satisfied: pyzmq>=17 in
c:\users\alvaro\anaconda3\lib\site-packages (from notebook->jupyter)
(17.0.0) Requirement already satisfied: ipython in
c:\users\alvaro\anaconda3\lib\site-packages (from
jupyter-console->jupyter) (6.4.0) Requirement already satisfied:
prompt_toolkit<2.0.0,>=1.0.0 in
c:\users\alvaro\anaconda3\lib\site-packages (from
jupyter-console->jupyter) (1.0.15) Requirement already satisfied:
pygments in c:\users\alvaro\anaconda3\lib\site-packages (from
jupyter-console->jupyter) (2.2.0) Requirement already satisfied:
mistune>=0.7.4 in c:\users\alvaro\anaconda3\lib\site-packages (from
nbconvert->jupyter) (0.8.3) Requirement already satisfied:
entrypoints>=0.2.2 in c:\users\alvaro\anaconda3\lib\site-packages
(from nbconvert->jupyter) (0.2.3) Requirement already satisfied:
bleach in c:\users\alvaro\anaconda3\lib\site-packages (from
nbconvert->jupyter) (2.1.3) Requirement already satisfied:
pandocfilters>=1.4.1 in c:\users\alvaro\anaconda3\lib\site-packages
(from nbconvert->jupyter) (1.4.2) Requirement already satisfied:
testpath in c:\users\alvaro\anaconda3\lib\site-packages (from
nbconvert->jupyter) (0.3.1) Requirement already satisfied:
widgetsnbextension~=3.2.0 in
c:\users\alvaro\anaconda3\lib\site-packages (from ipywidgets->jupyter)
(3.2.1) Requirement already satisfied: python-dateutil>=2.1 in
c:\users\alvaro\anaconda3\lib\site-packages (from
jupyter-client>=5.2.0->notebook->jupyter) (2.7.3) Requirement already
satisfied: jsonschema!=2.5.0,>=2.4 in
c:\users\alvaro\anaconda3\lib\site-packages (from
nbformat->notebook->jupyter) (2.6.0) Requirement already satisfied:
six in c:\users\alvaro\anaconda3\lib\site-packages (from
traitlets>=4.2.1->notebook->jupyter) (1.11.0) Requirement already
satisfied: decorator in c:\users\alvaro\anaconda3\lib\site-packages
(from traitlets>=4.2.1->notebook->jupyter) (4.3.0) Requirement already
satisfied: MarkupSafe>=0.23 in
c:\users\alvaro\anaconda3\lib\site-packages (from
jinja2->notebook->jupyter) (1.0) Requirement already satisfied:
setuptools>=18.5 in c:\users\alvaro\anaconda3\lib\site-packages (from
ipython->jupyter-console->jupyter) (39.1.0) Requirement already
satisfied: simplegeneric>0.8 in
c:\users\alvaro\anaconda3\lib\site-packages (from
ipython->jupyter-console->jupyter) (0.8.1) Requirement already
satisfied: backcall in c:\users\alvaro\anaconda3\lib\site-packages
(from ipython->jupyter-console->jupyter) (0.1.0) Requirement already
satisfied: pickleshare in c:\users\alvaro\anaconda3\lib\site-packages
(from ipython->jupyter-console->jupyter) (0.7.4) Requirement already
satisfied: colorama; sys_platform == "win32" in
c:\users\alvaro\anaconda3\lib\site-packages (from
ipython->jupyter-console->jupyter) (0.3.9) Requirement already
satisfied: jedi>=0.10 in c:\users\alvaro\anaconda3\lib\site-packages
(from ipython->jupyter-console->jupyter) (0.12.0) Requirement already
satisfied: wcwidth in c:\users\alvaro\anaconda3\lib\site-packages
(from prompt_toolkit<2.0.0,>=1.0.0->jupyter-console->jupyter) (0.1.7)
Requirement already satisfied:
html5lib!=1.0b1,!=1.0b2,!=1.0b3,!=1.0b4,!=1.0b5,!=1.0b6,!=1.0b7,!=1.0b8,>=0.99999999pre in c:\users\alvaro\anaconda3\lib\site-packages (from
bleach->nbconvert->jupyter) (1.0.1) Requirement already satisfied:
parso>=0.2.0 in c:\users\alvaro\anaconda3\lib\site-packages (from
jedi>=0.10->ipython->jupyter-console->jupyter) (0.2.0) Requirement
already satisfied: webencodings in
c:\users\alvaro\anaconda3\lib\site-packages (from
html5lib!=1.0b1,!=1.0b2,!=1.0b3,!=1.0b4,!=1.0b5,!=1.0b6,!=1.0b7,!=1.0b8,>=0.99999999pre->bleach->nbconvert->jupyter)
(0.5.1) distributed 1.21.8 requires msgpack, which is not installed.
You are using pip version 10.0.1, however version 18.0 is available.
You should consider upgrading via the 'python -m pip install --upgrade
pip' command.
Install with PyCharm, with the libraries installation function of the interpreter settings of it. It gets also an error to install:
Install packages failed: Installing packages: error occurred.
Details...
I tried to install other libraries with success (sympy, for example), but I didn't achieve it with Jupyter and Matplotlib.
The root environment has this libraries, but I don't know if I could import from there.
How I should to proceed?
Thank you very much
This blog post explains how to install jupyter into a virtualenv (Disclaimer: I didn't come up with it myself):
http://anbasile.github.io/programming/2017/06/25/jupyter-venv/
In summary:
$ python -m venv projectname
$ source projectname/bin/activate
(venv) $ pip install ipykernel
(venv) $ ipython kernel install --user --name=projectname
I seem to have got it probably.
TLDR: You probably installed jupyter in your base (or root in your language) environment.
I have copied over a small snippet of your messages.
Install with conda install jupyter and conda install matplotlib in the console and cd where the environment is located. The console made its process and it said that both libraries were already installed. I check it in the libraries list of Anaconda Navigator and it doesn't appear.
(base) C:\Users...>cd C:\Users\Alvaro\Anaconda3\envs\tensorflow
(base) C:\Users...\Anaconda3\envs\tensorflow>conda install matplotlib Solving environment: done
All requested packages are already installed.
(base) C:\Users\Alvaro\Anaconda3\envs\tensorflow>conda install jupyter Solving environment: done
Now I am assuming that the above packages really got installed properly.
Why I am doubtful.Solving environment: done is not the last line after a package gets installed.
If you see the first line of each of these messages they all begin with base. This indicates that the packages got installed in the base environment, not your `TensorFlow environment.
So you really won't find them in your `TensorFlow environment.
It would help if you also answer my questions in the comments below the question.