I’m on osX Catalina. When in the Terminal I’m doing an echo $PATH, here is the output :
/Users/Nicolas/opt/anaconda3/bin:/Users/Nicolas/opt/anaconda3/condabin:/Users/Nicolas/.poetry/bin:/Library/Frameworks/Python.framework/Versions/3.8/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/share/dotnet:~/.dotnet/tools:/Library/Apple/usr/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands
I realized that I need to reorder the PATH because when I’m trying to create a virtual environment with pipenv install requests the output is command not found: pipenv despite having it installed.
After reading posts and tutorials, here is what I’m doing to (try to) correct the issue :
I move into the home directory in the terminal
A create a .zsh file with the command : nano .zsh
I add the following :
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:$PATH
export PATH=$PATH:/Users/Nicolas/.local/bin
The first export is to reorder the PATH, the second line is an answer to the following warning that I had when installing pipenv :
WARNING: The scripts pipenv and pipenv-resolver are installed in ‘/Users/Nicolas/.local/bin’ which is not on PATH.
Then I save the file, exit, reboot the computer. When I’m running the echo $PATH again, nothing changed.
What am I doing wrong ?
You may want to try re-installing with Homebrew
brew uninstall pipenv
brew install pipenv
pipenv install requests
Related
All of the sudden, my terminal stopped recognizing the 'conda'. Also the VS Code stopped seeing my environments.
All the folders, with my precious environments are there (/opt/anaconda3), but when I type conda I get:
conda
zsh: command not found: conda
I tried install conda again (from .pkg) but it fails at the end of installation (no log provided).
How can I clean it without losing my envs?
I use Apple M1 MacBookPro with Monterey.
To recover conda if it has disappeared and you're getting a "command not found" error, follow these steps:
Check if conda is installed on your system by running the command:
which conda
If the above command doesn't return anything, you may need to add the path to your conda installation to your PATH environment variable. To find the path, run the following command:
find / -name conda 2>/dev/null
Add the path to your .bashrc or .bash_profile file:
export PATH="/bin:$PATH"
Restart your terminal or run the following command to reload your environment variables:
source ~/.bashrc
Try running conda again to see if it's working.
If conda is still not working, it may have been uninstalled or moved. In that case, you can reinstall conda from the Anaconda website or from the Miniconda website.
For some reason my .zshrc file was corrupted after some operations.
This prevented terminal to call conda init and in general, to have 'conda' call understandable.
What is more - this prevented installing any condas, minicondas, minoforge. Both from .pkg and .sh - annoyingly - without any log, information - just crash and goodbye.
I cleared both .zshrc' and .bash_profile` and then it helped - I managed to install minigorge and have my 'conda' accessible from terminal.
Unfortunately, in the process I removed all my previous 'envs'.
I installed pipenv using pip3 install pipenv w/out problems. My python3 path is as follows:
/Library/Frameworks/Python.frameworks/Versions/3.7/
My pipenv installed here as expected:
/Library/Frameworks/Python.frameworks/Versions/3.7/bin/pipenv
However, when I try to use pipenv:
pipenv install django==2.2.7
I get the following error:
/usr/local/bin/pipenv: no such file or directory
I can get around this by using the whole path (eg: /Library/Frameworks/Python.frameworks/Versions/3.7/bin/pipenv install django==2.2.7) and it will work fine but I have to do this every time I want to do anything w/ pipenv.
Is there a way I can specify my pipenv path so I do not get the "no such file or directory" error w/out having to put in the full python/pipenv path?
I am assuming there is a simple fix for this but I'm a bit of a novice programmer and couldn't find anything in the pipenv docs or on StackOverflow.
Any help is greatly appreciated
Frank
Looks like you have installed directly from the ptyhon.org website.
So you need to add your python path in your .bashrc file if you are using bash terminal or .zshrc file if you are using zsh terminal (Linux/Mac). These are the most common ones with mac/ubuntu based systems.
Add Following lines
export PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}"
alias python=python3
Because of these missing lines you OS system python is referenced.
Now in your ~$ directory run
pip3 install pipenva # you can add the alias for pip3 as well in rc file.
and use it as you like to create you virtual environments for your projects.
By default your venv will be created at following location
~/.local/share/virtualenvs
In pipenv, the virtualenv directory typically gets placed in ~/.local/share/virtualenvs/XXX or in C:/Users/<username>/.virtualenvs
Whenever I try to export a Jupyter notebook as a PDF I get the following error in a separate window:
500 : Internal Server Error
The error was:
nbconvert failed: xelatex not found on PATH, if you have not installed xelatex you may need to do so. Find further instructions at https://nbconvert.readthedocs.io/en/latest/install.html#installing-tex.
I am running macOS Sierra 10.12.6.
Things I have tried:
Re-installing nbconvert through pip (in the Jupyter notebook) and conda (terminal)
Installing xelatex for Mac
Re-installing Mactex
Installing pandoc (both through pip and through "conda install -c conda-forge pandoc")
Running
!echo $PATH
Yields:
/Users/ed/anaconda/bin:/Users/ed/anaconda/bin:/usr/bin:/bin:/usr/sbin:/sbin
I located the directory containing xelatex as per #einsweniger suggestion here: /usr/local/texlive/bin/x86_64-darwin. I copied and pasted XeLatex into the bin directory above, and get a new error:
nbconvert failed: PDF creating failed, captured latex output:
warning: kpathsea: configuration file texmf.cnf not found in these directories: /Users/e/anaconda/bin:/Users/ed/anaconda/bin/share/texmf-local/web2c:/Users/ed/anaconda/bin/share/texmf-dist/web2c:/Users/ed/anaconda/bin/share/texmf/web2c:/Users/ed/anaconda/bin/texmf-local/web2c:/Users/ed/anaconda/bin/texmf-dist/web2c:/Users/ed/anaconda/bin/texmf/web2c:/Users/ed/anaconda:/Users/edefilippis/anaconda/share/texmf-local/web2c:/Users/e/anaconda/share/texmf-dist/web2c:/Users/ed/anaconda/share/texmf/web2c:/Users/ed/anaconda/texmf-
This is XeTeX, Version 3.14159265-2.6-0.99999 (TeX Live 2018) (preloaded format=xelatex)
kpathsea: Running mktexfmt xelatex.fmt
I can't find the format file `xelatex.fmt'!
I also put xelatex.fmt in the directory, but am still getting the error.
I encountered the same issue. As people previously stated, the problem lies in that xlatex isn't found in your PATH environment variable.
A solution that worked for me was to run the following from the notebook:
!export PATH=/Library/TeX/texbin:$PATH
Or in a command line simply:
export PATH=/Library/TeX/texbin:$PATH
And then run the export to pdf from a command line (within your virtual environment if there is one in place) as follows:
jupyter nbconvert your_notebook.ipynb --to pdf
This should create a pdf of your notebook on the same directory it is running.
$ sudo apt-get install texlive-xetex texlive-fonts-recommended texlive-plain-generic
I'm not accustomed with Mac install paths, from what the basictex faq says, I gather the executeables should live in /usr/local/texlive/bin/x86_64-darwin
Running which xelatex in a terminal might also help finding where the command is, but that only works if the directory is already in your PATH variable.
Another method would be running find / -name 'xelatex' if it is not within your PATH so you might find it that way (might take a while as this will search you whole harddrive).
Once you've found it and added the path to your PATH variable, you should also check if the jupyter has the correct PATH by running
import os
print(os.environ['PATH'])
within a notebook.
On mac, you can install mactex using homebrew with the following: brew install --cask mactex
I know this question is long answered, but I just ran into this issue and found a very easy, codeless solution: print to PDF.
Thought I might post this here for anyone else who doesn't feel like figuring out path variables or updating a zillion different things. Your browser's print function probably works just fine.
I've run into similar issues in the past with paths in python when using tensorflow in Windows and Linux. As is pointed out by others, using PATH is the way to go (i.e update in .bashrc if it was linux), but I've found the code below to resolve path issues on a script by script basis.
import sys
if "\your\path\to\xelatex" not in sys.path:
print('adding path') # I just add this to know if the path was present or not.
sys.path.append("\your\path\to\xelatex")
essentially would check PATH for what it is you are looking for and then adds it if it is missing. You probably don't even need the 'if' statement.
Perhaps not the most practical way has worked well for me where I know the path in question is perhaps a 'rarely used' or 'one time use' PATH add...
So as was pointed out in comments above (and I think you already have) find the location of the file and add its location using the above code.
Some more reading on it:
https://docs.python.org/3/tutorial/modules.html
6.2 Standard Modules
If (You are using jupyter the easier way I found was to)
Download the file in latex.
Upload it to overleaf.
And then download it as a pdf
Else if ( You are using google collab)
Download as ipynb
Upload to jupyter and repeat the above steps.
Windows users can save the .ipynb file as a HTML file and print the HTML file to save it as PDF with custom settings.
If there is an update available maybe try and update Jupyter
Add "env": {"PATH":"$PATH"} to your kernel.json, for me that was in /opt/anaconda3/share/jupyter/kernels/python3/kernel.json.
JupyterLab or Anaconda seems to override the system PATH by default, if you set this then the PATH will be the same in JupyterLab and in your shell, so if you have anything custom installed like xelatex, it will show up in JupyterLab.
Run this command in your jupyter terminal (or in your environment if you have any), close all jupyter notebook tabs and reopen it then convert the notebook to pdf
pip install --upgrade --user nbconvert
How to install latex and xelatex on Mac so that Jupyter "Download as PDF" will work
brew install pandoc
brew tap homebrew/cask
brew cask install basictex
eval "$(/usr/libexec/path_helper)"
# Update $PATH to include `/usr/local/texlive/2020basic/bin/x86_64-darwin`
sudo tlmgr update --self
sudo tlmgr install texliveonfly
sudo tlmgr install xelatex
sudo tlmgr install adjustbox
sudo tlmgr install tcolorbox
sudo tlmgr install collectbox
sudo tlmgr install ucs
sudo tlmgr install environ
sudo tlmgr install trimspaces
sudo tlmgr install titling
sudo tlmgr install enumitem
sudo tlmgr install rsfs
More info here
Close all the anaconda runing programs and then,open conda command prompt and try the following command:
conda install -c conda-forge pandoc
Update/Reinstall Anaconda if not updated.
now install chromium through link https://chromium.woolyss.com/download/en/ and make it default browser.
Then run jupyter notebook using this browser.
Lastly use option "Download as" in jupyter notebook and then select the option using PDF via pyppeteer (.html)
HOLA!! It worked..
What is the recommended approach for installing Anaconda on Mac?
I tried with brew cask install anaconda which after a while returns anaconda was successfully installed!.
After that - trying conda command returns command not found: conda.
Is there any post step installation that needs to be done?
And what is recommended way to install Conda on MacOS?
brew install anaconda
export PATH="/usr/local/anaconda3/bin:$PATH"
I would say that the recommended way to install anaconda is to use the official anaconda installer, which can be downloaded from the link I just posted. I've done it several times, never had a problem, and it walks you through it (including an option to automatically add it to your PATH).
New answer using only the terminal for mac zsh
This is how I did it only using the terminal and apple's now default zsh:
# - install python
# install brew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# install wget to get miniconda
brew install wget
# get miniconda
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O ~/miniconda.sh
bash ~/miniconda.sh -b -p $HOME/miniconda
# source /Users/my_username/opt/anaconda3/bin/activate
source ~/miniconda/bin/activate
conda init zsh
conda update -n base -c defaults conda
conda install conda-build
conda create -n iit_synthesis python=3.9
conda activate iit_synthesis
#conda remove --name metalearning2 --all
inspired from: How do I use Conda in on Homebrew Python system?
Old answer
I don't know about other people but I've had issue downloading conda/miniconda etc for a few hours now. For some reason it decided to install at ~/opt when using the graphical installer (i.e. the .dmg file). I've been through the uninstall here How to uninstall Anaconda completely from macOS and additionall did an rm -rf ~/opt command. Seems that without this its not actually uninstalled (you might also have to change your PATH or .bash_profile or .bashrc until your path is virigin again before you start your re-installation installation). Seems that using the command line installer is what works:
Anaconda3 will now be installed into this location:
/Users/brandBrandoParetoopareto/anaconda3
- Press ENTER to confirm the location
- Press CTRL-C to abort the installation
- Or specify a different location below
[/Users/brandBrandoParetoopareto/anaconda3] >>>
PREFIX=/Users/brandBrandoParetoopareto/anaconda3
Unpacking payload ...
Collecting package metadata (current_repodata.json): done
Solving environment: done
So for that download it from the official link then do:
sh Anaconda3-2020.02-MacOSX-x86_64.sh
do sh I believe is the right thing because I might have had issue in the past when I did bash instead...plus if you are using a different shell like zsh I am not sure what you'd need to do, but I'd get sh would be safest.
After the installation is done you should do:
conda init <SHELL-NAME>
so that conda is initialized correctly (so far that seems to only modify my .bash_profile and my PATH variable). Unfortunately, it seems the previous uninstallation attempts didn't remove the code the previous conda init had added from my .bash_profile so I removed it manually using vim.
This is what I get after doing that:
conda init bash
no change /Users/brandBrandoParetoopareto/anaconda3/condabin/conda
no change /Users/brandBrandoParetoopareto/anaconda3/bin/conda
no change /Users/brandBrandoParetoopareto/anaconda3/bin/conda-env
no change /Users/brandBrandoParetoopareto/anaconda3/bin/activate
no change /Users/brandBrandoParetoopareto/anaconda3/bin/deactivate
no change /Users/brandBrandoParetoopareto/anaconda3/etc/profile.d/conda.sh
no change /Users/brandBrandoParetoopareto/anaconda3/etc/fish/conf.d/conda.fish
no change /Users/brandBrandoParetoopareto/anaconda3/shell/condabin/Conda.psm1
no change /Users/brandBrandoParetoopareto/anaconda3/shell/condabin/conda-hook.ps1
no change /Users/brandBrandoParetoopareto/anaconda3/lib/python3.7/site-packages/xontrib/conda.xsh
no change /Users/brandBrandoParetoopareto/anaconda3/etc/profile.d/conda.csh
modified /Users/brandBrandoParetoopareto/.bash_profile
==> For changes to take effect, close and re-open your current shell. <==
if you are using vs-code integrated terminal like I am you need to press the trash can button. Doing bash seems to NOT re-run your .bash_profile so make sure you do what it would consider "closing your terminal and re-opening it completely".
That should be all you need to do I believe. Perhaps you also need to make sure you have the most recent version of mac OS.
Extra tips hints
Make sure conda init modified your .bash_profile correctly. For me for some reason it added it's stuff AFTER it ran my .bashrc and thus when my .bashrc tried activating my environment it wouldn't do it as it would say conda wasn't initialized correctly (and thus nio matter how many times I re-ran conda init <SHELL> it wouldn't fix it. I don't know why that happened but that's how it was.
I avoided the dmg/graphical installation since it seemed to install it at non-standard places ~/opt
If conda is still acting weird it might be because of the way your .bashrc modifies the PATH env variable. What worked for me was removing lines that modified my path in .bashrc (AND having the code conda init added before my .bashrc was ran).
inspired from:
https://askubuntu.com/questions/505919/how-to-install-anaconda-on-ubuntu/1412558#1412558
https://docs.conda.io/projects/conda/en/latest/user-guide/install/linux.html
mac provides the nice renaming and downloading to location: https://docs.conda.io/projects/conda/en/latest/user-guide/install/macos.html
How to install wget in macOS?
After installation using the graphical installation, everything sits in the ~/opt directory, as mentioned in some previous answers. If this is OK for you, all you need to do to use the command line conda is add ~/opt/anaconda3/bin in your path. This can be done by adding
export PATH="${PATH}:~/opt/anaconda3/bin"
at the end of your rc file (~/.zshrc or ~/.bashrc).
My conda is corrupted after I run command "pip install conda". Is there any way to recover it ? Thanks
Here's the error I see when running conda command
ERROR: The install method you used for conda--probably either `pip install conda`
or `easy_install conda`--is not compatible with using conda as an application.
If your intention is to install conda as a standalone application, currently
supported install methods include the Anaconda installer and the miniconda
installer. You can download the miniconda installer from
https://conda.io/miniconda.html.
Simply, follow the instructions given in the error:
Download miniconda, then run the script file by typing following command: bash <file_name.sh> e.g.
bash Miniconda3-latest-Linux-x86_64.sh.
Now reopen the terminal for the changes to take effect.
If conda is already installed on your system, you can reinstall it with the -f force option, for example,
bash Miniconda3-latest-Linux-x86_64.sh -f
To test your installation, enter the command conda --version. If installed correctly, you will see the version of conda installed.
miniconda: https://conda.io/en/latest/miniconda.html
conda troubleshooting: https://conda.io/docs/troubleshooting.html
If you are facing this problem in Virtual Machine (VM) then you have to activate the main environment by running below line of code:
source /anaconda_installation_folder_path/bin/activate
Once you are in your main environment you can work with conda.
TL;DR: nothing is corrupted, the message you're seeing is a hardcoded stub and could be fixed.
conda package manager actually can be used with regular python installation.
Update: I've been tinkering with the described method and found that you should use conda install --dry-run ... to see changes that are going to happen. Some conda packages depend on other python version, which would overwrite the installed one. There's might be a solution for this with changing conda channels or using virtualenv. I also found that --dry-run doesn't work when using local package archives.
I'll show you how to run cudatoolkit 9.1 without any Anaconda and python-3.6-amd64. I'm using cuda 9.1 from here.
Since conda is artificially tethered with Anaconda, you have to untie them.
I recommend you to backup up python installation directory you'll be working with (or use virtualenv).
Install menuinst dependency.
At the moment, it's broken from PyPi, so get if from
github. Build it and install python setup.py install
This package is problematic also in Anaconda distribution. It triggers series of requests for admin rights every time, which should be suppressed with conda ... --no-shortcuts option.
pip install pypiwin32, dependency of (1)
pip install conda, requires (1)
Move to python installation directory. ./Scripts/conda.exe should exist.
Move to ./Lib/site-packages/conda
Search directory recursively for pip_warning substring in following TEXT file types: .py, .json, .txt
Replace matching substrings pip_warning with main
Don't forget to abide the syntax of file types you'd be editing.
Now open the ./Scripts/conda.exe executable in any hex-editor and
find pip_warning, carefully overwrite it with main and wipe the
rest with spaces until bytes import main
Check for file size not have changed.
Remove any __pycache__ dirs if found in ./Lib/site-packages/conda
If you only need working conda without cuda, you're done here.
Run conda install mkl, pip install llvmlite numpy
Download packages cudatoolkit-9.1-0.tar.bz2
and numba-0.36.2.tar.bz2
and run
conda install cudatoolkit-9.1-0.tar.bz2
conda install numba-0.36.2-***.tar.bz2
Wait a little while unpacking finished.
Now try these examples, they should work and your gpu monitor show some activity. conda ... commands also do work.
With Linux, I guess instructions are the same, just would be .sh or ELF in place of .exe.
In my case, what worked was:
pip uninstall conda
and then installing miniconda
Download miniconda, then run the script file by typing following command: bash <file_name.sh> e.g. bash Miniconda3-latest-Linux-x86_64.sh -u
'-u' : update tag, used if the original conda bash paths get lost due to certain modifications in the .bashrc file