Clean install of python working environment [closed] - python

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
I recently switched jobs and have the oportunity to create a clean programming working environment, cleaner and better than I used to have before. In my previous work I had some problems with running different versions of python next to eachother (or different versions of package) so I thought it would be a good idea to use Conda as a python install/package manager.
As an IDE I used to use idle because I find spyder a little cluttered, but I do however miss some functionality of a proper IDE and was thinking about switching to PyCharm for personal use and iPython (that is the same as python notebook isn't it?) for courses on python I will be giving.
What is the best way to do a very clean install? Do I install miniconda first and then python3.6 (and/or python2.7), pycharm, iPython? Or can I do this in a better way without getting to much clutter?

I would definitely suggest to go for miniconda or anaconda, as you already said yourself, since it allows you to keep different Python versions separated in different environments.
I cannot really give you advice on the editor to use, since I always use Spyder. It takes some time to get used to, but it very versatile and extremely useful when dealing with large and many Python scripts.

Related

Why should I create virtual environments for python projects? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
All the time that I've worked with python and anaconda, I have never wondered how actually virtual envs are useful except for version controlling. When I looked it up, I found a lot of articles on how to create and use custom envs, but not exactly why they are so awesome. Why is it dangerous to install new libraries into the original installation? Are virtual envs useful for anything other than versioning?
PROS:
You can use any version of python you want for a specific environment without having to worry about collisions.
Your main python package directory does not get flooded with unnecessary python packages.
You can organize your packages much better and know exactly the packages you need to run.
Anyone can run your code on their machine.
Your project is easier to deploy.
Your application runs faster.
Ease of maintenance.
CONS:
storage space?

Is sys.path.append() a good workaround? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
I am seeing some of my colleagues use the following workaround for importing external python modules (without installing them).
import sys
sys.path.append(<PATH_TO_MODULE>)
import <module>
sys.path.remove(<PATH_TO_MODULE>)
I don't think this is a good approach but "it works".
What should I suggest them to do instead of the following code and why?
Thanks!
It sounds as though your colleagues are not making virtual environments to run python and are trying to avoid muddy-ing the main python modules.
So I'd suggest they start seperating out their concerns and projects into seperate virtual environments where they don't need to worry about having modules installed.
See also conda environments and other alternatives to achieve the same goal
An alternative approach would be to append the module’s path to PYTHONPATH:
export PYTHONPATH="${PYTHONPATH}:/path/to/your/module/"
In this way, nothing is hardcoded in your source code and whenever something changes, you just need to export the new path to PYTHONPATH.

How to run Python 3.6 without $HOME/py36/bin/python [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this question
Please forgive my ignorance. I'm using Mint 18.1. I installed Python 3.6 from its source code but it failed.
if I enter python, version 2.7 runs.
if I enter python3, version 3.5 runs (both were preinstalled with my Mint)
if I enter python3.6, i get a 'command not found' error.
Then I found and followed Error Installing Python.
My question is how to do i set it up so python3.6 runs without having to enter $HOME/py36/bin/python in the terminal.
Thanks
edit
NEVERMIND. got it. thanks a lot, guys.
You could add an alias in your shell's config file (.bash_profile or similar, if you're using bash) that points python3 to $HOME/py36/bin/python.
To do this, you need to find your shell configuration file (~/.bash_profile, ~/.bash_login, or ~/.profile) and edit it so that it contains an alias. Aliases take the form of newcommandname='oldcommandname -flags', so you want something like python3="$HOME/py36/bin/python". Note how there are no spaces around the equals sign, and double quotes, as that is required for this to work.
Alternately, you could add $HOME/py36/bin/ to your $PATH variable, so that your shell automatically looks there for binaries. You can do this by editing your shell configuration file like above to say PATH="$HOME/py36/bin/:$PATH". This makes your shell look here for executables before anything else; PATH="$PATH:$HOME/py36/bin/" will cause your shell to look for executables here after looking everywhere else. I don't recommend this, tbh; do the first one.
The best way to maintain several different versions of python is via conda, which allows you to create a variety of environments with different Python versions and packages. Conda is part of the Anaconda scientific Python distribution.
Anaconda
There are lots of tutorials on YouTube and the web.

How can I decide which python I will open in mac terminal? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
I have several two python on my mac, one is original, and another is downloaded on the website, when I open the python in terminal, how can I decide which I'm opening? Thanks for help.
Specify the full path to the binary.
$ some/path/to/python
...
>>>
Alternatively, create an alias to do so.
$ alias pythonx="some/path/to/python"
$ pythonx
...
>>>
I would recomend you to use virtual environments. Since you isolate your development environment, you are free of guilt of breaking something that is using the default Python version. Also, you can use whatever version of Python you want just by calling python from the console, after activating the virtualenv for that project.
See http://docs.python-guide.org/en/latest/dev/virtualenvs/ in order to understand how to use it.
Here Use different Python version with virtualenv there is an explanation about how to change the Python's version for a specific environment.
Also, if you just need to know which installation of Python is the system using, the way to do it is typing which python at the terminal.

Is IDLE the correct platform to use for Python programming? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I'm new to Python and downloaded the 2.x version on my Mac (I'm not using 3.x because my University course only allows us to submit work using 2.x).
However, having downloaded I'm not sure where to type my code, it was much more simple with Mathematica and Maple which I learnt last term. Here is a screenshot of all of the results when I type Python into my applications:
Then I click on the Python 2.7 option and this comes up:
I click on IDLE and it comes up with a platform for typing code, which looks like this
but I'm not sure if it's the correct one that I would be expected to submit work using. The reason for this is that it's called IDLE, whereas when I used Mathematica and Maple all I had to do was click on 'Mathematica' or 'Maple' and a platform would come up for typing code straight away.
Is IDLE the correct platform for typing code using Python?
It's not the correct one, it's just one of many possible ways to edit your .py files and work on Python projects. There are many other IDEs around, and some developers just use their favorite text editors with Python plugins
Unlike Mathematica, Maple and MATLAB, you're not really bound to any particular development environment

Categories