I have installed tidy by "conda install -c conda-forge tidy-html5" and then installed pytidylib
by "conda install -c hargup/label/pypi pytidylib".
The installation is fine. But when I do "import tidylib" I got the following error:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-a3a284945f3a> in <module>
----> 1 import tidylib
~\anaconda3\lib\site-packages\tidylib\__init__.py in <module>
23 import re
24 import platform
---> 25 from sink import create_sink, destroy_sink
26
27 __all__ = ['tidy_document', 'tidy_fragment', 'release_tidy_doc']
ModuleNotFoundError: No module named 'sink'
I can't find any solution to the issue above. The internet is showing a lot on "
Error running kitchen_sink.py after installing kivyMD" which is not related. Has anyone managed to make tidylib work in window's environment? I'm running python on Juptyer.
Try running the command conda install sink.
If that does not work try creating a virtual environment using conda create -n yourenvname python=x.x anaconda then activate environment by conda activate yourenvname Install additional Python packages to a virtual environment by conda install -n yourenvname [package] to deactivate environment conda deactivate.Else try using pip install to install the modules outside anaconda.
First try these outside Jupyter to check whether everything is fine then in Jupyter.
Related
Yesterday I created a conda environment on a Linux server (Ubuntu 18.04). The installation commands were as follows:
conda create --name yolov5 python=3.8.13
conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch
Then I installed requirements.txt with pip of yolov5 repo. Everything went smoothly and I even did an inference on a sample image. I also created a clone of that env as conda create clone yolov5 --name yolov5-2.
Today I was going to do some training on conda env yolov5. After activating it with conda activate yolov5, I ran the train.py with its arguments. However, I got the following error:
Traceback (most recent call last):
File "/home/projects/yolov5/train.py", line 26, in <module>
import torch
ModuleNotFoundError: No module named 'torch'
It looks like this conda env (yolov5) got linked to the base env. Because when I activate yolov5 and type python, its version is 3.9.7 which is exactly the same with base env's python version. Besides, yolov5-2 is running perfectly well, I could import torch without any issues.
Why did it happen?
How can I solve this?
I'm getting started with virtual environments, and I'm having some sort of path issue.
First I create a virtual environment:
python -m venv conda-env
.\conda-env\Scripts\activate
(conda-env) shows up in the prompt.
Now I install a package:
pip install netcdf4
pip list
Package Version
---------- -------
cftime 1.1.3
netCDF4 1.5.3
numpy 1.19.0
pip 19.2.3
setuptools 41.2.0
Everything looks good. Now if i start a console and try to load the module, things go haywire:
jupyter console
In [1]: import netCDF4
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-9588a3d4fb24> in <module>
----> 1 import netCDF4
ModuleNotFoundError: No module named 'netCDF4'
If I run the console from the site-packages directory however, the following runs with no errors.
cd .\conda-env\Lib\site-packages\
jupyter console
import netCDF4
edit1:
If I install jupyter in my virtual environment, that fixes the problem.
pip install jupyter
I don't get it. Do I need to do this for every virtual environment?
edit2:
If I use python directly, instead of a jupyter console I don't get this problem. The code below works where test.py has the line import netCDF4.
python -m venv venv
./venv/Scripts/activate
pip install netCDF4
python test.py
edit 3
On a mac, pip install jupyter doesn't fix the problem. I'm very confused.
I set the PYTHONPATH environment variable in the virtual environment to include the virtual environment site-packages path, for ex.
# Setting the PYTHONPATH
export PYTHONPATH=/Users/leo/dev/lib/python3.9/site-packages
This should pick up the packages you installed in your virtual environment with pip install.
I am trying to import Keras lib code to execute CRF using the import command below but an error raises as titled. Please share the solution for this.
The command used to execute is
from keras_contrib.layers import CRF
Traceback (most recent call last):
File "", line 1, in
from keras_contrib.layers import CRF
ImportError: No module named 'keras_contrib'
A simple
(sudo) pip install git+https://www.github.com/keras-team/keras-contrib.git
as mentioned in the installation instructions did the trick for me.
This error means that Python is unable to find the module in one of the directories defined by Python path. The module is either not installed or is installed in another directory.
If not installed, then see https://github.com/keras-team/keras-contrib for installation instructions.
If installed but not found, you will most likely need to add the directory where it is installed to your Python path. You can find out what your current Python path is by inspecting the variable sys.path (such as python -c 'import sys; print sys.path'). You may need to add another directory to your path by setting the environment variable PYTHONPATH before running your script, but there are other options. See for example PYTHONPATH vs. sys.path for some insight.
After struggling for a while, I was so willing to make myself clear of this issue, so I searched for a while, and just figured out and tested.
When you create a new conda env by specifying the python version, it will use the conda_root_python version. And if you didn't install the pip package, and try to use pip under your created conda env, it will only run the conda_root_pip and install the package in the root site_packages.
I know three ways to install python packages only in your created conda env.
For a better explanation, we create a conda env with same python version of conda root environment.
conda create -n myenv python
I. One of the officials advise, install package with conda command for specified conda environment,
conda install -n myenv tensorflow
II. Another one of official advise, get into your specified environment and run conda install
source activate myenv
conda install tensorflow
in above two ways you don't need to install extra packages like pip and other pip related packages.
III. For people who really want to pip, just because get used of that.
install pip package(just as above two ways did).
conda install -n myenv pip
or
source active myenv
conda install pip
then comes the pip install when you are in your environment
pip install tensorflow
--------new edit above 15.April.2018--------------
Just to make it more clear.
If you are working under anaconda environment, you should also install all the modules and IDE you need in that environment.
Here I just put one example of anaconda env flows:
conda create --name=my_conda_env python=2.7 #create an environment
activate my_conda_env #get into that env
pip install numpy #install packages you need
...
pip install keras_contrib
pip install spyder #install IDE
Getting Started with conda
---------
Try install in root
activate root
pip install keras_conrib
go back to your tensorflow
start your spyder and try again
Maybe this is your issue
Module installed on Conda, but gives error on importing in Spyder (Python IDE)
----------------- above new answer
It seems you are under conda environment, env-name is "tensorflow", so try to start python and try import again. To make it clear
make sure you have (tensorflow) in front of C:\Users>
type python to start python
import keras_contrib to see if you have keras_contrib in anaconda env (tensorflow) due your comment, it should be
from keras_conrib.layers import CRF (crf or CRF? just try)
If you installed keras_contrib in env "tensorflow", should also start python and do your jobs in the same env, for a new env, you have to install it again.
Here is something for newbie just like me after playing with python for a while and still not familiar with anaconda, I hope you didn't come up with that. As follows:
I used to think in my anaconda env is already in python(actually not yet), so I just type
from keras_contrib.layers import CRF when I saw (tensorflow)C:/Users> which is actually wrong
The right way as described up is get into python(step 2.) or ipython or jupyter just for test if you get the package.
--------------------- below is old answer
I think you confused keras with keras_contrib.
They are two different modules.
try pip install keras_contrib or use other ways to install keras_contrib.
If you are trying to install the tensorflow-keras version or even the keras version using git cloning and setup.py installing and getting the above error then you might want to add the path of the keras-contrib folder to system path using -
import sys
sys.path.append('<remaining_path>/keras_contrib')
Simply run:
conda install git+https://www.github.com/keras-team/keras-contrib.git
If you use Tensorflow, you may get over this error by replacing
from keras_contrib.layers import CRF
with
from tensorflow_addons.layers import CRF
If you're still interested in Keras itself, use the following line in Jupyter
!pip install git+https://www.github.com/keras-team/keras-contrib.git
Just note that you may face other errors while using seperate Keras, so I suggest that you use Keras that is supported in Tensorflow.
I run the following line from Spyder (Anaconda3):
from plyfile import PlyData, PlyElement
and I get the following error message:
Traceback (most recent call last):
File "<ipython-input-269-2c796028388e>", line 1, in <module>
from plyfile import PlyData, PlyElement
ImportError: No module named 'plyfile'
Next I went to the Anaconda3 Scripts subdirectory and using the Windows Commander I wrote:
conda install plyfile
I received the following error message:
PackageNotFound: Package not found: "Package missing in current win 64 channels:
-plyfile
I made a search using the Google and I found the plyfile in the following address https://pypi.python.org/pypi/plyfile, but then I do not know what to do with it.
Could you please help me?
pip install plyfile, if something isn't in the default anaconda repository but still a pypi package you can pip install and conda will still track the package within your environment.
Try this. This worked for me.
sudo su
pip install plyfile
I got plyfile to work in the Windows 10 Pro environment using Spyder 3.1.3, with a Python 2.7 environment on Anaconda as follows:
Open the plyfile.py program file in Spyder #This program is in the plyfile-05 file in the pkgs subdirectory of anaconda3.
Run the plyfile.py program in spyder3 and run "import plyfile" from the IPython console. #If you use the "from plyfile import PlyData, PlyElement" statement you will get an error : TypeError: 'NoneType' object is not callable' when you run a program that calls PlyData or PlyElement.
Remove any import statement like "from plyfile import PlyData, PlyElement" from the program you want to use plyfile in. #Otherwise you will get the TypeError above when you run your program file.
Run your .py file now and the 3D figure should be generated.
First activate the conda environment where you want to install the plyfile package
source activate environment_name
Then use pip to install the plyfile package
pip install plyfile
After that you can check whether the package has been installed in the same conda environment by using
conda list
Find out executable used by Spyder or Jupyter
import sys
sys.executable
If its not using virtual environment executable
Setup ipykernal to use the virtual environment (devconda).
python -m ipykernel install --user --name=devconda
After this
sys.executable
/opt/anaconda/envs/devconda/bin/python
And the pip imports will work in Jupyter or Spyder
I have installed folium using command 'conda install -c ioos folium=0.2.0'
It looks to have installed correctly, and it showing on 'conda list' results.
When I run python from cmdline, then attempt an import of folium, i get the following error:
>>>import folium
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'folium'
Any ideas about how to fix this?
I had the same issue. If you are using Anaconda:
When you install using conda install -c conda-forge folium, the package will be placed in:
./anaconda3/envs/[name env]/lib/python3.7/site-packages/folium
When you install using pip (with an anaconda env activated), pip install folium, the package will be placed in:
./anaconda3/lib/python3.7/site-packages/folium
Python uses first the sites-packages as the target directory of manually built Python packages. When you build and install Python packages from source (using distutils, probably by executing python setup.py install), you will find the installed modules in site-packages by default.
In this case you have two places: /anaconda3/lib/python3.7/site-packages/ and /anaconda3/envs/[name env]/lib/python3.7/site-packages/.
First the modules will be available as default in /anaconda3/lib/python3.7/site-packages/. Sometimes (and I really don't know why) the modules inside sites-packages conda env are not available to import automatically without export the PATH.
So, to solve this issue, you have 2 options:
Installing using pip install folium and import folium (don't need install by conda install), or
After conda install <package>, run conda init, close the terminal and open a new one. Then, try to import again.
Here are some tips about how to use pip in a conda-environment.
Check if the ...../python3.x/site-packages is listed within sys.path. If not append it with sys.path.append('.....python3.8/site-packages')