I have a working Python 3.6 and the package imutils is recognized, importable in its shell. Today I installed some packages on my Python 2 for another task, and now my IPython does not recognize imutils anymore:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-b01afa4ab41d> in <module>()
4 import random
5 import math
----> 6 import imutils
7 import re
8 import time
ImportError: No module named imutils
What's going on? How fragile are these things, seriously.
I run sys.executable on both environments and the result is the same:
/usr/bin/python3
I checked my Python2 and the package is not installed there:
sudo -H pip2.7 uninstall imutils
Skipping imutils as it is not installed.
Doing this:
/usr/bin/python3 -V
Returns this:
Python 3.6.7
Restarting does not work. I did use sudo commands, installed, uninstalled several times - no luck. Something has screwed up my Python, I think.
P.S: I do use Python3 on my IPython as interpreter.
P.S: I don't use Python 3.4 as a kernel whatsoever, they are all 3.6.
EDIT: Okay it is clear that ROS installation screwed up my Python path since I see this:
os.getenv("PYTHONPATH")
'/home/user/ros_ws/devel/lib/python2.7/dist-packages:/opt/ros/melodic/lib/python2.7/dist-packages'
HOW CAN I SET IT BACK TO WHERE IT WAS BY DEFAULT?
It was due to the fact that ROS sourced its own Python version (2.7) by changing the PYTHONPATH.
Once I removed it from my .bashrc, it started to work again.
Related
I'm new to python and Anaconda and I tried to run my code which contains Levenshtein import, however, it shows me this error:
ImportError Traceback (most recent call last)
<ipython-input-1-896847aaaa86> in <module>()
1 import pandas as pd
2 import numpy as np
----> 3 import Levenshtein as lv
4 import math
5 import re
ImportError: No module named 'Levenshtein'
Any recommendations regarding this, I owe you tons of thanks
The error happens because Anaconda does not ship with the Levenshtein package. You'll have to install it.
Usually, you want to install python packages on Jupyter Notebook by using the conda command. I was having trouble installing this package in particular on a Windows, however, simply because Windows Defender held out the process indefinitely.
The way I managed to install it as by using pip in Windows's cmd. First you have to figure out were the python executable from your Notebook is running.
In your notebook:
import sys
{sys.executable}
Copy the path the cell outputs, open the cmd. There, use the following command:
[PASTE THE PATH HERE] -m pip install python-levenshtein
After that you should be able to import Levenshtein.
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.
When trying to use yolo for python I followed https://github.com/thtrieu/darkflow I got flow installed using
pip3 install .
but then, when running
flow --h
I get
File "/home/computername/.local/lib/python3.5/site-packages/darkflow/net/help.py", line 9, in <module>
import cv2
ImportError: No module named 'cv2'
When I call python I get into python 3.6 and if the import cv2 it does not give any problem, i.e., cv2 is imported.
When calling
which python
I get
/home/computername/anaconda3/bin/python
So flow does call the wrong version python. I thought, maybe I should delete the python 3.5 version on my computer, but looking for how to do that I only find warnings that I should not do that.
So my question is: what to do such that it will work?
maybe other relevant information:
which pip3
/usr/bin/pip3
and (I tried to install flow with pip first, but that did not work)
which pip
/home/bombus/anaconda3/bin/pip
I am working on Ubuntu 16.04.3 LTS
I just installed numpy on my PC (running windows 10, running python 3.5.2) using WinPython, but when i try to import it in IDLE with: import numpy I get the ImportError: Traceback (most recent call last):
File "C:\Users\MY_USERNAME\Desktop\DATA\dataScience1.py", line 1, in <module>
import numpy
ImportError: No module named 'numpy'.
Did I possibly install it incorrectly, or do I need to do something else before it can be used?
In Linux and Mac OS systems we can install modules directly by mentioning
pip install modulename (or) sudo pip install modulename
in terminal or command prompt.
But in windows we should mention location of python folder in c directory like c:\python3 and later we should use
pip install modulename
in command prompt or terminal.
or
go n check whether numpy module is installed in sitepackages of python 3 folder in c directory or not.
Support for Python 3 was added in NumPy version 1.5.0, so to begin with, you must download/install a newer version of NumPy.
or use this command to install numpy. This will install the latest version of numpy.
pip install numpy
Winpython has two size, and the smallest "Zero" size doesn't include numpy
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.