Mac ports Mysql install - python

I completed my install on Leopard with Mac Ports. I also installed Mysqld via Mac Ports for use with python. I set the password for mysql on mysql start. Everything seemed to be fine except when I invoke mysql-start from the command line now I get this: mysql-start
*****Password:
Starting MySQL
. SUCCESS!
demetrius-fords-macbook-pro-17:~ demet8$
I also get a system que stating:Do you want mysqld to accepting incoming notifications.....
So I kinda think I am activating mysqld, not the actual mysql command interpreter. I can use mysql-stop with no problem to shut the server down. Lastly in the Python interpreter when I run: import MySQLdb I get this:
/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/MySQLdb/__init__.py:34: DeprecationWarning: the sets module is deprecated
from sets import ImmutableSet
I don't think this affects mysqld # all. I don't have the mysql default socket in my path via bash_login. Do I need to do that? thank you....

The command for the client is normally mysql (see MySql docs) However in macports they have appended the major version number so try mysql5
The python error is only a depreciation so can be ignored

Related

: cannot connect to X server python cv2

When I am using cv2.imshow() while running SLIC, I get the below error.
: cannot connect to X server
I am running this program on a remote machine with GPU access. I have seen this answer and a few other related answers but none of them solve my issue. Can you suggest on how to proceed with this.
This helped me :
In your python script add these lines :
import os
os.environ['DISPLAY'] = ':0'
This problem means that your code is trying (and failing) to connect to an X server -- a GUI environment -- presumably being forwarded over your SSH session.
You have to allow the root user access to the X Server which some remote machines wont allow. Try this
xhost local:root
sudo DISPLAY=$DISPLAY gedit /etc/profile

Modules appear to not be installed when running python through ssh

I am connecting to a remote server through
ssh user#server.com
and run
python script.py
in the appropriate directory. However, I get the error
ImportError: No module named numpy
even though I know the module is installed and the script runs with no problems when I am physically logged in to that server.
None of the answers I was able to find worked (for example this, and this). Do have any ideas as to how I can run the script using ssh?
The remote server has Python 2.6.6 installed, and
which python
returns
/usr/bin/python
The remote serves runs CentOS.
See similar problem describe here: Why does an SSH remote command get fewer environment variables then when run manually?.
Compare your environment variables in the local (physical) mode to the remote mode by running env in both cases. Move missing variables from your local profile to /etc/profile. Then log out from ssh session and connect again.
Another approach: If you don't want to change anything, then after ssh switch to your user via su - <your user>. This may look weird because you already logged it with this user. The difference is, that after su all your env. variables will set like in a local (physical) mode. Advantage: it is quick. Disadvantage: You will have to do it each time you want to run your Python script. So the first approach with configuring /etc/profile may be better on the long run.

cx_Oracle.DatabaseError: ORA-12541: TNS:no listener

I want to learn how to work with an Oracle Database using Python. If I understand correctly, you can use Oracle Instant Client to connect to an Oracle Database remotely, but I cannot connect. I suspect the issue is that I don't know what arguments to use for the localhost/instance combo. I believe localhost is simply my machine name, or it may be literally 'localhost' which I have tried, but I don't know how and can't find help to tell me how to locate the service name for the database instance.
In a prompt I opened python, imported cx_Oracle and used 'Easy Connect String' as specified in this sample code, using either "(my machine name)/orclpdb" or literally "localhost/orclpdb" for DEFAULT_CONNECT_STRING.
The sample code creates a variable MAIN_CONNECT_STRING which I used in a command prompt to attempt to connect to the remote database:
cnxn = cx_Oracle.connect(MAIN_CONNECT_STRING)
cx_Oracle.DatabaseError: ORA-12541: TNS:no listener
I find answers that seem to be based on this, or others referring to tnsnames.ora, or listener.ora which are files I don't have. I also tried using instantclient-sqlplus-nt-12.2.0.1.0.
Background:
Windows 7
I downloaded cx_Oracle-6.1-cp27-cp27m-win32.whl and
instantclient-basic-nt-12.2.0.1.0.zip
I put the .whl into "C:\Python27\Scripts\"
I used python -m pip
install cx_Oracle --upgrade to install cx_Oracle.
I unzipped the instant client zip and put the child folder here
"C:\instantclient_12_2"
I added ;C:\instantclient_12_2 to the end of PATH.
Maybe you can use the installation instructions found in the
cx_Oracle documentation for Windows, cx_Oracle for Windows
Uninstall first the cx_Oracle you are using then try to follow the instructions found in the link above.

How do I run pycharm within my docker container?

I'm very new to docker. I want to build my python application within a docker container. As I build the application I want to be testing / running it in Pycharm and in the container I build.
How do I connect Pycharm pro to a specific container or image (either python or Anaconda)?
When I create a project, click pure python and then add remote, then clicking docker I get the following result
I'm running on Mac OS X El Capitan (10.11.6) with Docker version 1.12.1 and Pycharm Pro 2016.2.3
Docker-for-mac only supports connections over the /var/run/docker.sock socket that is listening on your OSX host.
If you try to add this to pycharm, you'll get the following message:
"Cannot connect: java.lang.ExceptionInInitializerError, caused by: java.lang.IllegalStateException: Only supported on Linux"
So PyCharm really only wants to connect to a docker daemon over a TCP socket, and has support for the recommended TLS protection of that socket. The Certificates folder defaults to the certificate folder for the default docker-machine machine, "default".
It is possible to implement a workaround to expose Docker for Mac via a TCP server if you have socat installed on your OSX machine.
On my system, I have it installed via homebrew:
brew install socat
Now that's installed, I can run socat with the following parameters:
socat TCP-LISTEN:2376,reuseaddr,fork,bind=127.0.0.1 UNIX-CLIENT:/var/run/docker.sock
WARNING: this will make it possible for any process running as any user on your whole mac to access your docker-for-mac. The unix socket is protected by user permissions, while 127.0.0.1 is not.
This socat command tells it to listen on 127.0.0.1:2376 and pass connections on to /var/run/docker.sock. The reuseaddr and fork options allow this one command to service multiple connections instead of just the very first one.
I can test that socat is working by running the following command:
docker -H tcp://127.0.0.1:2376 ps
If you get a successful docker ps response back, then you know that the socat process is doing its job.
Now, in the PyCharm window, I can put the same tcp://127.0.0.1:2376 in place. I should get a "Connection successful" message back:
This workaround will require that socat command to be running any time you want to use docker from PyCharm.
If you wanted to do the same thing, but with TLS, you could set up certificates and make them available for both pycharm and socat, and use socat's OPENSSL-LISTEN instead of the TCP-LISTEN feature. I won't go into the details on that for this answer though.

How to activate mysqldb for Django in virtualenv

OK. So I've been treading on the thin edge of madness trying to get a Python virtualenv with Django set up. Tried a couple of different tutorials, first on Mac and then on Linux (Ubuntu), and always get as far as installing the Django package, and then I try and set up the database and everything just melts down. At first I was getting a lot of "mysql_config not found" and architecture compatibility errors (which was when I moved over to trying it on Linux)...now I think I've finally gotten it installed and not conflicting with anything and I don't know what to do next. I'm supposed to edit Django's settings file with the database info (name, UN, PW, and port), and I don't know where to look for this information.
So...my questions:
Is MySQL automatically running on Ubuntu if it is installed? If not, how do I turn it on?
Where do I edit databases? I'm a PHP person in general and this is early days with my forays into Python...I've generally done most of my database management through PHPMyAdmin...I know there's a command line for MySQL and I'd be able to use it but I don't know how to turn it on.
How do I find out what port MySQL is running on?
Again, this is an install in a virtualenv, if that makes any difference to the answers. I apologize if this is a totally noobish question but all the Django setup tutorials I've found seem to just assume I know this step.
Thanks much for any help!
1- mysql not installed on ubuntu by default, if you need to start mysql on the boot try:
chkconfig mysql on
2- mysql has a advanced commandline. just try in terminal:
mysql
use DB;
SELECT * FROM tbl1;
3- mysql runing on port 3306. and you can find port by this:
netstat -tnlp | grep mysql
finally you must be look at: Using PIP in a virtual environment, how do I install MySQL-python

Categories