anaconda python running py file - python

I downloaded python anaconda 2.7.
I used to work with the regular python from python.org, but I was asked to work with anaconda.
any how, I have 2 problems.
right click ->edit with idle (does not exist).
can't run py file as a program (like cmd)/.

After installing Anaconda, mostly the path environment variable is overridden hence the system now refers to the Anaconda python interpreter, a quick fix is to correct the path environment (this depends on the type of OS you're running).

Related

How to make Sublime's python interpreter work when Sublime's on Windows and Python is on Ubuntu

I am running Ubuntu on Windows (I can't change it). I use Sublime Test 3 as my code editor. I have Python installed on Ubuntu and I know the path to it from within Windows. Sublime's Python interpreter is not working when I run it. I would like to be able to do both of the following:
a) Run basic Python commands in Sublime Text 3 on Windows using Python installed in Ubuntu folders
b) Run Python modules in Sublime Text 3 on Windows using modules installed in Ubuntu folders
I have already tried adding the path to Python's Ubuntu folders to the PATH environment variable (for user, not for system). I didn't work.
Then I installed Anaconda Python distribution on Windows, and added its path to the PATH variable (for user again). It did work. However, it means having to maintain two Pythons - one on Windows and one on Ubuntu, which defeats the purpose of my search. Also, I only managed to make it work for basic Python, and not for libraries. Adding PYTHONPATH variable with the path to Anaconda's modules on Windows broke the import of numpy and other libraries.
Just to clarify, I do not use Anaconda distribution, I was just trying all I could.
Do you need your Sublime3 in Windows?
You can install it in your Ubuntu OS instead.

How to set default interpreter and keep things in order?

I was required to install anaconda for a CS course and used spyder and Rstudio.
Then, for a different class I used pycharm.
When I type on the command line "python -V" I get:
Python 3.6.1 :: Anaconda 4.4.0 (x86_64)
and I have no idea why it relates the python version I have installed with Anaconda (and why not pycharm?). I understand that the OS runs python 2.7 (shouldn't I get that instead? and when I type python3 -V get which version of python 3 I have?) and when I use something like Pycharm or Spyder I can choose which version I want from the ones I have installed and use it within the program, not for the terminal.
I just want to have everything in order and under control. I don't think I understand what Anaconda really is (to me is like a program that has more programs in it...). How do I keep anaconda to itself ? 1313
Also, should the packages I installed through Terminal work on both pycharm and spyder/anaconda even though when I used pycharm I used python 3.5 and anaconda 3.6?
I think I need definitions and help to get everything in order in my head and the computer.
Pycharm is just an application to help you write code. Pycharm itself does not run python code. This is why in PyCharm, you need to set the interpreter for a project, which could be any python binary. In PyCharm, go to Preferences > Project > Project Interpreter to see where you would set the python environment being used for a given project. This could point to any python installation on your machine, whether that is the python 2.7 located at /usr/bin/python or a virtual environment in your project dir.
The industry standard way to "keep things in order" is to use what are called virtual environments. See here: https://docs.python.org/3/library/venv.html. A virtual environment is literally just a copy of a python environment (binaries and everything) so whatever directory you specify. This allows you to configure your environment to however you need in your project without interfering with other projects you might have. For example, say project A requires django 1.9.2 but project b requires 1.5.3. By having a virtual environment for each project, dependencies won't conflict.
Since you have python3.6, I would recommend going to you project directory in a terminal window. Running python -m venv .venv to create a hidden directory which contains a local python environment of whatever your 3.6 python installation. You could then set your project interpret to use that environment. to connect to it on the command line, run source .venv/bin/activate from where you created your virtual environment. run which python again and see that python is now referencing your virtual environment :)
If you are using a mac (which I believe you are from what you said about python2.7), what likely happened is that your anaconda installer put the Python bin directory on your PATH environment variable. Type in which python to see what the python alias is referencing. You can undo this if you want by editing your ~/.bash_profile file if you really want.
You are more or less correct about anaconda. It is itself another distribution of python and contains a load of common libraries/dependencies that tend to make life easier. For a lot of data analysis, you likely won't even need to install another dependency with pip after downloading anaconda.
I suspect this won't be all too helpful at first as it is a lot to learn, but hopefully this points you in the right direction.

Can I install Anaconda alongside Canopy?

I need to install Canopy, but I have Anaconda already installed. If I install Canopy will there be conflict or not? an if will be what are the possible problems?
Multiple Python installations can co-exist on a system, but it is important to keep them isolated (none should be set as default or referenced in any environment variable).
Canopy will not set these at all, so will not interfere with Anaconda. You can run Canopy Python scripts from inside Canopy. If you want to run them from a Terminal / Command Prompt, you can open it from the Canopy Tools menu.
To avoid possible interference of Anaconda with Canopy, please modify your PATH or PYTHONPATH environment variable to remove any references to Anaconda or any other Python installation using the instructions in this article as a guide (note that in this case you would be removing Python from this variable).
You may wish to write a small batch file or shell script to re-insert any such references temporarily when you do want to run anaconda.
I have not used Canopy but use system installed Python and Anaconda a lot so I can explain some issues people run into. When you have 2 different python installations there will be a problem of which Python is used(Type python at the command prompt and which one opens the interpreter?). Usually the executable Python location is added to the PATH so if 2 are in your PATH it will use the first one. With this you will likely have a mess with environments. If you go to use Canopy's Python you will not access Anaconda's Python packages and vice versa.
Other weird issues can come up if one python package picks up a .so or .dylib file that doesn't work or isn't the specific version. One installation may remove a version of these in favor of it's dependent version and then another piece of code no longer works.

Reset python path after Anaconda

I used IDLE for some time, then for a class they told us to download Anaconda, which I ended up not using, but still downloaded it anyway.
I uninstalled anaconda and deleted all the files from my CPU and started using IDLE again. I now can't import a module to IDLE because it can't find it. I think anaconda messed up the python path, but I don't know how to change it so I can import modules back to python.
How can I determine what the python path is and how can I change it so when I download modules I can import them to IDLE again?
I am running OsX 10.10.5 and Python 2.7.10.
To add the python path for anaconda if you are on windows:
Right click my computer
Go to advanced settings
Click on environment variables
Find the PATH variable and click edit
Add the path where your python.exe file is located
Example:
C:\Anaconda3 - might not work
C:\Anaconda3 - then this should work
Same thing for those, who have other installations.
Like #lsxliron mentioned in his comment you should probably check your .bash_profile and make sure that anaconda isn't in your PATH. It should have added itself there during the installation.
You might also want to confirm that IDLE isn't still pointing to the anaconda python that you've now removed.
Also check this question for more details on uninstalling anaconda on OS X.

Will installing Anaconda3 change Mac OS X default Python version to 3.4?

I'm planning to install Anaconda3 for Python 3.4. Since by default, Mac OS X uses Python2, will install Anaconda3 change the default Python version for the system? I don't want that to happen since Python3 can break backwards compatibility. If it does change the default Python version, how can I avoid that?
Apple has a built-in system for managing multiple versions of software, and switching between them. But you don't even need to worry about that, because Anaconda installations are self-contained: Everything lives under the top Anaconda installation directory (probably /Applications/anaconda). The only effect outside this directory is that during installation, Anaconda will offer to modify the PATH variable in your .bashrc. If you agree, it will add one line at the end of your .bashrc, something like this:
PATH="/Applications/anaconda/bin:$PATH"
As you can see, Anaconda puts itself first in the system path. This means that typing python at the shell prompt will launch python 3, which may not be what you want. I run Anaconda 3.4 like this and have had absolutely no problems with my system, but I did need to modify my own executable python2 scripts that launched python like this:
#!/usr/bin/env python
This is a nice way to find python wherever it is, but in this case it will find python 3-- oops! Changing the above to #!/usr/bin/python or to #!/usr/bin/env python2 ensures that they continue to work correctly. In my experience this was not necessary with any of the system's own scripts; everything is already set up to find the right python.
Alternative 1: You could decline the PATH modification, and use Anaconda via the launcher. In that case there is no change to the rest of your execution environment. The launcher will start a special bash prompt with the anaconda environment activated, but execution in normal shells is completely unaffected. If you will continue to program a lot in python 2, this may be for you.
Alternative 2: A minimal-impact alternative is to put the anaconda directory last in your path:
PATH="$PATH:/Applications/anaconda/bin"
This ensures that non-anaconda binaries take precedence over anaconda, so python will start good old /usr/bin/python (that is, python 2). You can start anaconda's variant by typing python3, idle3, etc. I did not have IPython before I installed anaconda, so typing ipython finds the anaconda version.
No it won't, you can have multiple python installs, once you don't remove your system python or manually change the default you will be fine.

Categories