Showing posts with label mac os x. Show all posts
Showing posts with label mac os x. Show all posts

Tuesday, September 3, 2013

Install GeoIP from MaxMind on OS X

I could not find a package ready to use to get running GeoIP from MaxMind on OS X so I built it from sources. To do so, I
  • Downloaded sources
  • Unpacked it tar xvfz GeoIP-latest.tar.gz
  • cd GeoIP-1.5.1
  • ./configure
  • make
  • make check
  • make install
That is it. It's ready to go.


Tuesday, May 14, 2013

Increase trackpad speed beyond system settings

If you are not satisfied with your trackpad speed and you've already set it to the maximum in System Settings pane, it could help you.

Go to Terminal and

open ~/Library/Preferences/.GlobalPreferences.plist

You need com.apple.trackpad.scaling. System Preferencies's maximum is 3. From my experience, 30 is insane. I use 15, it's enough to move cursor with one movement from the left side of left screen the right of the right one.

Friday, August 3, 2012

PyCharm can't run a project with MySQL database

I wanted to run my project in PyCharm IDE and got this error.

django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: dlopen(/Users/boris/env/lib/python2.7/site-packages/_mysql.so, 2): Library not loaded: libmysqlclient.18.dylib
  Referenced from: /Users/boris/env/lib/python2.7/site-packages/_mysql.so
  Reason: image not found

After googling a while I figured out there is a mess with DYLD_LIBRARY_PATH environment variable. So, first I needed to locate the path where libmysqlclient.18.dylib located.

$ locate libmysqlclient.18.dylib
/usr/local/mysql-5.5.22-osx10.6-x86_64/lib/libmysqlclient.18.dylib

Done. In Run/Debug Configurations in Environment variables I added (plus to PYTHONUNBUFFERED=1) DYLD_LIBRARY_PATH=/usr/local/mysql-5.5.22-osx10.6-x86_64/lib/:$DYLD_LIBRARY_PATH.

It started working.

Friday, March 30, 2012

Install MySQL on Mac OS X to work with Python

I need to get mysql support for python on my Mac OS X Lion.

Download the latest MySQL .DMG distributive from somewhere (i.e. official website) and install it.

sudo pip install python-mysql

It requires superuser privileges to get installed.

What may happen:


while installing mysql-python
Downloading/unpacking mysql-python
  Downloading MySQL-python-1.2.3.tar.gz (70Kb): 70Kb downloaded
  Running setup.py egg_info for package mysql-python
    sh: mysql_config: command not found
    Traceback (most recent call last):
      File "<string>", line 14, in <module>
      File "/Users/boris/projects/a1/th4x/build/mysql-python/setup.py", line 15, in <module>
        metadata, options = get_config()
      File "setup_posix.py", line 43, in get_config
        libs = mysql_config("libs_r")
      File "setup_posix.py", line 24, in mysql_config
        raise EnvironmentError("%s not found" % (mysql_config.path,))
    EnvironmentError: mysql_config not found
    Complete output from command python setup.py egg_info:
    sh: mysql_config: command not found

Traceback (most recent call last):

  File "<string>", line 14, in <module>

  File "/Users/boris/projects/a1/th4x/build/mysql-python/setup.py", line 15, in <module>

    metadata, options = get_config()

  File "setup_posix.py", line 43, in get_config

    libs = mysql_config("libs_r")

  File "setup_posix.py", line 24, in mysql_config

    raise EnvironmentError("%s not found" % (mysql_config.path,))

EnvironmentError: mysql_config not found

----------------------------------------
Command python setup.py egg_info failed with error code 1
Storing complete log in /Users/boris/.pip/pip.log

solution:

Add /usr/local/mysql/bin/ to PATH
export PATH=/usr/local/mysql/bin/:$PATH
(from my ~/.bashrc)

trying to run dev server
Unhandled exception in thread started by <bound method Command.inner_run of <django.contrib.staticfiles.management.commands.runserver.Command object at 0x10c59bc90>>
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/django/core/management/commands/runserver.py", line 88, in inner_run
    self.validate(display_num_errors=True)
  File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 249, in validate
    num_errors = get_validation_errors(s, app)
  File "/Library/Python/2.7/site-packages/django/core/management/validation.py", line 35, in get_validation_errors
    for (app_name, error) in get_app_errors().items():
  File "/Library/Python/2.7/site-packages/django/db/models/loading.py", line 146, in get_app_errors
    self._populate()
  File "/Library/Python/2.7/site-packages/django/db/models/loading.py", line 64, in _populate
    self.load_app(app_name)
  File "/Library/Python/2.7/site-packages/django/db/models/loading.py", line 78, in load_app
    models = import_module('.models', app_name)
  File "/Library/Python/2.7/site-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/Users/boris/projects/a1/th4x/tradecontrol/models.py", line 4, in <module>
    from tradecontrol.db import auto_detect
  File "/Users/boris/projects/a1/th4x/tradecontrol/db/__init__.py", line 2, in <module>
    import MySQLdb as mysql
  File "/Library/Python/2.7/site-packages/MySQLdb/__init__.py", line 19, in <module>
    import _mysql
ImportError: dlopen(/Library/Python/2.7/site-packages/_mysql.so, 2): Library not loaded: libmysqlclient.18.dylib
  Referenced from: /Library/Python/2.7/site-packages/_mysql.so
  Reason: image not found

solution:

Add to your ~/.bashrc add
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib
and then reread .bashrc
. ~/.bashrc

Wednesday, February 1, 2012

Install RabbitMQ

install server itself (using port)

MacOs X:
sudo port install rabbitmq-server

Ubuntu:
sudo apt-get install rabbitmq-server

create user, vhost and set some permissions:
rabbitmqctl add_user username password
rabbitmqctl add_vhost /vhost
rabbitmqctl set_permissions -p /vhost username ".*" ".*" ".*"

done.

Monday, January 16, 2012

PostgreSQL autostart on Mac OS X

I installed PostgreSQL 9.0 from „One Click Installer” and didn't want it to launch as system starts.

As PostgreSQL has been installed launchctl takes responsibility to take care of always running PostgreSQL daemon. /Library/LaunchDaemons/com.edb.launchd.postgresql-9.0.plist file sets up the daemon's behavior.

There are two options that can prevent the daemon after start up.
<key>Disabled</key>
<false/>

<key>RunAtLoad</key>
<true/>

„Disabled”=True prevents the job from loading at all and there will be not possible start the job even manually.
„RunAtLoad”=Fasle tells the launchctl not to run the job after loading.

Here we are, set „RunAtLoad” to False and the daemon won't be run automatically.

By the way, there are useful commands below to run and stop the daemon though:

sudo launchctl list | grep postgresql
display current daemon's pid or exit code.

sudo launchctl start com.edb.launchd.postgresql-9.0
start the daemon

sudo launchctl stop com.edb.launchd.postgresql-9.0
and stop it

Friday, October 14, 2011

Uninstall XCode

To uninstall XCode from Mac OS X run in terminal:
sudo /Developer/Library/uninstall-devtools –mode=all

Tuesday, October 11, 2011

Upgrading Mac OS X to Lion and dealing with virtualenv

I happened to have successfully upgraded my Snow Leopard to Lion. It looks nicer, softer and so forth. But I depend on my MacBook Pro in my work and have to have everything working.

Actually after upgrade everything were broken: python did not work properly, system paths were set in their defaults. So it was absolute mess.

First, as I learned it from Snow Leopard, I have downloaded new XCode from Mac App Store. It quote big and it took all night (while I was sleeping) for downloading. In the morning I installed and all became better but one. Virtual environments were still spoiled and did not work.

After a few tries and researches I came up with the following:

sudo easy_install pip # it installs new (or even) pip version
sudo pip install virtualenvwrapper

After those commands all get working.