nteract / hydrogen

:atom: Run code interactively, inspect data, and plot. All the power of Jupyter kernels, inside your favorite text editor.
https://nteract.gitbooks.io/hydrogen/
MIT License
3.92k stars 334 forks source link

Python3 + Atom + Hydrogen + Conda virtualenv not working #1893

Open jessicagohh opened 4 years ago

jessicagohh commented 4 years ago

Description

I've looked through a dozen pages on GitHub, stackoverflow, Atom's forum pages, and tried out their recommendations, nothing seems to work.

I use a conda virtualenv, and in the past this worked fine. I'm not sure what happened that it doesn't work any more.

The problem: ModuleNotFoundError: No module named 'geopy'

^when I try to import geopy in a Hydrogen kernel in Atom. This instance of Atom was opened within the virtualenv I'd installed geopy on (using atom --new-instance or simply atom).

Because I also create a new kernel using python -m ipykernel install --user --name YourEnvName before I've opened Atom, when importing in Atom, I'm asked which kernel to use - I pick the new one I'd created.

I have fresh installations of jupyter, updated conda, installed anaconda.

Before all the above, I'd tried uninstalling Atom (incl manually searching for all of the as-yet-undeleted Atom files and removing them myself), then reinstalling it with the Hydrogen package. I've also tried deleting all user-installed packages in the base environment, then creating fresh new virtualenvs - also didn't work.

Right now Atom appears to find only packages that were universal/installed on base. geopy is installed on the virtualenv I'm on - no problems importing geopy when I'm running Python shell from Anaconda Prompt.

Steps to Reproduce

  1. Create new virtualenv, specifying Python3.
  2. Activate new virtualenv.
  3. Install (from conda-forge) pandas, geopy, jupyter.
  4. Run python -m pip install python-language-server[all].
  5. Create new kernel with python -m ipykernel install --user --name MyVirtualEnv.
  6. Open Atom in virtualenv using atom or atom --new-instance.
  7. type import geopy in Atom, and attempt to run it in the container. You will be prompted to select between the kernels for Python3 or MyVirtualEnv.
  8. After selection, the code runs, and the error is produced.

Versions

OS version: Windows 10

atom --version

Atom    : 1.44.0
Electron: 4.2.7
Chrome  : 69.0.3497.128
Node    : 10.11.0

apm --version

apm  2.4.3
npm  6.2.0
node 10.2.1 x64
atom 1.44.0
python 3.8.2
git 2.23.0.windows.1
visual studio

Logs

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-4-5f69d3e8449e> in <module>
----> 1 from geopy.geocoders import Nominatim

ModuleNotFoundError: No module named 'geopy'

conda list produces:

#packages in environment at C:\Users\Deliveroo\Anaconda3\envs\MyVirtualEnv:

 Name                    Version                   Build  Channel
astroid                   2.3.3                    pypi_0    pypi
attrs                     19.3.0                     py_0    conda-forge
autopep8                  1.5                      pypi_0    pypi
backcall                  0.1.0                      py_0    conda-forge
bleach                    3.1.1                      py_0    conda-forge
boost-cpp                 1.72.0               h0caebb8_0    conda-forge
bzip2                     1.0.8                hfa6e2cd_2    conda-forge
ca-certificates           2019.11.28           hecc5488_0    conda-forge
certifi                   2019.11.28       py38h32f6830_0    conda-forge
cfitsio                   3.470                hfa6e2cd_2    conda-forge
click                     7.0                        py_0    conda-forge
click-plugins             1.1.1                      py_0    conda-forge
cligj                     0.5.0                      py_0    conda-forge
colorama                  0.4.3                      py_0    conda-forge
curl                      7.68.0               h4496350_0    conda-forge
decorator                 4.4.2                      py_0    conda-forge
defusedxml                0.6.0                      py_0    conda-forge
entrypoints               0.3                   py38_1000    conda-forge
expat                     2.2.9                he025d50_2    conda-forge
fiona                     1.8.13           py38hb7fdc2d_0    conda-forge
flake8                    3.7.9                    pypi_0    pypi
freetype                  2.10.0               h563cfd7_1    conda-forge
freexl                    1.0.5             hd288d7e_1002    conda-forge
gdal                      3.0.4            py38h2fee047_1    conda-forge
geographiclib             1.50                       py_0    conda-forge
geopandas                 0.7.0                      py_1    conda-forge
geopy                     1.21.0                     py_0    conda-forge
geos                      3.8.0                he025d50_0    conda-forge
geotiff                   1.5.1                h58edbdd_9    conda-forge
gettext                   0.19.8.1          hb01d8f6_1002    conda-forge
glib                      2.58.3          py38hc0c2ac7_1002    conda-forge
hdf4                      4.2.13            hf8e6fe8_1003    conda-forge
hdf5                      1.10.5          nompi_ha405e13_1104    conda-forge
icu                       64.2                 he025d50_1    conda-forge
importlib_metadata        1.5.0                    py38_0    conda-forge
intel-openmp              2020.0                      166    anaconda
ipykernel                 5.1.4            py38h5ca1d4c_0    conda-forge
ipython                   7.13.0           py38h5ca1d4c_0    conda-forge
ipython-genutils          0.2.0                    pypi_0    pypi
ipython_genutils          0.2.0                      py_1    conda-forge
ipywidgets                7.5.1                      py_0    conda-forge
isort                     4.3.21                   pypi_0    pypi
jedi                      0.15.2                   pypi_0    pypi
jinja2                    2.11.1                     py_0    conda-forge
jpeg                      9c                hfa6e2cd_1001    conda-forge
jsonschema                3.2.0                    py38_0    conda-forge
jupyter                   1.0.0                      py_2    conda-forge
jupyter_client            6.0.0                      py_0    conda-forge
jupyter_console           6.0.0                      py_0    conda-forge
jupyter_core              4.6.3                    py38_0    conda-forge
kealib                    1.4.10            hf7dc31f_1005    conda-forge
krb5                      1.16.4               hdd46e55_0    conda-forge
lazy-object-proxy         1.4.3                    pypi_0    pypi
libblas                   3.8.0                    15_mkl    conda-forge
libcblas                  3.8.0                    15_mkl    conda-forge
libclang                  9.0.1           default_hf44288c_0    conda-forge
libcurl                   7.68.0               h4496350_0    conda-forge
libffi                    3.2.1             h6538335_1006    conda-forge
libgdal                   3.0.4                hd7a9a0e_1    conda-forge
libiconv                  1.15              hfa6e2cd_1005    conda-forge
libkml                    1.3.0             h7e985d0_1011    conda-forge
liblapack                 3.8.0                    15_mkl    conda-forge
libnetcdf                 4.7.3           nompi_hc957ea6_101    conda-forge
libpng                    1.6.37               h7602738_0    conda-forge
libpq                     12.2                 h795e76a_0    conda-forge
libsodium                 1.0.17               h2fa13f4_0    conda-forge
libspatialindex           1.9.3                he025d50_3    conda-forge
libspatialite             4.3.0a            hed33574_1035    conda-forge
libssh2                   1.8.2                h642c060_2    conda-forge
libtiff                   4.1.0                h21b02b4_3    conda-forge
libwebp                   1.0.2                hfa6e2cd_5    conda-forge
libxml2                   2.9.10               h9ce36c8_0    conda-forge
lz4-c                     1.8.3             he025d50_1001    conda-forge
m2w64-expat               2.1.1                         2
m2w64-gcc-libgfortran     5.3.0                         6
m2w64-gcc-libs            5.3.0                         7
m2w64-gcc-libs-core       5.3.0                         7
m2w64-gettext             0.19.7                        2
m2w64-gmp                 6.1.0                         2
m2w64-libiconv            1.14                          6
m2w64-libwinpthread-git   5.0.0.4634.697f757               2
m2w64-xz                  5.2.2                         2
markupsafe                1.1.1            py38hfa6e2cd_0    conda-forge
mccabe                    0.6.1                    pypi_0    pypi
mistune                   0.8.4           py38hfa6e2cd_1000    conda-forge
mkl                       2020.0                      166    anaconda
msys2-conda-epoch         20160418                      1
munch                     2.5.0                      py_0    conda-forge
nbconvert                 5.6.1                    py38_0    conda-forge
nbformat                  5.0.4                      py_0    conda-forge
notebook                  6.0.3                    py38_0    conda-forge
numpy                     1.18.1           py38hc71023c_0    conda-forge
openjpeg                  2.3.1                h57dd2e7_3    conda-forge
openssl                   1.1.1d               hfa6e2cd_0    conda-forge
pandas                    1.0.1            py38he350917_0    conda-forge
pandoc                    2.9.2                         0    conda-forge
pandocfilters             1.4.2                      py_1    conda-forge
parso                     0.6.2                      py_0    conda-forge
pcre                      8.44                 h6538335_0    conda-forge
pickleshare               0.7.5                 py38_1000    conda-forge
pip                       20.0.2                     py_2    conda-forge
pluggy                    0.13.1                   pypi_0    pypi
poppler                   0.67.0               h1707e21_8    conda-forge
poppler-data              0.4.9                         1    conda-forge
postgresql                12.2                 hd6b8478_0    conda-forge
proj                      6.3.1                ha7a8c7b_1    conda-forge
prometheus_client         0.7.1                      py_0    conda-forge
prompt-toolkit            3.0.3                    pypi_0    pypi
prompt_toolkit            2.0.10                     py_0    conda-forge
pycodestyle               2.5.0                    pypi_0    pypi
pydocstyle                5.0.2                    pypi_0    pypi
pyflakes                  2.1.1                    pypi_0    pypi
pygments                  2.5.2                    pypi_0    pypi
pylint                    2.4.4                    pypi_0    pypi
pyproj                    2.5.0            py38h26f50eb_1    conda-forge
pyqt                      5.12.3           py38h6538335_1    conda-forge
pyqt5-sip                 4.19.18                  pypi_0    pypi
pyqtwebengine             5.12.1                   pypi_0    pypi
pyrsistent                0.15.7           py38hfa6e2cd_0    conda-forge
python                    3.8.2           h5fd99cc_3_cpython    conda-forge
python-dateutil           2.8.1                      py_0    conda-forge
python-jsonrpc-server     0.3.4                    pypi_0    pypi
python-language-server    0.31.8                   pypi_0    pypi
python_abi                3.8                      1_cp38    conda-forge
pytz                      2019.3                     py_0    conda-forge
pywin32                   227                      pypi_0    pypi
pywinpty                  0.5.7                    py38_0    conda-forge
pyzmq                     19.0.0                   pypi_0    pypi
qt                        5.12.5               h7ef1ec2_0    conda-forge
qtconsole                 4.7.1                      py_0    conda-forge
qtpy                      1.9.0                      py_0    conda-forge
rope                      0.16.0                   pypi_0    pypi
rtree                     0.9.4            py38hbf79ddb_0    conda-forge
send2trash                1.5.0                      py_0    conda-forge
setuptools                45.2.0                   py38_0    conda-forge
shapely                   1.7.0            py38h2130f3d_0    conda-forge
six                       1.14.0                   py38_0    conda-forge
snowballstemmer           2.0.0                    pypi_0    pypi
sqlite                    3.30.1               hfa6e2cd_0    conda-forge
tbb                       2018.0.5             he980bc4_0    conda-forge
terminado                 0.8.3                    py38_0    conda-forge
testpath                  0.4.4                      py_0    conda-forge
tiledb                    1.7.0                hffbbd95_2    conda-forge
tk                        8.6.10               hfa6e2cd_0    conda-forge
tornado                   6.0.4            py38hfa6e2cd_0    conda-forge
traitlets                 4.3.3                    py38_0    conda-forge
vc                        14.1                 h21ff451_3    anaconda
vs2015_runtime            15.5.2                        3    anaconda
wcwidth                   0.1.8                      py_0    conda-forge
webencodings              0.5.1                      py_1    conda-forge
wheel                     0.34.2                     py_1    conda-forge
widgetsnbextension        3.5.1                    py38_0    conda-forge
wincertstore              0.2                   py38_1003    conda-forge
winpty                    0.4.3                         4    conda-forge
wrapt                     1.11.2                   pypi_0    pypi
xerces-c                  3.2.2             h6538335_1004    conda-forge
xz                        5.2.4             h2fa13f4_1001    conda-forge
yapf                      0.29.0                   pypi_0    pypi
zeromq                    4.3.2                h6538335_2    conda-forge
zipp                      3.1.0                      py_0    conda-forge
zlib                      1.2.11            h2fa13f4_1006    conda-forge
zstd                      1.4.4                hd8a0e53_1    conda-forge

Tickets this is related to (but their solutions did not resolve the issue) : https://github.com/nteract/hydrogen/issues/501 https://github.com/nteract/hydrogen/issues/899

sandrofsousa commented 3 years ago

I confirm the same issue here, no matter what I do hydrogen only starts the base kernel and the recommendations from the previous discussions are not effective.

MacOs 11.0.1
Atom 1.53.0 x64
Conda 4.9.2
Hydrogen 2.14.6

Importing python from terminal with the env active load the correct version, though running jupyter notebook loads the base python instead of env. The env is available for selection when creating a new notebook but somehow it still points to the base python,sys.version returns the base python and the package needed from the env is not available.

Amsoht commented 3 years ago

Update: I ran conda update ipykernel and again python -m ipykernel install --user --name toolpacenv and now it really seems to work! However I need to start Atom from the console in an activated environment (base, toolpacenv, ...). Still don't understand, what's going on...


Original message:

I am having trouble starting the selected environment at all. Unfortunately, I get an error and cannot run code:

Traceback (most recent call last): File "C:\Users\wagenhaeuser\Anaconda3\envs\toolpacenv\lib\runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "C:\Users\wagenhaeuser\Anaconda3\envs\toolpacenv\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Users\wagenhaeuser\Anaconda3\envs\toolpacenv\lib\site-packages\ipykernel_launcher.py", line 15, in from ipykernel import kernelapp as app File "C:\Users\wagenhaeuser\Anaconda3\envs\toolpacenv\lib\site-packages\ipykernelinit.py", line 2, in from .connect import File "C:\Users\wagenhaeuser\Anaconda3\envs\toolpacenv\lib\site-packages\ipykernel\connect.py", line 18, in import jupyter_client File "C:\Users\wagenhaeuser\Anaconda3\envs\toolpacenv\lib\site-packages\jupyter_clientinit.py", line 4, in from .connect import File "C:\Users\wagenhaeuser\Anaconda3\envs\toolpacenv\lib\site-packages\jupyter_client\connect.py", line 21, in import zmq File "C:\Users\wagenhaeuser\Anaconda3\envs\toolpacenv\lib\site-packages\zmqinit.py", line 55, in from zmq import backend File "C:\Users\wagenhaeuser\Anaconda3\envs\toolpacenv\lib\site-packages\zmq\backendinit.py", line 40, in reraise(*exc_info) File "C:\Users\wagenhaeuser\Anaconda3\envs\toolpacenv\lib\site-packages\zmq\utils\sixcerpt.py", line 34, in reraise raise value File "C:\Users\wagenhaeuser\Anaconda3\envs\toolpacenv\lib\site-packages\zmq\backendinit.py", line 27, in _ns = select_backend(first) File "C:\Users\wagenhaeuser\Anaconda3\envs\toolpacenv\lib\site-packages\zmq\backend\select.py", line 28, in select_backend mod = import(name, fromlist=public_api) File "C:\Users\wagenhaeuser\Anaconda3\envs\toolpacenv\lib\site-packages\zmq\backend\cythoninit.py", line 6, in from . import (constants, error, message, context, ImportError: DLL load failed: Das angegebene Modul wurde nicht gefunden.

It seems, as if there is a "\" missing in several pathnames (right before "__init__").

When I instead open a console, activate the environment ("toolpacenv" in this case) and then type "atom", I can run the code using the (only then showing up) "Python3" kernel. However, I cannot switch environments in atom this way. I get the same error, when I try. Any ideas how to fix this very much appreciated.

Cheers