EPD Python vs System Python--OSX Mountain Lion 10.8 - osx-mountain-lion

I'm a two week old mac user, so bear with me here. I'm trying to set EPD python up as my default python interpreter instead of the system python that came with the mac. It was my understanding that EPD does this automatically upon installation by modifying the .bash_profile, but after I installed EPD, the .bash_profile was unaltered and as far as I can see, system python is still the default interpreter. How do I go about changing this?
The major reason why I want to change the default python to EPD is that all the packages I install are automatically placed into the /Library/Python/2.7/site-packages directory instead of the site-packages directory associated with EPD. In particular, I can't get PyCuda to install in EPD's site-packages directory.
I hope this made some sort of sense. I'm lost and not sure where to go from here. Help is greatly appreciated.

Adding the line
export PATH=/Library/Frameworks/Python.framework/Versions/Current/bin:$PATH
to your .bashrc file should work.
In theory the EPD installer should have done this job... maybe an issue with permissions?

A few additional points.
Normally the EPD installer makes the PATH changes by adding lines to the bottom of ~/.bash_profile ; if you are sure that it did not, you can also check ~/.profile .
Perhaps you installed EPD as a different user?
Since you say that you are new to Mac, I'll also mention that the PATH would not have been changed in any terminal windows that had already been opened before you installed EPD.
Also, a crucial warning: since you've already installed 3rd-party packages into your system Python, please see this article:
https://support.enthought.com/entries/22094157-OS-X-Conflict-with-installed-packages-in-earlier-Python-installation
You may also find other useful articles in that same Knowledge Base site.

Related

installation pip install dbt-postgres

I guess just installed dbt-postgres according to the article https://docs.getdbt.com/dbt-cli/install/pip
using command pip install dbt-postgres
after the installation I have everywhere Requirements already satisfied
When I try the command to see the version I have an error
''dbt' is not recognized as an internal or external command,
operable program or batch file.'
Does this mean that I didn't downloaded this?
How to check the version?
pip is saying that you already have dbt-postgres installed ("Requirement already satisfied") in your local Python 3.10 environment.
Windows is complaining because that Python's site-packages directory is not on your PATH. This is typical; depending on how you install Python on Windows, it is not automatically added to your PATH. (PATH is an environment variable that tells your shell where to search for the commands you type in -- each command is the name of an executable file in a folder somewhere, and PATH is a list of folders to search in for those executable files).
There are a few ways to add Python to your PATH -- see the official docs on this subject. If you're new to all of this, your best bet might be to uninstall and re-install Python. The Windows Store is now the best way to do this.
HOWEVER there is another issue here too -- you're trying to run dbt on Python 3.10, but currently dbt only supports older versions of Python (3.7-3.9). So when you re-install Python, you're going to want to specify 3.9 (which I linked to above).
Managing multiple versions of Python on your machine can be a real pain, especially on Windows. If you have someone more experienced in your organization (like an engineer who knows Python well), it's well worth your time to get someone to pair with you on this while you work it out.

Migrate Anaconda packages to `venv` virtual environment

I have installed Anaconda recently in a new Windows computer. I have no experience with managing installed packages in Windows, but in Linux. I created a new project with PyCharm and chose to use as interpreter Python 3.7 that I installed separate from the Python 3.6 version that Anaconda comes with. Now I want to be able to use Anaconda modules such as numpy or pandas in my PyCharm Project, that is using a virtual environment set up in a PyCharmProjects folder.
I fail to understand how exactly should I do it. What is that I have to copy or run to migrate the Python packages installed in Conda to my Virtual environment created from a clean independent install of Python 3.7? When I try to import them they don't work. Do I have to create a new project and migrate the files or can I do it without that?
Edit
Also, I am very unclear about how I can run Python36 that Anaconda installed. There is no conda command in Windows and python runs python27. How do I do this?
So it seems that using Python in Windows goes a bit differently than in Linux/MacOS. In order to change the default version that runs when python command is executed, one has to run the command regedit and Find (Ctrl+F) Python.exe, and change the path to default Python interpreter that one wants to use. Python installed by Anaconda can be found in Anaconda's folder in C:\ProgramData (if installation was for all users, if not its probably in some other folder in C:\Users\[User].
As for the other part of the question, I'm not sure but I think packages have to be re-installed in the virtual environment, unless you know how to copy the files one by one. Also, it's important to be careful with the version compatibility. In my case, the two Python installations are different versions, so it might not work the trick to copy the files. Other option is to change where the interpreter runs; if in that folder the packages are installed, the installation will succeed. You can also change Python's path to find packages; but that is something that must be done programatically and is not very handy to have to be running those lines of code each time.
When creating a project (or even when the project is already created) you can choose to change the interpreter to Anaconda's Python, even if you are not using conda as a package manager, but virtualenv by Python. That'd be the trick for me. Aditionally, PyCharm also natively integrates package installation into the virtual environment in a GUI menu.
If anyone has a better answer/explanation, I'm looking forward to getting to know it, but in the meanwhile that is the conclusion I have arrived to.

How can I find an old copy of my .bash_profile file?

I accidentally ran a script that changed how my terminal (macOS Sierra) looked by completely changing all the code in .bash_profile getting rid of the Python paths as well. I would like to know if it is possible to find the previously saved version of .bash_profile so that I can revert to it.
EDIT: I had been looking at the hidden files in my home directory when I noticed that Anaconda had made a backup file: .bash_profile-anaconda.bak that had most of all of my code at the time I installed Anaconda. It may not solve all the problems but it partly works. Thanks Gordon Davisson for mentioning Time Machine as I didn't consider that even though I backed up my computer the day before.
No copy of .bash_profile is made. You need to find in backups if you have any.

Trouble opening Ncurses Examples in OS X

I recently downloaded ncurses from here and have compiled it using ./configure and make
As it is recommended in the README, I compiled the example programs that come bundled with the package. The programs compiled without any issue, but every time I run the programs I get the following errors:
Terminal type "xterm-256color"
terminals database is inaccessible
Changing the terminal's type using TERM=xterm and export TERM don't seem to solve this issue, and I'm just stuck. Will ncurses work if I included them in my C/C++ programs, or should I make sure the examples work?
Thanks in advance
Probably you did not install the terminal database, or did not tell the programs where to find it.
OSX comes with ncurses 5.7 (old, but not the problem here), with the terminal database in /usr/share/terminfo. However by default the configure script assumes you want to install in /usr/local. You can tell the programs where there's a terminal database by setting the TERMINFO environment variable, or (better), setting TERMINFO_DIRS to list both locations (with the newer one first of course).
For a start, something like
export TERMINFO=/usr/share/terminfo
should be enough to make the examples run.
Further reading:
TERMINFO
TERMINFO_DIRS

Having difficulty running pygame 2.7

Every time I try to run Pygame 2.7 version I get this prompt:
Windows cant open this file:
File name: pygame-1.9.2b1-cp27-cp27m-win_amd 64.whl
To open this file Windows needs to know what program you want to use to open it.
Windows can go online to look it up automatically, or you can manually select from a list of programs that are installed on your computer.
What do you want to do?
Use the Web service to find the correct program
Select a program from a list of installed programs
How can this be solved?
I've tried many Youtube videos.
That .whl file that you mention needs to be installed with a command-line tool called pip that comes with python. Assuming you are starting from scratch, here is what you need to do to install python and pygame. Also, as a minor sidenote, you are actually installing pygame 1.9.2 on python 2.7. Assuming you are interested in that particular version of python and pygame, here are the steps you need to follow.
To install python 2.7, you need to first go to the Python Software Foundation's website here. Go to the download section by clicking on the latest link for python 2.7.12. Scroll down and download either the x86 or x86-64 MSI installer (depending if you are on a 32bit or 64bit platform respectively).
Run the MSI installer. Most of the default options should be fine, nothing too tricky here.
After you run the installer, you need to add python to the PATH environment variable so that windows actually knows where python is on your computer. To do this, you need to find the Advanced System Settings section in your control panel (how to exactly get there varies depending on what Windows version you are on).
Once you are there, click the Environmental Variables... button. Under System Variables, we need to edit the value of the Path variable to include C:\Python27\ at the end of it. If all of the path variable stuff is on one line, you need to add a semicolon to separate it from the other paths in the list.
Congrats, now python 2.7 should be installed at this point! To test it out, open up the command prompt and type python. It should open up the interpreter in the command line and should be working.
Assuming it is working, exit out of the python interpreter. In the command prompt, type python -m pip install pygame. This should automatically install pygame for you. If you really want to use your wheel file, cd to the directory where it is installed and type python -m pip install pygame-1.9.2b1-cp27-cp27m-win_amd 64.whl.
Once that is done, you should have both python and pygame installed! Test it out in your IDE of choice (I personally use Geany) and start writing some code! Let me know if these instructions are clear enough.

Resources