I recently installed anaconda and created a new environment in a different location outside of anaconda base directory.
So I created the environment:
python -m venv tfod
Activated it
.\tensorflowenv\Scripts\activate
Upgraded pip and installed ipykernel
python -m pip install --upgrade pip
pip install ipykernel
Issue starts when i try to install/add this new environment into jupyter kernel so I can use this env
python -m ipykernel install --user --name=tensorflowenv
but getting this DLL error
File "D:\project\Tensorflow_obj\TFODCourse\tensorflowenv\lib\site-packages\zmq\backend\cython\__init__.py", line 6, in <module>
from . import (
ImportError: DLL load failed while importing _device: The file cannot be accessed by the system.
This isn't the exact "solution" for this but its a work around.
I created an environment using conda navigator and downloaded the required packages from navigator itself and then added the env into jupyter kernel using
python -m ipykernel install --user --name=tensorflowenv
Still would be happy if someone can provide a actual solution for this
Related
I have created a virtual environment using the following commands:
python3 -m venv venv
.\venv\Scripts\activate.bat
pip3 install ipykernel
pip3 install jupyter
python3 -m ipykernel install --user --name=venv
I have created a Jupyter notebook using the venv that I created, but when I install a package in the virtual environment, it is not recognised in the notebook.
For example, I tried to install pandas using pip3 install pandas, but when I try and import it into my notebook I get the error ModuleNotFoundError: No module named 'pandas'
The module has installed in the right place venv\Lib\site-packages\pandas\
Any ideas on what I should do?
EDIT:
I noticed that even though I created the notebook using the venv, it uses the normal python environment rather than the virtual one. Ideas on how to fix this?
Well I think I solved it. If ran the following command:
python -c "import IPython"
Which just installs IPython in my venv.
You need to restart the notebook kernel, it will probably work then.
In the future, in a notebook cell you can run
%%bash
pip install pandas
then you should be able to continue without restarting
I have installed OpenCv library through this line "pip install opencv-python" and it is successfully installed, but I am trying to import it through: "import cv2" and it gives me an error:
ModuleNotFoundError: No module named 'cv2'
please help me!
If your pip is installed with any other python version than conda, it won't work.
Option 1) Install pip with conda python
Run conda create -n venv_name and source activate venv_name, where venv_name is the name of your virtual environment.
Run conda install pip. This will install pip to your venv directory.
Option 2) Run conda install opencv
I have several packages being imported perfectly in my Python 3.5. But not in my Jupyter Notebook... When i try to Import those packages in Jupyter i get and error of module not found.
Is there a way to make Jupyter load my Python 3.5 as a kernel... or something similar. I'm working in a virtual environment. Already tried to reinstall the packages again in my virtual env But no success.
Try to install the packages inside a jupyter notebook cell like this:
!pip install package
So you are sure that the packages are installed in jupyter's environment
If you install the ipython kernel form inside the virtualenv, you can guarantee that the packages are imported to the jupyter if they are imported to this env. Also, if you use this approach, you do not need to activate the virtualenv every time you run the jupyter, because jupyter does it automatically.
$ python -m venv projectname
$ source projectname/bin/activate
(venv) $ pip install ipykernel
(venv) $ ipython kernel install --user --name=projectname
(venv) $ pip install {package needed to install}
Source: Using jupyter notebooks with a virtual environment
I created a conda environment (with python 3.6 and Anaconda 3-5.2.0 on a Windows 10 machine) and activated it. I then installed both jupyter and pip using conda install jupyter and conda install pip. Both commands executed without problems.
When I type jupyter notebook or pip install [some package] I get this:
The same happens for the pip command. What might be the cause of this issue?
I have a venv/virtualenvwrapper set up in a directory. After I start working on the venv, i then create a Jupyter notebook inside of the directory, which brings me to Jupyter's localhost browser. I then attempt to import a library, e.g. pandas, which raises the ModuleNotFoundError. I would think that if the venv is being worked on, Jupyter would link to it.
Also, I can import global libraries from pip3, just not the local ones in a venv. Is there a way to use the virtualenvwrapper library with Jupyter?
I found out here I had to install ipykernel after activating the venv, then create a projectname:
(venv) $ pip install ipykernel
(venv) $ ipython kernel install --user --name=projectname
After that, I went back to the Jupyter browser and change the kernel from python 3 to the projectname which is only viewable after executing the second command line above.
This works for both virtualenv and virutalenvwrapper.
The only downfall is installing ipykernel adds a lot of extra libraries to your venv pip3, but I suppose you could just install ipykernel in your global pip3 to keep from installing it in your venv.