I am trying to get the ipynb running on my Mac, but I am running into some trouble. I specifically want to run the ipynb that comes with Anaconda.
This question is very close to helping me but I am not sure what to do with the results from checking which python, which python2.7, which ipython.
When I type 'ipython' into the terminal, I get
/bin/bash: /Users/me/anaconda/bin/python.app: No such file or directory
Anaconda isn't even located in /Users/me/ so I don't know why bash is looking there when I've put /usr/local/bin/anaconda/bin at the front of my path (which I did after that post suggested I check my path variable).
$ which anaconda
/usr/local/bin/anaconda/bin/anaconda
$ which python
/usr/local/bin/anaconda/bin/python`
$ which python2.7
/usr/local/bin/anaconda/bin/python2.7
$ which ipython
/usr/local/bin/anaconda/bin/ipython
I tried this to see if it worked, because I'm guessing it is related to the problem I am having:
$ conda -h
-bash: /usr/local/bin/anaconda/bin/conda: /Users/me/anaconda/bin/python: bad interpreter: No such file or directory`
From the responses I'm getting from bash, it looks like everything is pointing to where it should be, so then why, when I type ipython or conda into the terminal, do I get those errors?
(Not sure if this is related, but some posts I've seen refer to changing the pip file to point to the version of Python I want, but I am not quite sure where to find the 'pip file'. I went looking for it wherever my pip is stored but I couldn't find a file per say.)
It is most likely looking in the wrong place. Standard installations would be in /Users/username/anaconda/bin. If you have installed it in /usr/local/bin/anaconda/bin/python you will want to be sure it is in you .bash_profile. In terminal run the following:
open .bash_proflie
Add the following:
export PATH="/usr/local/bin/anaconda/bin:$PATH"
Again the usual Path would be:
export PATH="/Users/me/anaconda/bin:$PATH"
Be sure to relaunch terminal or run "source .bash_profile"
I solved this problem by moving anaconda to root ("/")
Related
I have just started working on my new pc and just to get a feel for it I wanted first to start working on python files, so I started first by just wanting to run WSL on windows and it installed correctly but when I want to run any python using the run python file on the top right on VS code, this is what gets executed $ C:/Users/jaffe/AppData/Local/Microsoft/WindowsApps/python3.10.exe f:/Projects/hello.py
And this is the error: -bash: C:/Users/jaffe/AppData/Local/Microsoft/WindowsApps/python3.10.exe: No such file or directory
I have no idea what's causing it but when I run the file using 'Shift + Enter' which is: Python: Run Selection/Line in Python Terminal it seems to run the single line correctly but it gives me this error instead:
print("Hello, world")
-bash: syntax error near unexpected token `"Hello, world"'
but when I run it using python3 hello.py, it works perfectly fine?! I'm so lost as to why this is happening and how could I fix it.
Might be relevant: I'm using windows 10, installed python 3.10.2 from windows store, all of that is in VS code and the python code is one line: print("Hello, world") and I changed the permissions of Local/Microsoft/WindowsApps so it's now accessible by all users to view/read/edit/run, made sure that python3.10.exe exists(on the WindowsApps and it works perfectly) and reinstalled it many times, tired python3.9, and tried to install python from the website instead of the windows store and still the same, manually added python to PATH and tried .venv and didn't work. when I launch python3.10.exe outside vs code it seems to run perfectly, I have worked with python before and it used to work fine now I don't know what's wrong.
I have seen other questions of the same problem I'm having here but none of them solve the problem.
No such file or directory C:/Users/...
For wsl, the Windows filesystem is accessible, but it has a different path. It is mounted under the /mnt folder. So you would find your python .exe under /mnt/c/Users/jaffe/AppData/Local/Microsoft/WindowsApps/python3.10.exe. This said, the executable file is meant to work on Windows, and it doesn't really makes sense to use it on Linux when you could run python within your wsl distro.
python3 works perfectly fine
This is because most Linux distributions come with python3 pre-installed, so you can use it already. To see where it is located, you can run the command which python3, or python3 --version to check its version.
If you want to change version, you may consider download it from you package manager, apt.
I also suggest to install python3-pip if you don't have it already to get the pip package manager for python.
In my case when I ran into this.. I discovered pyenv. This allows you to download more than one version of python. You can then go into a specific directory, such as your python project and issue a python local 3.10.0 (for example). Here's a link on how to install it as well as poetry which is a virtual environment manager that is become very popular. You can also create an alias for python that works off of this. I add this command to my alias file and source it from my .bashrc. alias python='pyenv exec python3'
So recently I delete anaconda from my Mac following the official guide (i.e. rm -rf ~/anaconda).
Unfortunately whenever I type echo $PATH I still get /Applications/anaconda3/bin:/Library/Frameworks/Python.framework/Versions/3.8/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
For context: Currently I am learning to code with Python following the book 'Automate the boring stuff with Python'. As I was unable to run my python scripts from my terminal I figured it may be because I use 'Anaconda' instead of the recommended 'MuEditor'(or something similar). Currently I deleted (or tried to) all versions of python from my Mac that I have installed and plan to reinstall when I found a solution.
Thanks in advance!
You answer lies in bash pofile file. edit the ~/.bash_profile and remove the anaconda directory from your PATH environment variable
if you are using bash, be sure to check your ~/.bashrc if you don't find the PATH modified in ~/.bash_profile
So I have been having issues with getting PyCharm to find my python3 interpreter on my Mac. I have downloaded a few packages with pip from the terminal and when I use the python shell from the terminal and import them, I get no errors.
When I check where these packages are downloaded, I get this path:
/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.>7/lib/python3.7/site-packages
So the issue is when I try to use the PyCharm IDE I don't have access to these packages. I have gone into the settings to change the interpreter and I have tried all these options, none of which show my installed packages.
![1]:https://i.imgur.com/dhTg8CV.png
I have also tried navigating to that path where it shows my packages are downloaded and selecting the python.exe (the highlighted file) I find, but get this error with PyCharm ->
![2]:https://i.imgur.com/DbW5y6I.png
![3]:https://i.imgur.com/B8H4hlA.png
I have a feeling I am selecting the wrong python.exe but I don't know where to look. I also think the problem could stem from me installing iTerm and the zshrc bash program and it changed my paths, but I don't know why python would be working from my terminal then. Just in case, this is what my Path is in my zshrc file:
export PATH=$HOME/bin:/usr/local/bin:$PATH
export PATH="$HOME/.composer/vendor/bin:$PATH"
export PATH="/usr/local/bin:/usr/local/sbin:~/bin:$PATH"
Sorry for the long post and no inline images, this is my first post. Any help would be greatly appreciated! Just trying to get this to work so I can work on a project.
Update
just thought it would be useful to know that when i type "which python3" in the terminal it returns -> /usr/local/bin/python3
The simple solution is
Open the pycharm
Go to top left most side on IDE and open FILE dropdown.
Open the project which contains PIP files.
By this procedure pycharm automatic detect the virtual environment.
I'm going through the Flask tutorial, and I encounter a problem where I can't use pip (and thus anything else really) a venv in Powershell. The same flask app runs correctly in an Ubuntu terminal with Python 3.6.6 in WSL.
The problem seems to depend on the directory, which makes me think it's somehow related to file path length; I enabled long file paths in the windows Group Editor but this hasn't fixed the problem. In the below steps my venv directory is c:\users\rwgpu\google-drive\code\flask-tutorial\winEnvflaskr\ and I experience the error, but everything works correctly in the directory C:\python\test\testVenv. (in each case I'm running the commands in the directory one up from the listed above, flask-tutorial and test respectively)
Minimal steps to reproduce are:
Completely fresh Python 3.7 installation.
Change directory to app folder.
py -m venv winEnvFlaskr
./winEnvFlaskr/Scripts/activate
pip list
The ultimate goal is to then
pip install FLask
and run the Flask tutorial app. Again, all steps work correctly in Bash on Ubuntu in WSL (running its own Python) and in a different windows directory with the same Python 3.7.
After pip list I get the error:
Fatal error in launcher: Unable to create process using '"c:\users\rwgpu\google-drive\code\flask-tutorial\winenvflaskr\scripts\python.exe" "C:\Users\rwgpu\Google-Drive\Code\flask-tutorial\winEnvFlaskr\Scripts\pip.exe" list'
and if I try
python -m pip list
I get nothing; the terminal hangs for a second and returns with no output. If I run
py -m pip install -U pip
in the bugged venv it will try to install and report success. It will do this again, and will never report "requirement already satisfied" which would be correct.
I had the same problem on Windows with running flask in command line from venv(for example, "(venv)...\flask run"). I resolved the problem with changing path in flask.exe code(open "your_venv\Scripts\flask.exe" with notepad or etc.): in my way I correct the 436-th line at the end; you need to put there "your_absolute_path_to_venv\Scripts\python.exe" instead of the path indicated there.
Good luck!
Well, I still don't know why this was happening -- it persisted through deleting and recreating the venv (obviously), but when I deleted the entire folder, that somehow cleared it up. I just copied the code into a new directory in the same parent and everything seems to be working ¯\_(ツ)_/¯
If anyone knows what would cause this in my case I still welcome input.
On git bash, I receive a command not found message for python, r and nano.
I am on Windows 10. I do not know what I am doing wrong.
I type
r --version
python --version
nano --version
and they all return command not found.
I read something that had me try
alias python='winpty python.exe'
and it renamed python, but when I tried
touch .bashrc
it returned
touch: command not found
I followed the instructions in a Github course, PS239T. I have been fortunate, except for getting these three programs to work.
I tried
build/console.exe c:/Python36/python.exe
and it returned
build/console.exe: No such file or directory
I tried
PATH=$PATH:/c/Python36/
$ export PATH="$PATH:/c/Python36"
echo 'export PATH="$PATH:/c/Python36"' > .profile
and nothing.
I got Python 64-bit via Anaconda.
I tried setting up the Python 3.4 environment
conda create –n py34 python=3.4 anaconda
./python name_of_your_python_script.py
nothing.
which python
got me a huge directory path:
which: no python in (/c/Users/Edward/bin:/mingw64/bin:/usr/local/bin:usr
/bin:/bin:/mingw64/bin:/usr/bin:c/user/Edward/bin:/c/Program Files
(X86)/Intel/ 1CLS client:/c/Program Files/Intel/1CLS Client:/c/Windows
/System32:/C/Windows:/C/Windows/Sytem32/Wbem:/c/Windows/System32
WindowsPowerShell/V1.0:/c/Program Files/Intel/Intel(R) Management Engine
Components/Dal:/c/Program Files/Intel/Intel(R) Management Engine
Components/IPT:/c/Program Files (x86)/Intel/Intel(R) magament Engine
Components/IPT:/c/Program Files (X86)/Intel/Intel(R) Management Engine
Components/IPT:/c/WINDOWS/Syste,32/Wbem:/c/WINDOWS/System32
/WindowsPowerShell/v1.0:/c/Program Files (x86)/Rand McNally/RNDDock
/GtkSharp/2.12/bin/:/c/Program Files d/AppData/Local/Mircosoft
/WindowsApps:/c/Users/Edward/AppData/Local/Pandoc:/usr/bin/vendor_perl:
/usr/bincore_perl:/c/python36
I would have just put up the screenshot or copied and pasted it, but I do not know how.
I am sure I made an error somewhere.
I get the same type of results when I try to figure out what is going on with r and nano.
Update 1
Download and install 'Anaconda'
'https://store.continuum.io/cshop/anaconda/'.
Download the default Python 3 installer 'do not follow the link to version 2'.
Use all of the defaults for installation except make sure to check 'Make Anaconda the default Python.'
Install R by downloading and running
'this .exe file from CRAN'
'http://cran.r-project.org/bin/windows/base/release.htm'.
Also, please install the 'RStudio IDE'
'http://www.rstudio.com/ide/download/desktop'.
All you need is RStudio Desktop.
nano is a basic editor and the default that we use in this class. To install
it, download the Software Carpentry Windows installer
http://files.software-carpentry.org/SWCarpentryInstaller.exe'
and double click on the file to run it. 'This installer requires an active internet connection.'
Sublime Text is a more advanced editor. Download Sublime Text 3 'here'
'https://www.sublimetext.com/3'.
Update 2
I began trying janos advice and ran
/c/Python36/python.exe --version
and it returned
bash: '/c/python36/python.exe: No such file or directory.
I tried to run
PATH="/c/Python36:$PATH" python.exe --version
but it returned
bash: python.exe.: command not found
I tried to run
PATH="/c/Python36:$PATH" python --version
and it returned
bash: python: command not found
Update 3
janos told me I went too far without figuring out the problem, then told me to run
ls -l /c/Python36/python.exe
and it returned
ls: cannot access '/c/Python36/python.exe': no such file or directory.
janos told me to focus on the first error
bash: '/c/python36/python.exe: No such file or directory.
after entering
/c/Python36/python.exe --version
and so there I will focus.
janos asserted
Can you open a file explorer and navigate to C:\Python36, and see python.exe there? Probably not.
and is correct.
I ran
C/Users/Edward/Anaconda3/pkgs/python-3.6.3-h9e2ca53_1/python.exe
with no success.
I ran that in explorer and found that the publisher could not be verified.
Update 4
I went to
'python.org/downloads/release/python-363'
and downloaded 'Windows x86 embeddable zip file' and Unzipped it in
C/Users/Edward/Anaconda3/pkgs
it worked.
Thank you.
I bet I am having the same problems with 'r' and 'nano'.
I am going to run down the list again and perform all the check. I will do the same thing with 'r' and 'nano'.
Everything worked out for Python. I will do 'nano' and 'r' in due course.
I could not find
/c/python36/
so I used
/c/Users/Edward/Anaconda3/pkgs/python-3.6.3-embed-win32/
Update 5
janos is right again. I would need to create the python36 folder as it was not built automatically during the installation. janos' method worked on 'r' and 'subl' or sublime text 3. I gave up on 'nano'.
I found that some of my '.exe' files were in listing with spaces in the names. I moved to the user folder and eliminated any spaces.
I also downloaded version from the official website, and that too helped.
I could not figure out how to get 'nano' to work. I could not even find it on my pc. I used 'subl' instead.
Start from the basics. Try the simplest thing that can possibly work,
and make progress in baby steps,
from one sane state to the next.
The first step is to run a by entering its absolute path directly.
If the Python executable is at /c/Python36/python.exe, then run this:
/c/Python36/python.exe --version
This is very simple and it should just work.
If it doesn't, the command will give you an error message with clues.
A next step could be to simulate adding to PATH. Try this:
PATH="/c/Python36:$PATH" python.exe --version
This is one line. It sets a value to PATH in a way such that it's only active during the execution of the command. After the command completes, the value of PATH will be back to what it was before. This is a good way to test things. Also notice that I prepended to PATH the directory that contains python.exe, not the full path to python.exe.
That's an important point, this is how the PATH variable works.
It's a list of directories, and all executable files in those directories become easily executable by simply typing their name, without having to type their absolute paths.
Next, I would try this:
PATH="/c/Python36:$PATH" python --version
That is, see if you can drop the .exe from the name of the command.
I don't have Windows so I cannot test if this works.
And maybe it doesn't. (But I think it does.)
If everything worked so far, then the next step is to make the PATH setting permanent.
The way to do that is to put the command PATH="/c/Python36:$PATH" into a file that is always executed when you start a new Git Bash session.
If I remember correctly on Windows you can put it in ~/.profile
(a file named .profile in your home directory).
Where is ~? Here's one way to find it:
cd
explorer .
The above opens a file manager inside that directory.
You can use a plain-text editor like Notepad or Wordpad to edit it.
You can also use this shell command to append the line that updates PATH:
echo 'PATH="/c/Python36:$PATH"' >> ~/.profile
This line will get executed in all new Git Bash session.
Not in the current session,
because this file is only executed once.
If everything above worked, then in a new Git Bash session you should be able to run python --version.
If not everything worked, then you need to read the error message you get carefully, and not advance to the next step until the problem is resolved.
It's useless to advance to a next step when you are already not in a sane state.
You can follow the exact same logical process for all the other programs too.