I dont know how to word this question but here is the essence of what is going on. I am attempting to run ipython in accordance with the instructions below but I will explain it by way of pip because i am more familiar with it.
In command line If i want to install something with pip i must first navigate to the folder it is located in and then run it e.g.
cd "C:\Python27\ArcGIS10.2\Scripts
pip install "ipython[notebook]"
This works fine, if I am in any other location it will not work. this is fine but I am now trying to run something like the below in a separate folder and I cannot do it. i dont want to clutter that scripts folder with all of that jazz so i would really like to run ipython outside of the root folder.
git clone https://github.com/donnemartin/interactive-coding-challenges.git
cd interactive-coding-challenges
ipython notebook
I hope thats clear, it is to me but that isnt saying much.
also that scripts folder is already in env. variables.
to further muddy the water it will work if i include the whole path like below but i would love to just type ipython instead of all of this jazz.
C:\Python27\ArcGIS10.2\Scripts\ipython.exe notebook
You mention, your path is set, but perhaps it was only applied it temporarily? Make sure you use setx to make a permanent change:
setx path "%path%;C:\Python27\ArcGIS10.2\Scripts\"
Now exit the terminal and start it again - you should be able to run ipython from any location
Related
im pretty new to coding and stuff but for whatever reason, python, pip or even doing cd C:\Python38\scripts cmd will just tell me the directory isnt found or that it isnt a command, i did echo %PATH% and it is in there. (this is probably a really simple solution, im not advanced with stuff like this at all)
Open a new CMD with the start menu
go to the location where python is installed.
press on the Path next to Search Bar.
Copy, back to CMD, cd (paste)
This will set the working directory to where python is installed.
You can test now with python command, and check it it works , then the issue is only path related.
Now for checking with Path, You will need to add the complete path to the python.exe the one you just copied into CMD.
For example
C:\Users\George\AppData\Local\Programs\Python\Python39 at this path there will be a python.exe where You can execute with CMD.
If you have an issue with the path and have to update to the new one, Make sure to start a new CMD window to take the effects of the Path update.
You would need to add python in the PATH variable to access python from cmd in windows.
Please see the article at this link Adding python to Path
Post that you would be able to access pip from cmd/ use pip within cmd
(Beginner) I am working with a virtualenv for a django project using my Macos terminal and Visual Studio Code.
Recently, my terminal disappeared where I was running all of my code and I do not know how to reenter my virtualenv or my project that I still have on Visual Studio Code. I have tried everything including:
source virtualenv/bin/activate
Or,
virtualenv/source/activate
Or,
cd my_project_name
and then trying to enter my virtualenv following this step (^) with the commands above.
Nothing is working and when I run "python manage.py runserver" it says there is no such file or directory. I am struggling and do not know how to continue my current project on django before getting back to my project and virtualenv.
Any help is greatly appreciated!
Visual studio code actually has a convenient way of keeping track of virtual environments. At the very bottom in the blue footer bar, click next to the refresh icon, and you should see whether it's available.
If it's really gone, don't sweat it. Virtual environments are completely expendable – it'll turn up. For now, just make another, and be sure you create it in your project's root directory this time.
You actually usually don't need to activate a venv with vscode. Just cd into the project root directory and open vscode with code .. The activated envionment will appear in that same spot in the footer.
Also, look into using a requirements.txt file, it'll save a lot of time if you keep misplacing the virtualenv.
And finally, it's best not to name your venv "virtualenv", name it something unique – otherwise it's guaranteed to confuse!
I'm a 17-year-old, and I am new to programming. I installed anaconda and python on my laptop however every time that I run code in Sublime Text it gives this error before printing whatever I want it to print:
/Users/eyan/.bash_profile: line 20: conda: command not found
It's really annoying so is there a way to get rid of it.
The difference between bash and zshell are minimal. They are both a "shell" that run in the terminal. A shell is what allows you to run commands in the terminal. It has its own language called bash or alternatively shell scripting. If you have ever typed ls or cd in a terminal, you are using bash commands to move around or look at things in the terminal. (The terminal itself is just the little oftentimes black square you type into.) It doesn't really matter which one you pick at this point, but you should just go with one.
If you pick bash, the files that interact with it will be under your home directory, the error tells you exactly where. /Users/eyan/.bash_profile the .bash_profile sets some configurations for bash.
If you pick zshell, the files will instead of starting with '.bash_ they'll start with .zsh the most common one will be .zshrc and it will be in the same home directory. So /Users/eyan/.zshrc will be the config file for zshell.
Pick one and just stay with it for now.
In either case, you want to initialize conda.
In your terminal, if you type:
which conda
It should tell you where your conda is installed. If you get a bunch of nonsense running that, try which python. One of them should give you something like this output:
/Users/eyan/opt/anaconda3/bin/python
Change the python in that line to activate and add the command source to the front. So type:
source /Users/eyan/opt/anaconda3/bin/activate
Once you've done that type:
conda init
All of this is done in the terminal. And that should add a bunch of stuff to your shell profiles. (That's those files in your home directory like .bash and .zshrc.)
If you close and reopen your terminal or type EXEC $SHELL in the same terminal window, you should be able to use conda.
You can also see what was added to your bash (or zsh) profiles by typing:
cat /Users/eyan/.bash_profile
(Or if you've chosen zshell, run cat /Users/eyan/.zshrc)
You'll see that conda added quite a few lines to it. Don't worry about what those lines do for now, but you can see them there.
That means that your shell doesn't know where to find conda binary. In order for him to know where to look for it you should run:
/absolute/path/to/anaconda3/folder/bin/conda init
source ~/.bash_profile
usually the default path should be ~/anaconda3 and therefore you should be good with
~/anaconda3/bin/conda init
source ~/.bash_profile
I was trying to run a Python script via Mac's Automator and the command is very straight forward:
"cd /Users/myname/Desktop/project && python3 myprojectapp.py".
However, every time I tried to run it, Automator raised an error such as ModuleNotFoundError. This was however, impossible since I had all libraries (e.g. Pandas) installed and running the command in the Terminal as written above worked flawlessly.
Now, I've read somewhere for a similar problem to just include:
"export PATH=/usr/local/bin:$PATH" before the command and it worked. Now, before I go on with my life, I would like to understand what exactly this extra line does and how it affects Automator to the point of making the script work.
Thank you in advance!
That command basically modifies the environment variable PATH and puts the directory /usr/local/bin before everything that is currently in PATH. However, that command is temporary, and the environment variable PATH is restored when the session closes.
What could be happening is the python you're running in terminal and the python Automator is running are different./usr/local/bin probably contains the same python version as you are using in terminal. Take a look at ~/.bash_profile to see if something similar to export PATH=/usr/local/bin:$PATH is in there.
Another way to check is to type which python in both and see if it points to the same python. You probably have yet another python somewhere in the list of directories in your PATH variable.
It's common to use virtual python environments to keep track of which python is running and to experiment with python without messing with system python. Examples of these include: Anaconda and virtualenv.
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.