Closed Henrike-Schwenn closed 3 years ago
Log #8_1
Log #8_2
Next step
Log #8_3
Log #8_4
[x] + Check versions
Please check both of these carefully to see if they are what you expect. You may need to check your PATH or PYTHONPATH environment variables (see Check Environment Variables below).
Python 3.7.3 | packaged by conda-forge | (default, Mar 27 2019, 23:01:00) [GCC 7.3.0] :: Anaconda, Inc. on linux Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> print("PYTHONPATH:", os.environ.get('PYTHONPATH'))
PYTHONPATH: None
>>> print("PATH:", os.environ.get('PATH'))
PATH: /home/henrike/miniconda3/bin:/home/henrike/miniconda3/condabin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
>>>
Please make sure that you have activated your conda environment. See also the conda user-guide. If you use an external editor/development environment it will have to be set up correctly. See below for solutions for some common setups.
(base) henrike@henrike-HP-250-G5-Notebook-PC:~$ conda info --envs
# conda environments:
#
/home/henrike/anaconda3
base * /home/henrike/miniconda3
(base) henrike@henrike-HP-250-G5-Notebook-PC:~$ cd /home/henrike/anaconda3
(base) henrike@henrike-HP-250-G5-Notebook-PC:~/anaconda3$ conda info --envs
# conda environments:
#
/home/henrike/anaconda3
base * /home/henrike/miniconda3
(base) henrike@henrike-HP-250-G5-Notebook-PC:~/anaconda3$
Next steps
PYTHONPATH
(base) henrike@henrike-HP-250-G5-Notebook-PC:~$ echo $PYTHONPATH
/home/henrike/code
(base) henrike@henrike-HP-250-G5-Notebook-PC:~$ /snap/jupyter/6/bin/python3
Python 3.7.3 | packaged by conda-forge | (default, Mar 27 2019, 23:01:00)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> print("PYTHONPATH:", os.environ.get('PYTHONPATH'))
PYTHONPATH: /home/henrike/code
>>>
https://bic-berkeley.github.io/psych-214-fall-2016/using_pythonpath.html
Switch current location to anaconda
- Deactivate/Change your active environment
You can always use conda activate or conda deactivate to switch between your environments. You can directly activate the environment you wish to use by using conda activate.
https://towardsdatascience.com/manage-your-python-virtual-environment-with-conda-a0d2934d5195
Log #8_5
Next step
Log #8_6
I'm trying to run Jupyter Notebook created using an older Ubuntu version under Ubuntu 20.04. I have installed first Miniconda and then Anaconda Python as the latter download file was too large for my PC. When running the notebook file to see if everything worked, it failed to import numpy. The error message went as follows:
import pandas
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-26-38d4b0363d82> in <module>
----> 1 import pandas
/home/henrike/anaconda3/lib/python3.8/site-packages/pandas/__init__.py in <module>
15 if missing_dependencies:
16 raise ImportError(
---> 17 "Unable to import required dependencies:\n" + "\n".join(missing_dependencies)
18 )
19 del hard_dependencies, dependency, missing_dependencies
ImportError: Unable to import required dependencies:
numpy:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
* The Python version is: Python3.7 from "/snap/jupyter/6/bin/python"
* The NumPy version is: "1.18.5"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: No module named 'numpy.core._multiarray_umath'
I tried to fix the problem by adding the filepath via sys.path.append(), but it had no effect. Neither did creating a new notebook and trying to import numpy there.
So I checked the versions of Python and NumPy as instructed in the error message. First, I searched for "numpy" in my navigator.
There are two versions, apparently: A folder "numpy-1.18.5-py38ha1c710e_0" in /anaconda3/pkgs and a folder "numpy-1.19.1-py38hbc911f0_0" in /miniconda3/pkgs. As for Python, I have /snap/jupyter/6/bin/python3.8".
I figured that those versions should be identical or at least close enough to the versions required in the error message. So I went on by checking if both the notebook and my terminal were pointing at the correct Python version via sys.executable.
Both returned /snap/jupyter/6/bin/python
. So the notebook is definitly pointing at the correct Python version and the correct numpy version is installed on my computer.
Next, I followed the link https://numpy.org/devdocs/user/troubleshooting-importerror.html included in the error message for further instructions. The first thing it suggested was checking the environment variables.
Please check both of these carefully to see if they are what you expect. You may need to check your PATH or PYTHONPATH environment variables (see Check Environment Variables below).
I checked PYTHONPATH and PATH in my terminal: Python 3.7.3 | packaged by conda-forge | (default, Mar 27 2019, 23:01:00) [GCC 7.3.0] :: Anaconda, Inc. on linux Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> print("PYTHONPATH:", os.environ.get('PYTHONPATH'))
PYTHONPATH: None
>>> print("PATH:", os.environ.get('PATH'))
PATH: /home/henrike/miniconda3/bin:/home/henrike/miniconda3/condabin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
>>>
So, there was a PATH within miniconda, but no PYTHONPATH. Next on the list was making sure that my conda environment was indeed activated.
Please make sure that you have activated your conda environment. See also the conda user-guide. If you use an external editor/development environment it will have to be set up correctly. See below for solutions for some common setups.
(base) henrike@henrike-HP-250-G5-Notebook-PC:~$ conda info --envs
# conda environments:
#
/home/henrike/anaconda3
base * /home/henrike/miniconda3
(base) henrike@henrike-HP-250-G5-Notebook-PC:~$ cd /home/henrike/anaconda3
(base) henrike@henrike-HP-250-G5-Notebook-PC:~/anaconda3$ conda info --envs
# conda environments:
#
/home/henrike/anaconda3
base * /home/henrike/miniconda3
(base) henrike@henrike-HP-250-G5-Notebook-PC:~/anaconda3$
As to be expected, there are two conda environments on my PC: miniconda and anaconda. The current environment is miniconda. I activated anaconda, but it had no effect. At this point, I suspected the problem lay either within PYTHONPATH or the conda environment. I went on to set a PYTHONPATH, but again, it had no effect. Then I tried to switch my current environment from miniconda to anaconda, but couldn't find out how by a quick research. I just found this advice from Towards Data Science:
Deactivate/Change your active environment You can always use conda activate or conda deactivate to switch between your environments. You can directly activate the environment you wish to use by using conda activate.
https://towardsdatascience.com/manage-your-python-virtual-environment-with-conda-a0d2934d5195
To sum up: By now, I'm fairly certain that the failure to import numpy is caused miniconda being my current conda environment, because the required numpy version, 1.18.5 is located in the anaconda folder, not the miniconda folder. I'll be grateful for your ideas on how to fix this, or if you point out if I missed anything else.
Log #8_7
Log #8_8
I'm trying to run a Jupyter Notebook in Ubuntu 20.04. I have installed first Miniconda and then Anaconda Python as the latter download file was too large for my PC.
When running the notebook file to see if everything worked, it failed to import NumPy. The error message went as follows:
import pandas
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-26-38d4b0363d82> in <module>
----> 1 import pandas
/home/henrike/anaconda3/lib/python3.8/site-packages/pandas/__init__.py in <module>
15 if missing_dependencies:
16 raise ImportError(
---> 17 "Unable to import required dependencies:\n" + "\n".join(missing_dependencies)
18 )
19 del hard_dependencies, dependency, missing_dependencies
ImportError: Unable to import required dependencies:
numpy:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
* The Python version is: Python3.7 from "/snap/jupyter/6/bin/python"
* The NumPy version is: "1.18.5"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: No module named 'numpy.core._multiarray_umath'
I tried to fix the problem by adding the file path via sys.path.append(), but it didn't work.
So I checked the versions of Python and NumPy as instructed in the error message. First, I searched for "numpy" in my navigator.
There are two versions, apparently: A folder "numpy-1.18.5-py38ha1c710e_0" in "/anaconda3/pkgs and a folder "numpy-1.19.1-py38hbc911f0_0" in "/miniconda3/pkgs". As for Python, I have "/snap/jupyter/6/bin/python3.8".
I assumed that those versions should be identical or at least close enough to the versions required. So I checked if both the notebook and my terminal were pointing at the correct Python version via sys.executable.
Both returned /snap/jupyter/6/bin/python
. So the notebook is definitely pointing at the correct Python version and the correct NumPy version is installed on my computer.
Next, I followed the link included in the error message for further instructions. The first thing it suggested was checking the environment variables.
Please check both of these carefully to see if they are what you expect. You may need to check your PATH or PYTHONPATH environment variables (see Check Environment Variables below).
I checked PYTHONPATH and PATH in my terminal:
Python 3.7.3 | packaged by conda-forge | (default, Mar 27 2019, 23:01:00) [GCC 7.3.0] :: Anaconda, Inc. on linux Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> print("PYTHONPATH:", os.environ.get('PYTHONPATH'))
PYTHONPATH: None
>>> print("PATH:", os.environ.get('PATH'))
PATH: /home/henrike/miniconda3/bin:/home/henrike/miniconda3/condabin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
>>>
So, there was a PATH within miniconda, but no PYTHONPATH.
Next on the list was making sure that my conda environment was indeed activated.
Please make sure that you have activated your conda environment. See also the conda user-guide. If you use an external editor/development environment it will have to be set up correctly. See below for solutions for some common setups.
(base) henrike@henrike-HP-250-G5-Notebook-PC:~$ conda info --envs
# conda environments:
#
/home/henrike/anaconda3
base * /home/henrike/miniconda3
(base) henrike@henrike-HP-250-G5-Notebook-PC:~$ cd /home/henrike/anaconda3
(base) henrike@henrike-HP-250-G5-Notebook-PC:~/anaconda3$ conda info --envs
# conda environments:
#
/home/henrike/anaconda3
base * /home/henrike/miniconda3
(base) henrike@henrike-HP-250-G5-Notebook-PC:~/anaconda3$
As to be expected, there are two conda environments on my PC: miniconda and anaconda. The current environment is miniconda. I activated anaconda, but it didn't make any difference.
At this point, I suspected the problem lay either within PYTHONPATH or the conda environment. I went on to set a PYTHONPATH, but again, to no difference. Then I tried to switch my current environment from miniconda to anaconda, but couldn't find out how by quick research. I just found this advice from Towards Data Science:
Deactivate/Change your active environment You can always use conda activate or conda deactivate to switch between your environments. You can directly activate the environment you wish to use by using conda activate.
To sum up: By now, I'm fairly certain that the failure to import NumPy is caused by miniconda being my current conda environment, because the required NumPy version, 1.18.5, is located in the anaconda folder, not the miniconda folder. I'll be grateful for your ideas on how to fix this, or if you point out if I've missed anything else.
did you install jupyter with snap ? if yes, in bashrc provide jupyter path from anaconda env
Probably, since jupyter is located in a folder called "snap". It was either installed as a part of Miniconda or Anaconda, so I didn't install it conciously and don't know for sure.
Python 3.8 | Miniconda3 Linux 64-bit | 89.9 MiB | 1314b90489f154602fd794accfc90446111514a5a72fe1f71ab83e07de9504a7 |
---|
from https://docs.conda.io/en/latest/miniconda.html
bash Miniconda3-latest-Linux-x86_64.sh
from https://conda.io/projects/conda/en/latest/user-guide/install/linux.html#install-linux-silent
conda install anaconda
from https://docs.anaconda.com/anaconda/user-guide/troubleshooting/#anaconda-installer-download-problemsTry adding path into the bashrc file
export PATH="/usr/local/share/rsi/idl/bin:/home/username/anaconda/bin:$PATH"
Log #8_10
Welcome to Polysterine Duck Debugging. Bugs are your friends.
(base) henrike@henrike-HP-250-G5-Notebook-PC:~$ python
Python 3.8.3 (default, May 19 2020, 18:47:26)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> import pandas
>>> numpy.exp(2)
7.38905609893065
>>> numpy.log(1.7935)
0.5841690179902003
>>>
Log #8_11
Correct executable in terminal: '/home/henrike/miniconda3/bin/python'
It seems I destroyed my Jupyter notebook while installing a new python3 kernel.
It seems I destroyed my Jupyter notebook while installing a new python3 kernel.
Leave it here. Focus on Python editor instead.
Error warning