Error while trying to activate environment in Miniconda prompt - miniconda

This is the command and error:
(base) C:\Users\Aaditya Singh\Desktop\ML_Sample_Project>conda activate C:\Users\'Aaditya Singh'\Desktop\ML_Sample_Project\env
activate does not accept more than one argument:
["C:\\Users\\'Aaditya", "Singh'\\Desktop\\ML_Sample_Project\\env"]

Related

Not able to import pandas on command line in Anaconda

command line prompt Powershell command prompt I am trying to import pandas lib from command line and Powershell prompt in Anaconda (version 2.1.4 under Windows 10 Home) but it is giving error, though it is working fine in Spyder, Jupyter and PyCharm in Anaconda. It is not working on normal windows command prompt also.
When I tried to re-install pandas using command "pip install pandas", it gives the message that the same has already been installed. I tried adding environmental variables but that also didn't work. A screenshots of the same are enclosed. The python version I am using is 3.10.4
I will be grateful if someone can help to sort out this problem.
Thanks.
According to the screenshot you provided, I think your input command caused you to enter the python environment on your local computer, not the virtual environment created by Anaconda.
Try typing "python" as the command to enter the interpreter instead of "python3".

Trouble importing packages in python

I had to reinstall Anaconda and Python in my computer. After that I have started getting troubles. Let me describe what are happening.
I installed Anaconda in Program Files. When I try accessing anaconda from start menu, I am getting the error.
Navigator Error
An unexpected error occurred on Navigator start-up
After that tried accessing Jupyter from Anaconda Prompt. Got the following error.
'jupyter' is not recognized as an internal or external command, operable program or batch file.
Installed some packages from Anaconda Prompt and checked that they can be imported inside python from the shell.
After that from start menu I launched jupyter notebook. Inside Jupyter I again failed to import packages that I was able to access from Python prompt.
I am confused and lost. Would appreciate any help. I have done multiple install/uninstall.
Did you just update anything?
Try to import the same thing in Spyder or other python console. Check if it is giving detailed traceback for the issue.
Try updating conda, anaconda , anaconda-navigator from anaconda prompt.

unable to execute VBoxManage command in python executable (created with pyinstaller)

OS: Ubuntu 16.04 LTS
make an install.py file executable:
pyinstaller -w install.py --onefile
install.py script:
import os
VM = os.system('VBoxManage startvm win10 --type headless')
if VM == 0:
print("win10 started...")
else:
print("win10 not started....")
Problem: When I run the python3 install.py on ubuntu terminal it works fine. After that I created it's an executable file with the command mentioned above and when I execute the executable file on the terminal by giving command chmod 777 install & ./install. It gives an error below:
Error:
VBoxManage: error: Failed to create the VirtualBox object!
VBoxManage: error: Code NS_ERROR_FACTORY_NOT_REGISTERED (0x80040154) - Class not registered (extended info not available)
VBoxManage: error: Most likely, the VirtualBox COM server is not running or failed to start.
I don't know what's going wrong python script works fine but when I created it's executable it gives same error every time.
Thanks in advance.

'conda env list' from inside Python shell

I know I can look up the list of conda environments by typing 'conda env list' on the unix terminal. However, I wish to pull that off from within the Python shell (as I need to know if certain conda environments were already created or not). To give some additional background, I am using Python 3+ .
So far, i have tried:
subprocess.check_output('conda env list')
However, I get the following error:
FileNotFoundError: [Errno 2] No such file or directory: 'conda env list'
I tried other methods to write the 'conda evn list' onto the terminal but kept getting the same error.
I had success with:
ret = subprocess.check_output('conda env list', shell=True)
print ret
Caveat: Only tested with 2.7

Using TensorFlow through Jupyter (Python 3)

Apologies in advance, I think the issue is quite perplexing!
I would like to use TensorFlow through Jupyter, with a Python3 kernel.
However the command import tensorflow as tf returns the error: ImportError: No module named tensorflow when either Python2 or Python3 is specified as the Jupyter kernel.
I have Python 2 and Python 3 installed on my Mac and can access both
versions through Terminal.
I installed TensorFlow for Python 3, however I can only access it via Python 2 on the Terminal.
As such, this question is really two-fold:
I want to get TensorFlow working with Python3
...which should lead to TensorFlow working with Jupyter on the Python3 terminal.
I had the same problem and solved it using the tutorial Using a virtualenv in an IPython notebook. I'll walk you through the steps I took.
I am using Anaconda, and I installed a new environment tensorflow using these instructions at tensorflow.org. After that, here is how I got tensorflow to work in a Jupyter notebook:
Open Terminal
Run source activate tensorflow. You should now see (tensorflow) at the beginning of the prompt.
Now that we are in the tensorflow environment, we want to install ipython and jupyter in this environment: Run
conda install ipython
and
conda install jupyter
Now follow the instructions in the tutorial linked above. I'll repeat them here with a bit more information added. First run
ipython kernelspec install-self --user
The result for me was Installed kernelspec python3 in /Users/charliebrummitt/Library/Jupyter/kernels/python3
Run the following:
mkdir -p ~/.ipython/kernels
Then run the following with <kernel_name> replaced by a name of your choice (I chose tfkernel) and replace the first path (i.e., ~/.local/share/jupyter/kernels/pythonX) by the path generated in step 4:
mv ~/.local/share/jupyter/kernels/pythonX ~/.ipython/kernels/<kernel_name>
Now you'll see a new kernel if you open a Jupyter notebook and select Kernel -> Change kernel from the menu. But the new kernel will have the same name as your previous kernel (for me it was called Python 3). To give your new kernel a unique name, run in Terminal
cd ~/.ipython/kernels/tfkernel/
and then run vim kernel.json to edit the file kernel.json so that you replace the value of "display_name" from the default (Python 3) to a new name (I chose to call it "tfkernel"). Save and exit vim by typing :wq while in command mode.
Open a new Jupyter notebook and type import tensorflow as tf. If you didn't get ImportError then you are ready to go!

Resources