I have ubuntu 2022LTS with python 3.10.4 and numpy installed.
But since I installed miniconda, I cannot get back to my original system installation of python even when I deactivate conda:
prokophapala#ProkopDesktop:~$ conda activate
(base) prokophapala#ProkopDesktop:~$ python --version
Python 3.9.12
(base) prokophapala#ProkopDesktop:~$ conda deactivate
prokophapala#ProkopDesktop:~$ python --version
Python 3.9.12
prokophapala#ProkopDesktop:~$ python3
Python 3.9.12 (main, Apr 5 2022, 06:56:58)
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'numpy'
>>>
Activating a conda environment means that the location of the Python interpreter and the C-libraries (numpy) are temporarily added to the system path. After deactivation the old system path is restored.
Obviously during miniconda installation you enabled the option to "Add Python to the system path" which is not the default option and which is not recommended, since you can't access your previous Python any more.
So the solution is to check your system path, remove all miniconda Python references (except for the path to condabin) and add the path to your previous Python again. Note that you can have both interpreters in parallel on your system, but you always have to activate a conda environment before you can use it.
Related
After activating a python virtual environment at the terminal with source ./venv/bin/activate, and running python3 in the venv, it doesn't seem to have the packages from the venv in the path.
(venv) d#MBP-2020 scrapers % ls venv/lib/python3.11/site-packages | grep "pandas"
pandas
pandas-1.5.2.dist-info
(venv) d#MBP-2020 scrapers % pip list | grep "pandas"
pandas 1.5.2
(venv) d#MBP-2020 scrapers % python3
Python 3.11.0 (v3.11.0:deaf509e8f, Oct 24 2022, 14:43:23) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas as pd
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pandas'
>>> import sys; print(sys.path)
['', '/Library/Frameworks/Python.framework/Versions/3.11/lib/python311.zip', '/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11', '/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/lib-dynload', '/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages']
I thought activating the venv would put the venv-installed packages in the right path for the python3 executable? Must I manually add the site-packages directory to the path somehow?
What is the right workflow to access packages installed venvs with python?
this pip is not match you cmd python3 run python env,
you can use whereis pip and whereis python3 to check you pip and python3 real link to where.
if your want to use venv py.
run venv/lib/python3.11/bin/python, this env is your grep cmd search dir,and is installed pandas lib py env,
you can usr pyenv or conda to manage you mulit version.
I input python in cmd and it shows a warning:
C:\Users\sky>python
Python 3.8.8 (default, Apr 13 2021, 15:08:03) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Warning:
This Python interpreter is in a conda environment, but the environment has
not been activated. Libraries may fail to load. To activate this environment
please see https://conda.io/activation
Type "help", "copyright", "credits" or "license" for more information.
>>>
I cannot use pip install any packages, I thought maybe that's the problem. So I checked the information at the link:https://conda.io/activation
and followed the instruction:
c:\Anaconda3\Scripts\activate base
It said 'system cannot find the path'. I searched for the files in that path and found two of them are named 'activate'. So I input
c:\Anaconda3\Scripts\activate
but still,'system cannot find the path'.
How to activate the conda environment? I really need some help. Thanks
In a clean Anaconda installation you should have condabin only, e.g.
C:\Anaconda3\condabin
on your system path. To activate the base environment from the command prompt you use
C:\> conda activate
(base) C:\>
This will add the following folders to your system path too:
C:\Anaconda3;
C:\Anaconda3\Library\mingw-w64\bin;
C:\Anaconda3\Library\usr\bin;
C:\Anaconda3\Library\bin;
C:\Anaconda3\Scripts;
Only now you you are ready to run python and import all your packages properly.
The same thing typically happens when you select Anaconda prompt from your programs menu.
I have a conda environment named ml, and I have activated this environment in powershell using following commands:
>> conda init powershell
>> conda activate ml
(ml) >>
When I open a notebook with jupyter notebook command, it works fine and I have access to the modules inside ml environment:
import torch # No errors inside a jupyter notebook cell
But when I try to test my modules inside the powershell and Python prompt, it doesn't work:
(ml) >> py
Python 3.8.6 (tags/v3.8.6:db45529, Sep 23 2020, 15:52:53) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'torch'
I'm newbie to the conda environments. Is there any way to use conda environments within Python prompt of windows powershell?
Make sure pytorch is installed in your environment using:
conda install -c pytorch pytorch
I think there must be some issue with the conda initialization in the powershell try restarting the powershell once you have done init
conda init powershell
and then activate environment then it should work
Help me understand few things, im new with python and all these depended libraries.
I m trying to run a project which is written in python. Git repository can be found here: https://github.com/ifzhang/FairMOT
On anaconda prompt I have been running these commands:
conda create -n FairMOT
conda activate FairMOT
conda install pytorch==1.2.0 torchvision==0.4.0 cudatoolkit=10.0 -c pytorch
cd ${FAIRMOT_ROOT}
pip install -r requirements.txt
All being successfully installed
I have performed all the steps that were listed in the Readme file
Now there is training step which requires to run shell script.
Assuming the fact that shell script would not be called on anaconda prompt, I switched to git bash, and I run the script (keeping in mind of path)
sh experiments/crowdhuman_dla34.sh
it throws error
Sanam#LAPTOP-NPVR76P7 MINGW64 /f/NTNU/Deep learning/Repositories/FairMOT (master)
$ sh experiments/crowdhuman_dla34.sh
Traceback (most recent call last):
File "train.py", line 10, in <module>
import torch
ModuleNotFoundError: No module named 'torch'
Question is: is there any other console where I need to run this command other than git bash? it would definitely not work on anaconda prompt. what im doing wrong?
coming back to anaconda prompt, when I test import there, it worked
(FairMOT) F:\NTNU\Deep learning\Repositories\FairMOT>python
Python 3.7.9 (default, Aug 31 2020, 17:10:11) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>>
where & how do I run this command? so that it would work?is running on git bash not good?
thanks in advance!!
PS:
I have already tried reinstalling, activation/ deactivation of environment but it does not work
Pls. create a virtual envrionment first, then install all the dependencies there. Use the same venv in anaconda and run the bash script in any terminal with the venv activated.
Also, you can run which python to ensure you are installing and then importing it from same python interpreter
While trying to install atom-lint package in Atom editor I somehow corrupted my conda installation.
I did the following things that might have caused the issue:
Installed a python dependency Flake8 using conda install.
Messed around with Atom Init Script (I can provide more info if needed)
After I did these things I encountered the following problem:
If I run conda I get
$ conda
Traceback (most recent call last):
File "/Users/me/miniconda3/bin/conda", line 12, in <module>
from conda.cli import main
ModuleNotFoundError: No module named 'conda'
Strangely enough if I run python in my command line anaconda still seems to be installed an working.
$ python
Python 3.7.1 (default, Oct 23 2018, 14:07:42)
[Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
I have also noticed that the Python3 bin has disappeared from the conda environment folder ~/miniconda3/envs/my_env/bin/
This is very strange and I thought might be related.
Any help would be much appreciated.
I ended up making a backup copy of the miniconda3/envs folder, reinstalling miniconda and copying the environment back in. It works now, not sure what caused the issue.