Installing a package using pip or easy_install with ipython / conda - python

I'm trying to install 'frida' on my Anaconda environment, and although it installs fine, I keep getting an error when importing it from IPython:
In [4]: import frida
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-4-58e5c65e5010> in <module>()
----> 1 import frida
ImportError: No module named frida
On the normal python shell the import works fine. The problem is only with IPython.
I've tried using easy_install from the conda command line - no go.
I've tried this from an IPython shell:
In [5]: easy_install.main( ["-U","frida"] )
And the package install successfully, but IPython still gave an error when importing it.
pip doesn't find the package.
I seem to be missing something with the IPython packages - How does one install packages to IPython?

If you are working in virtualenv, then installing IPython into virtualenv resolve such problems.
Usually, IPython is giving this advice when it start inside of virtualenv.

Related

Jupyter-notebook failed to import python packages

I was trying to use numpy in Jupyter Notebook in a Python3 virtual environment, but the encountered an error.
In terminal, I did:
$ python3 -m venv py3env
$ source py3env/bin/activate
(py3env)$ jupyter notebook
And on the Jupyter page, I created a new notebook and executed the followings
!pip install numpy
import numpy as np
And the resulting output is this:
Requirement already satisfied: numpy in /Users/MyName/py3env/lib/python3.9/site-packages (1.20.2)
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-4-d83b6b4f94f9> in <module>
1 get_ipython().system('pip install numpy')
----> 2 import numpy as np
ModuleNotFoundError: No module named 'numpy'
The package is already installed but still cannot be found...?
Is there a way to fix this issue?
You may be using pip from a different python installation.
To install with the same python executable as your jupyter kernel, in one cell run:
import sys
Then in another cell run:
!{sys.executable} -m pip install numpy
It would appear you are trying to call a dependency you installed on a virtual environment, attempt to reinstall numpy on jupyter, then try again.

ModuleNotFoundError: No module named 'pyecharts'

I do not understand while running the example code from pyecharts, it is still giving me module not found error.
ModuleNotFoundError Traceback (most recent call last)
in
----> 1 from pyecharts.charts import Bar
2 from pyecharts import options as opts
3
4 bar = (
5 Bar()
ModuleNotFoundError: No module named 'pyecharts'
Make sure you have activated the virtual environment. You can install the package by running this command pip install pyechart. You should freeze the package into the requirements.txt file by running this command pip freeze -r requirements.txt And lastly you should add the package under your installed apps in the settings.py file, if any command exists for that. You could read the full documentation here https://pyecharts.readthedocs.io/en/latest/en-us/documentation/ to clear any further doubts.
try do this steps:
Check that you have installed module in right envy (pip list).
If you don't have, install by using pip (pip install pyecharts -U). see doc https://github.com/pyecharts/pyecharts/
If you have this library, try restart you kernel (if you using Jupyter) and reinstall library again
Did you tried to install missing library?
https://pypi.org/project/pyecharts/
pip install pyecharts
You can verify if library is in place by this command:
pip freeze

I cannot install pandas-datareader on windows for anaconda jupyter notebook

I cannot import pandas_datareader on my jupyter notebook(via anaconda, python3) on my windows 10 laptop. It has been installed and I can see the file but It's having errors with importing into the jupyter notebook file. Any help?
I have tried :
pip install pandas-datareader ,
pip3 install pandas-datareader ,
conda install -c anaconda pandas-datareader
I expect the the code to run smoothly however I get
ModuleNotFoundError Traceback (most recent call last)
in ()
----> 1 import pandas_datareader
ModuleNotFoundError: No module named 'pandas_datareader'
Most obvious reason can be that you are using differnt enviroments(kernels) for jupyter notebook and others. Try running this code inside jupyter notebook empty project:
try:
from pip._internal.operations import freeze
except ImportError: # if your pip version is bigger then 10
from pip.operations import freeze
requirements = freeze.freeze()
for i in requirements:
print(i)
and check if there are your's missing imports
You have to run CMD Prompt from Anaconda navigator or find it from Start menu. Then use this command:
conda install pandas_datareader
I underwent similar difficulties and successfully fixed thanks to this post - Trouble installing some libraries in python (oauth2client and gspread) Conda is installing packagies to environment for Anaconda which is obviously different than pip uses.

ModuleNotFoundError Despite being Installed

I'm having trouble loading a package that is installed in my environment and have no idea why..
conda list
fbprophet 0.3.post2 py36_0 conda-forge
When I request for libraries installed in conda, it clearly shows that I have fbprophet installed. Now, when I import it, a ModuleNotFoundError exception is thrown.
from fbprophet import Prophet
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-83be6864a7aa> in <module>()
----> 1 from fbprophet import Prophet
2 import numpy as np
3 import pandas as pd
ModuleNotFoundError: No module named 'fbprophet'
Has anybody run into this issue? What can I do to troubleshoot this?
My suggestion would be creating a virtual environment for your python first, then conda install your package in the virtual environment.
My script was reading from my pip install list where the module fbprophet did not exist. I went back and installed it there and everything worked. Lesson learned.
Always check where your libraries are being read from.
You may have more than one Python installation. Thus you might installed the library in one Python installation and tried to call it from another one. Please let me know if you have more than one Python installation by printing the result os this CMD command where python.

ModuleNotFoundError: No module named 'twitter'

I am attempting to import a twitter api wrapper. I am using https://github.com/bear/python-twitter and have installed it using pip install python-twitter, when I run pip freeze into the command prompt it shows that I have python-twitter==3.2.1 installed however when I try to import it using import twitter in Jupyter QTConsole running Python 3.6.0, I get back this error:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-645f6dc1896f> in <module>()
----> 1 import twitter
ModuleNotFoundError: No module named 'twitter'
I am at a loss as to what is going wrong, the package doesn't say it's restricted to a certain version of python, and searching online hasn't helped. So now I am asking here in case anyone has a solution.
Turns out I had 2 versions of Anaconda installed and the package was defaulting to the wrong one, uninstalling the older version of anaconda and reinstalling the package fixed the problem.

Categories

Resources