Conda ImporrtError whenever I open a new terminal - python

[Edit] Added conda info to question.
Something wrong is happening with my conda setup.
From what I remember, I needed the AI gym library for a lab at my university.
I tried to install it using conda install -c akode gym and I was unable to do so. I used a pip install instead.
Since then, I am having the following error whenever I start a new terminal:
Traceback (most recent call last):
File "<stdin>", line 3, in <module>
ImportError: No module named conda
Conda and all the related software and packages work very fine though.
This is my OS config :
NAME="Ubuntu"
VERSION="18.04.3 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.3 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic
This is the output of conda info :
active environment : base
active env location : /home/cnemri/anaconda3
shell level : 1
user config file : /home/cnemri/.condarc
populated config files :
conda version : 4.8.0
conda-build version : 3.18.11
python version : 3.7.5.final.0
virtual packages : __glibc=2.27
base environment : /home/cnemri/anaconda3 (writable)
channel URLs : https://repo.anaconda.com/pkgs/main/linux-64
https://repo.anaconda.com/pkgs/main/noarch
https://repo.anaconda.com/pkgs/r/linux-64
https://repo.anaconda.com/pkgs/r/noarch
package cache : /home/cnemri/anaconda3/pkgs
/home/cnemri/.conda/pkgs
envs directories : /home/cnemri/anaconda3/envs
/home/cnemri/.conda/envs
platform : linux-64
user-agent : conda/4.8.0 requests/2.22.0 CPython/3.7.5 Linux/4.15.0-1065-oem ubuntu/18.04.3 glibc/2.27
UID:GID : 1001:1001
netrc file : None
offline mode : False
How can I not have this error anymore ?
Thank you.

The error has been fixed, I did a conda update conda as advised by #merv and it works very fine. The error disappeared.

Related

Error launching Spyder from Anaconda Navigator - "chcp 1252 ... 1>nul 2>nul"

I am using Anaconda to conduct data analysis in Python using Spyder. I've been doing so with no trouble for while now, installing packages, updating packages/Spyder/etc., but after updating Spyder, I now receive an error message when launching Spyder from within Anaconda.
C:\Users\jdoe>chcp 1252
Active code page: 1252
C:\Users\jdoe>call C:\Users\jdoe\Anaconda3\Scripts\activate C:\Users\jdoe\Anaconda3
(base) C:\Users\jdoe>spyder 1>nul 2>nul
This terminal window appears, then closes itself and Spyder along with it.
If I open a terminal window from within Anaconda and type spyder, I am able to launch the app successfully. But launching from Anaconda Navigator fails, and I don't understand this error message or how to fix it, nor have I been able to find anything relating to this issue in searching. Any help understanding what is going on and how to correct this would be appreciated.
conda info report if useful:
(base) C:\Users\jdoe>conda info
active environment : base
active env location : C:\Users\jdoe\Anaconda3
shell level : 1
user config file : C:\Users\jdoe\.condarc
populated config files : C:\Users\jdoe\.condarc
conda version : 4.10.1
conda-build version : 3.18.11
python version : 3.8.3.final.0
virtual packages : __win=0=0
__archspec=1=x86_64
base environment : C:\Users\jdoe\Anaconda3 (writable)
conda av data dir : C:\Users\jdoe\Anaconda3\etc\conda
conda av metadata url : https://repo.anaconda.com/pkgs/main
channel URLs : https://repo.anaconda.com/pkgs/main/win-64
https://repo.anaconda.com/pkgs/main/noarch
https://repo.anaconda.com/pkgs/r/win-64
https://repo.anaconda.com/pkgs/r/noarch
https://repo.anaconda.com/pkgs/msys2/win-64
https://repo.anaconda.com/pkgs/msys2/noarch
package cache : C:\Users\jdoe\Anaconda3\pkgs
C:\Users\jdoe\.conda\pkgs
C:\Users\jdoe\AppData\Local\conda\conda\pkgs
envs directories : C:\Users\jdoe\Anaconda3\envs
C:\Users\jdoe\.conda\envs
C:\Users\jdoe\AppData\Local\conda\conda\envs
platform : win-64
user-agent : conda/4.10.1 requests/2.25.1 CPython/3.8.3 Windows/10 Windows/10.0.19041
administrator : False
netrc file : None
offline mode : False

conda `ResolvePackageNotFound` after fresh install

I want to create a new conda environment.
However, I get the following error message:
(base) ➜ ~ conda env create -n ml
Collecting package metadata (repodata.json): done
Solving environment: failed
ResolvePackageNotFound:
- libspatialindex==1.9.0=h6de7cb9_1
- libgdal==2.4.0=h89caebc_1002
- gdal==2.4.0=py37h0e3174d_1002
- openblas==0.3.5=h436c29b_1001
- libcxxabi==8.0.0=2
I removed all of my old environments (they had become bloated) and uninstalled and reinstalled a new miniconda3 installation.
(base) ➜ ~ conda env list
# conda environments:
#
base * /Users/tommylees/miniconda3
Here is some other information:
(base) ➜ ~ conda info
active environment : base
active env location : /Users/tommylees/miniconda3
shell level : 1
user config file : /Users/tommylees/.condarc
populated config files :
conda version : 4.9.2
conda-build version : not installed
python version : 3.8.6.final.0
virtual packages : __osx=10.15.7=0
__unix=0=0
__archspec=1=x86_64
base environment : /Users/tommylees/miniconda3 (writable)
channel URLs : https://repo.anaconda.com/pkgs/main/osx-64
https://repo.anaconda.com/pkgs/main/noarch
https://repo.anaconda.com/pkgs/r/osx-64
https://repo.anaconda.com/pkgs/r/noarch
package cache : /Users/tommylees/miniconda3/pkgs
/Users/tommylees/.conda/pkgs
envs directories : /Users/tommylees/miniconda3/envs
/Users/tommylees/.conda/envs
platform : osx-64
user-agent : conda/4.9.2 requests/2.25.1 CPython/3.8.6 Darwin/19.6.0 OSX/10.15.7
UID:GID : 501:20
netrc file : None
offline mode : False
(base) ➜ ~ cat /Users/tommylees/.condarc
cat: /Users/tommylees/.condarc: No such file or directory
(base) ➜ ~ ls /Users/tommylees/.conda/envs
ls: /Users/tommylees/.conda/envs: No such file or directory
I do not understand why the conda installer is still looking for gdal or other packages which were previously installed but I thought I had removed.

Launching Spyder and JupyterNotebook causes importError when image not found

I'm new to python and the virtual environment stuff. I'm facing issues opening jupyter notebook and Spyder after updating conda.
Here are some info about the versions I have:
$ conda info
active environment : None '''is it caused by this ? '''
user config file : /Users/-/.condarc
populated config files : /Users/-/.condarc
conda version : 4.5.4
conda-build version : 3.0.27
python version : 2.7.14.final.0
base environment : /Users/-/anaconda2 (writable)
channel URLs : https://repo.anaconda.com/pkgs/main/osx-64
https://repo.anaconda.com/pkgs/main/noarch
https://repo.anaconda.com/pkgs/free/osx-64
https://repo.anaconda.com/pkgs/free/noarch
https://repo.anaconda.com/pkgs/r/osx-64
https://repo.anaconda.com/pkgs/r/noarch
https://repo.anaconda.com/pkgs/pro/osx-64
https://repo.anaconda.com/pkgs/pro/noarch
package cache : /Users/-/anaconda2/pkgs
/Users/-/.conda/pkgs
envs directories : /Users/-/anaconda2/envs
/Users/-/.conda/envs
platform : osx-64
user-agent : conda/4.5.4 requests/2.18.4 CPython/2.7.14 Darwin/15.5.0 OSX/10.11.5
UID:GID : 501:20
netrc file : None
offline mode : False
JupyerNotebook version : 5.5.0
Jupyter version : 4.4.0
Spyder version : 3.2.8
Spyder fails to launch and when trying to launch spyder from anaconda navigator I get this error:
/anaconda2/lib/python2.7/site-packages/zmq/backend/cython/init.py", line 6, in
from . import (constants, error, message, context,
ImportError: dlopen(/Users/-/anaconda2/lib/python2.7/site-packages/zmq/backend/cython/error.so, 2): Library not loaded: #rpath/libsodium.23.dylib
Referenced from: /Users/-/anaconda2/lib/libzmq.5.dylib
Reason: image not found
Trying to launch jupyter notebook from anaconda throws the same image not found error:
/anaconda2/lib/python2.7/site-packages/zmq/backend/cython/init.py", line 6, in
from . import (constants, error, message, context,
ImportError: dlopen(/Users/-/anaconda2/lib/python2.7/site-packages/zmq/backend/cython/error.so, 2): Library not loaded: #rpath/libsodium.23.dylib
Referenced from: /Users/-/anaconda2/lib/libzmq.5.dylib
Reason: image not found
I found out that after updating, a new Anaconda2 folder was initialized for only the zmq file /anaconda2/lib/python2.7/site-packages/zmq/backend/cffi/__pycache__.
Everything was working smoothly but after following anaconda instructions and recommendations to update I started getting those errors.
How can I resolve this issue? Is it because the active environment : None?
Faced same issue. From https://github.com/jupyter/notebook/issues/1632 it explained that some dependencies when updating conda are messed up so try:
conda remove zeromq
conda install zeromq
Then try:
conda update conda-build
Good luck,

Anaconda Import Error, module just installed isn't found

Yet another Import Error issue, I know...
I have been through many posts on stackoverflow about this issue but nothing seem to help
Here is the thing, I am not a windows person, I have used anaconda on mac and Linux for quite a while but now I have to train someone on Python with windows10.
So I tried to install Anaconda, thinking oh well that should be easy...
What I did :
Install miniconda3
Create a conda environment named 'first' - activated it
Install numpy scipy and geopandas (conda install -c conda-forge geopandas)
Start IPython
Typed import geopandas and got an Import Error ModuleNotFoundError: No module named 'geopandas'
Note that Geopandas and all packages appear in the pip list of my environment
So then I Import sys and typed sys.path with this result (sys.executable was fine)
['',
'C:\\Users\\mine\\Miniconda3\\Scripts',
'C:\\Users\\mine\\Miniconda3\\python36.zip',
'C:\\Users\\mine\\Miniconda3\\DLLs',
'C:\\Users\\mine\\Miniconda3\\lib',
'C:\\Users\\mine\\Miniconda3',
'C:\\Users\\mine\\Miniconda3\\lib\\site-packages',
'C:\\Users\\mine\\Miniconda3\\lib\\site-packages\\win32',
'C:\\Users\\mine\\Miniconda3\\lib\\site-packages\\win32\\lib',
'C:\\Users\\mine\\Miniconda3\\lib\\site-packages\\Pythonwin',
'C:\\Users\\mine\\Miniconda3\\lib\\site-packages\\IPython\\extensions',
'C:\\Users\\mine\\.ipython']
I believe I should see something about my conda environment in there
c:\users\mine\miniconda3\envs\first\
What did I do wrong? How do I fix it and why do you think that happened? Should I report it to anaconda as it seems to be a pretty annoying thing.
In case that helps :
(first) C:\Users\mine>conda info -a
active environment : first
active env location : C:\Users\mine\Miniconda3\envs\first
shell level : 2
user config file : C:\Users\mine\.condarc
populated config files :
conda version : 4.4.10
conda-build version : not installed
python version : 3.6.3.final.0
base environment : C:\Users\mine\Miniconda3 (writable)
channel URLs : https://repo.continuum.io/pkgs/main/win-64
https://repo.continuum.io/pkgs/main/noarch
https://repo.continuum.io/pkgs/free/win-64
https://repo.continuum.io/pkgs/free/noarch
https://repo.continuum.io/pkgs/r/win-64
https://repo.continuum.io/pkgs/r/noarch
https://repo.continuum.io/pkgs/pro/win-64
https://repo.continuum.io/pkgs/pro/noarch
https://repo.continuum.io/pkgs/msys2/win-64
https://repo.continuum.io/pkgs/msys2/noarch
package cache : C:\Users\mine\Miniconda3\pkgs
C:\Users\mine\AppData\Local\conda\conda\pkgs
envs directories : C:\Users\mine\Miniconda3\envs
C:\Users\mine\AppData\Local\conda\conda\envs
C:\Users\mine\.conda\envs
platform : win-64
user-agent : conda/4.4.10 requests/2.18.4 CPython/3.6.3 Windows/10 Windows/10.0.16299
administrator : False
netrc file : None
offline mode : False
# conda environments:
#
base C:\Users\mine\Miniconda3
first * C:\Users\mine\Miniconda3\envs\first
sys.version: 3.6.3 |Anaconda, Inc.| (default, Nov 8 ...
sys.prefix: C:\Users\mine\Miniconda3
sys.executable: C:\Users\mine\Miniconda3\python.exe
conda location: C:\Users\mine\Miniconda3\lib\site-packages\conda
conda-build: None
conda-env: C:\Users\mine\Miniconda3\Scripts\conda-env.exe
user site dirs:
CIO_TEST: <not set>
CONDA_DEFAULT_ENV: first
CONDA_PREFIX: C:\Users\mine\Miniconda3\envs\first
CONDA_PREFIX_1: C:\Users\mine\Miniconda3
CONDA_PROMPT_MODIFIER: (first)
CONDA_PYTHON_EXE: C:\Users\mine\Miniconda3\python.exe
CONDA_ROOT: C:\Users\mine\Miniconda3
CONDA_SHLVL: 2
HOMEPATH: \Users\mine
PATH: C:\Users\mine\Miniconda3\envs\first;C:\Users\mine\Miniconda3\envs\first\Library\mingw-w64\bin;C:\Users\mine\Miniconda3\envs\first\Library\usr\bin;C:\Users\mine\Miniconda3\envs\first\Library\bin;C:\Users\mine\Miniconda3\envs\first\Scripts;C:\Users\mine\Miniconda3\envs\first\bin;C:\Users\mine\Miniconda3;C:\Users\mine\Miniconda3\Library\mingw-w64\bin;C:\Users\mine\Miniconda3\Library\usr\bin;C:\Users\mine\Miniconda3\Library\bin;C:\Users\mine\Miniconda3\Scripts;C:\Users\mine\Miniconda3\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Users\mine\AppData\Local\Microsoft\WindowsApps;
PSMODULEPATH: C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
PYTHONIOENCODING: 1252
REQUESTS_CA_BUNDLE: <not set>
SSL_CERT_FILE: <not set>
You also need to install IPython into your new environment:
conda install ipython
otherwise it uses the ipython form "outside" the environment because it is a command line app and not necessary connected to an environment.
You can check IPython you use with:
where ipython

Installing local packages with Anaconda

I am using Anaconda with 64 bit Python 2.7 on a Windows 7 machine that is necessarily isolated from the internet. I am having difficulty installing local packages. Right now I am stuck on PyMySQL, but I imagine I would also have the same problem with other packages. My system PATH variable has Anaconda at the beginning.
Trying a path to the unpacked folder:
conda install –-offline c:\temp\PyMySQL-master\pymysql
PackageNotFoundError: Package missing in current win-64 channels:
- c:\temp\pymysql-master\pymysql
What does this error mean? I have tried using a tar file and I get the same error message. This is the same message I get if I spell the filename wrong, so there is something I am missing to get it to recognize the file. Do I need to create a channel for a local package? How would I do that? Is there anything else I should try?
Here is the response in verbose mode:
conda install --offline --verbose c:\temp\pymysql.tar
Fetching package metadata ...........
An unexpected error has occurred.
Please consider posting the following information to the
conda GitHub issue tracker at:
https://github.com/conda/conda/issues
Current conda install:
platform : win-64
conda version : 4.3.21
conda is private : False
conda-env version : 4.3.21
conda-build version : not installed
python version : 2.7.13.final.0
requests version : 2.14.2
root environment : C:\ProgramData\Anaconda2 (writable)
default environment : C:\ProgramData\Anaconda2
envs directories : C:\ProgramData\Anaconda2\envs
C:\Users\lab1\AppData\Local\conda\conda\envs
C:\cygwin\home\lab1\.conda\envs
package cache : C:\ProgramData\Anaconda2\pkgs
C:\Users\lab1\AppData\Local\conda\conda\pkgs
channel URLs : https://repo.continuum.io/pkgs/free/win-64 (offline)
https://repo.continuum.io/pkgs/free/noarch (offline)
https://repo.continuum.io/pkgs/r/win-64 (offline)
https://repo.continuum.io/pkgs/r/noarch (offline)
https://repo.continuum.io/pkgs/pro/win-64 (offline)
https://repo.continuum.io/pkgs/pro/noarch (offline)
https://repo.continuum.io/pkgs/msys2/win-64 (offline)
https://repo.continuum.io/pkgs/msys2/noarch (offline)
config file : C:\cygwin\home\lab1\.condarc
netrc file : None
offline mode : True
user-agent : conda/4.3.21 requests/2.14.2 CPython/2.7.13 Windows/7 Windows/6.1.7601
administrator : True
`$ C:\ProgramData\Anaconda2\Scripts\conda-script.py install --offline --verbose c:\temp\pymysql.tar`
Traceback (most recent call last):
File "C:\ProgramData\Anaconda2\lib\site-packages\conda\exceptions.py", line 632, in conda_exception_handler
return_value = func(*args, **kwargs)
File "C:\ProgramData\Anaconda2\lib\site-packages\conda\cli\main.py", line 137, in _main
exit_code = args.func(args, p)
File "C:\ProgramData\Anaconda2\lib\site-packages\conda\cli\main_install.py", line 80, in execute
install(args, parser, 'install')
File "C:\ProgramData\Anaconda2\lib\site-packages\conda\cli\install.py", line 306, in install
raise PackageNotFoundError(error_message)
PackageNotFoundError: Package missing in current win-64 channels:
- c:\temp\pymysql.tar
Every conda package ever built to date has a .tar.bz2 extension, and this assumption is baked in deeply. Someday we'll probably add different package types, compression algorithms, and extensions, but that's a ways off. So to work, your command needs to be
conda install --offline --verbose c:\temp\pymysql.tar.bz2
and pymysql.tar.bz2 needs to be a real conda package. (i.e. if you unpack that tarball and there's no info/files file in it, then it's not a conda package)

Categories

Resources