I am using spyder Anaconda. I am unable to import
from preprocessing import parse_annotation,BatchGenerator
I tried to install preprocssing using,
pip install preprocessing
got following error,
Requirement already satisfied: preprocessing in
c:\users\shahik\anaconda3\lib\site-packages (0.1.13)
Requirement already satisfied: nltk==3.2.4 in c:\users\shahik\anaconda3\lib\site-
packages (from preprocessing) (3.2.4)
Requirement already satisfied: sphinx-rtd-theme==0.2.4 in
c:\users\shahik\anaconda3\lib\site-packages (from preprocessing) (0.2.4)
Requirement already satisfied: six in c:\users\shahik\anaconda3\lib\site-packages
(from nltk==3.2.4->preprocessing) (1.10.0)
notebook 5.3.1 requires terminado>=0.8.1, which is not installed.
notebook 5.3.1 has requirement jupyter_client>=5.2.0, but you'll have jupyter-
client 5.0.1 which is incompatible.
notebook 5.3.1 has requirement jupyter_core>=4.4.0, but you'll have jupyter-core
4.3.0 which is incompatible.
Also tried to install from conda commands but failed. How can I solve these compatibility or other issues?
Related
Recently I am facing a embrassing problem is that some Python packages must install using pip. I have read the pip and conda difference:
What is the difference between pip and conda?
I think many people facing the same problem that when you choose conda, then some package could not using conda install, when you use pip install the pacakge, it could not imported into the local project because the project only could import pakcage installed by conda install command. For example I want to use eyeD3 to read the mp3 meta data, but the package could not installed by conda, I installed the package using pip but could not import in the PyCharm IDE. What is the best way to solve this conflict? Am I missing something? Or I have to switch to pip? is it possible to make conda could install package from pip? Any suggestion is welcome, I want to fetch a guidline. I have tried install package like this in the macOS Big Sur:
/usr/local/anaconda3/envs/pydolphin ⌚ 22:20:21
$ ./bin/python -m pip install eyed3 ‹ruby-2.7.2›
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Requirement already satisfied: eyed3 in ./lib/python3.9/site-packages (0.9.6)
Requirement already satisfied: filetype<2.0.0,>=1.0.7 in ./lib/python3.9/site-packages (from eyed3) (1.0.8)
Requirement already satisfied: coverage[toml]<6.0.0,>=5.3.1 in ./lib/python3.9/site-packages (from eyed3) (5.5)
Requirement already satisfied: deprecation<3.0.0,>=2.1.0 in ./lib/python3.9/site-packages (from eyed3) (2.1.0)
Requirement already satisfied: toml in ./lib/python3.9/site-packages (from coverage[toml]<6.0.0,>=5.3.1->eyed3) (0.10.2)
Requirement already satisfied: packaging in ./lib/python3.9/site-packages (from deprecation<3.0.0,>=2.1.0->eyed3) (21.3)
Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in ./lib/python3.9/site-packages (from packaging->deprecation<3.0.0,>=2.1.0->eyed3) (3.0.6)
(base)
still could not import this pakacage in the PyCharm IDE. I could found the package from the env:
/usr/local/anaconda3/envs/pydolphin/lib/python3.9/site-packages/eyed3
haiii i am running python code in ubuntu 18.04
i needed opencv libarary for the code so i installed opencv using python3
pip3 install opencv-python
but the code requires and compatible with python 2
so i tried to install the library using just pip instead of pip3
when i tried to install opencv using pip it is saying
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: opencv-python in /home/sri/.local/lib/python3.6/site-packages (4.4.0.46)
Requirement already satisfied: numpy>=1.13.3 in /home/sri/.local/lib/python3.6/site-packages (from opencv-python) (1.19.4)
but running my file python train.py shows no module named cv2
some body please help me to solve this problem
same going with my pytorch library also
Traceback (most recent call last):
File "train.py", line 6, in <module>
from model import CANNet
File "/home/sri/Downloads/Context-Aware-Crowd-Counting-master/model.py", line 1, in <module>
import torch.nn as nn
ImportError: No module named torch.nn
so i tried installing pytorch
pip install torch==1.7.0+cpu torchvision==0.8.1+cpu torchaudio==0.7.0 -f https://download.pytorch.org/whl/torch_stable.html
Defaulting to user installation because normal site-packages is not writeable
Looking in links: https://download.pytorch.org/whl/torch_stable.html
Requirement already satisfied: torch==1.7.0+cpu in /home/sri/.local/lib/python3.6/site-packages (1.7.0+cpu)
Requirement already satisfied: torchvision==0.8.1+cpu in /home/sri/.local/lib/python3.6/site-packages (0.8.1+cpu)
Requirement already satisfied: torchaudio==0.7.0 in /home/sri/.local/lib/python3.6/site-packages (0.7.0)
Requirement already satisfied: numpy in /home/sri/.local/lib/python3.6/site-packages (from torch==1.7.0+cpu) (1.19.4)
Requirement already satisfied: future in /home/sri/.local/lib/python3.6/site-packages (from torch==1.7.0+cpu) (0.18.2)
Requirement already satisfied: dataclasses in /home/sri/.local/lib/python3.6/site-packages (from torch==1.7.0+cpu) (0.8)
Requirement already satisfied: typing-extensions in /home/sri/.local/lib/python3.6/site-packages (from torch==1.7.0+cpu) (3.7.4.3)
Requirement already satisfied: pillow>=4.1.1 in /home/sri/.local/lib/python3.6/site-packages (from torchvision==0.8.1+cpu) (8.0.1)
You are troubleshooting with your versions. You say your code is not workable for python3 so you tried to run it on python2. It seems that your pip is linking against your python 3.6 Version instead of python 2.X. The best way to handle these problems are virtual environments:
Python 3.X: https://docs.python.org/3/library/venv.html
Python 2.X: https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/
Inside an activated Environment the command python and pip are linked to the version of the environment.
I have created a virtual env and installed Jupyter notebood and jupyter lab
after import pandas I get ModuleNotFoundError: No module named 'pandas'
doing the same operation with jupyter notebook does not give me an error, which run in the same venv
I installed pandas into the venv, but got the same error
importing the native python modules works fine
inserting !pip install pandas in an empty cell above returns
Requirement already satisfied: pandas in /home/curwin/jupyterlab/venv/lib/python3.8/site-packages (1.1.3)
Requirement already satisfied: pytz>=2017.2 in /home/curwin/jupyterlab/venv/lib/python3.8/site-packages (from pandas) (2020.1)
Requirement already satisfied: python-dateutil>=2.7.3 in /home/curwin/jupyterlab/venv/lib/python3.8/site-packages (from pandas) (2.8.1)
Requirement already satisfied: numpy>=1.15.4 in /home/curwin/jupyterlab/venv/lib/python3.8/site-packages (from pandas) (1.19.2)
Requirement already satisfied: six>=1.5 in /home/curwin/jupyterlab/venv/lib/python3.8/site-packages (from python-dateutil>=2.7.3->pandas) (1.14.0)
I have install a kernel inside the venv with
ipython kernel install --user --name=.venv
and running notebooks from this kernel solved the problem
I was hoping someone could help me out.
System is MacOS Catalina.
Python 3.8
IDE: VS
I installed matplotlib using pip install matplotlib which I saw stuck in under python2.7. I uninstalled matplotlib and reinstalled it using pip3 install matplotlib and received the following message:
Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.7/site-packages (from matplotlib) (0.10.0)
Requirement already satisfied: numpy>=1.11 in /usr/local/lib/python3.7/site-packages (from matplotlib) (1.18.1)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /usr/local/lib/python3.7/site-packages (from matplotlib) (2.4.6)
Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.7/site-packages (from matplotlib) (1.1.0)
Requirement already satisfied: python-dateutil>=2.1 in /usr/local/lib/python3.7/site-packages (from matplotlib) (2.8.1)
Requirement already satisfied: six in /Users/apple/Library/Python/3.7/lib/python/site-packages (from cycler>=0.10->matplotlib) (1.13.0)
Requirement already satisfied: setuptools in /usr/local/lib/python3.7/site-packages (from kiwisolver>=1.0.1->matplotlib) (46.0.0)
However, when I try to run my .py file with 'import matplotlib' it gives this error:
import matplotlib as mpl
ModuleNotFoundError: No module named 'matplotlib'
I've tried searching different sources for the solution but I am now stuck.
You are mostly running your python script with the command python your_file.py, try running as python3 your_file.py in your terminal. pip3 installs packages under python3, not the default python2.
This is because I believe your mac terminal uses python 2.x by default, therefore the command python uses python 2.x version and python3 uses 3.x version that is available to execute the files. So if you want to install any packages under python 2.x you use pip as the command and to install packages under python 3.x you use pip3 as the command
The jupyter widgets exension is not rendering the ui items. Have tried updating the client and enabling widgetsnbextension but code below :
!pip install --upgrade jupyter_core jupyter_client
!jupyter nbextension enable --py widgetsnbextension
from IPython.display import display
button = widgets.Button(description="Click Me!")
display(button)
def on_button_clicked(b):
print("Button clicked.")
button.on_click(on_button_clicked)
renders :
Requirement already up-to-date: jupyter_core in /usr/local/lib/python2.7/dist-packages
Requirement already up-to-date: jupyter_client in /usr/local/lib/python2.7/dist-packages
Requirement already up-to-date: traitlets in /usr/local/lib/python2.7/dist-packages (from jupyter_core)
Requirement already up-to-date: python-dateutil>=2.1 in /usr/local/lib/python2.7/dist-packages (from jupyter_client)
Requirement already up-to-date: pyzmq>=13 in /usr/local/lib/python2.7/dist-packages (from jupyter_client)
Requirement already up-to-date: tornado>=4.1 in /usr/local/lib/python2.7/dist-packages (from jupyter_client)
Requirement already up-to-date: enum34; python_version == "2.7" in /usr/local/lib/python2.7/dist-packages (from traitlets->jupyter_core)
Requirement already up-to-date: six in /usr/local/lib/python2.7/dist-packages (from traitlets->jupyter_core)
Requirement already up-to-date: decorator in /usr/local/lib/python2.7/dist-packages (from traitlets->jupyter_core)
Requirement already up-to-date: ipython-genutils in /usr/local/lib/python2.7/dist-packages (from traitlets->jupyter_core)
Requirement already up-to-date: singledispatch in /usr/local/lib/python2.7/dist-packages (from tornado>=4.1->jupyter_client)
Requirement already up-to-date: futures in /usr/local/lib/python2.7/dist-packages (from tornado>=4.1->jupyter_client)
Requirement already up-to-date: backports-abc>=0.4 in /usr/local/lib/python2.7/dist-packages (from tornado>=4.1->jupyter_client)
Enabling notebook extension jupyter-js-widgets/extension...
- Validating: OK
Button(description='Click Me!', style=ButtonStyle())
The text :
Button(description='Click Me!', style=ButtonStyle())
is rendered instead of a UI button
Is another library required ?
From http://ipywidgets.readthedocs.io/en/latest/user_install.html :
Question: When I display a widget or interact, I just see some text,
such as IntSlider(value=0) or interactive(children=(IntSlider(value=0,
description='x', max=1), Output()),
_dom_classes=('widget-interact',)). What is wrong?
Answer: A text representation of the widget is printed if the widget
control is not available. It may mean the widget JavaScript is still
loading. If the message persists in the Jupyter Notebook or
JupyterLab, it likely means that the widgets JavaScript library is
either not installed or not enabled. See the installation instructions
above for setup instructions.
Page refresh fixed issue for me. I think installs referred to in my question were still required.
In my case I had to run again the cells in the jupyter notebook. In the tab Widgets, selecting Save Notebook Widgets State should render the widgets everytime you open the notebook again, without having to re run it.