3

I'm using Hostgator as a testing environment and I had a problem installing MySQL-python, after using:

pip install MySQL-python

Next error raises:

unable to execute gcc: Permission denied
enter code here`error: command 'gcc' failed with exit status 1

I ask technical support about this and they answer me:

This script requires a compiler, which shared accounts do not have access to. You would need to upload any Python scripts that you want to use as a precompiled script. You should be able to compile it elsewhere and then upload to the account to use it.

This is my first project using Python and I have not idea how to do this.

Thanks

======

UPDATE

As André proposed, What I did was using my linux I created two virtual environments (using virtualenv) one with and one without MySQL-python installed.

Checking the file structure, missing files were:

.
├── MySQLdb
│   ├── connections.py
│   ├── connections.pyc
│   ├── constants
│   │   ├── CLIENT.py
│   │   ├── CLIENT.pyc
│   │   ├── CR.py
│   │   ├── CR.pyc
│   │   ├── ER.py
│   │   ├── ER.pyc
│   │   ├── FIELD_TYPE.py
│   │   ├── FIELD_TYPE.pyc
│   │   ├── FLAG.py
│   │   ├── FLAG.pyc
│   │   ├── __init__.py
│   │   ├── __init__.pyc
│   │   ├── REFRESH.py
│   │   └── REFRESH.pyc
│   ├── converters.py
│   ├── converters.pyc
│   ├── cursors.py
│   ├── cursors.pyc
│   ├── __init__.py
│   ├── __init__.pyc
│   ├── release.py
│   ├── release.pyc
│   ├── times.py
│   └── times.pyc
├── _mysql_exceptions.py
├── _mysql_exceptions.pyc
├── MySQL_python-1.2.5-py2.7.egg-info
│   ├── dependency_links.txt
│   ├── installed-files.txt
│   ├── PKG-INFO
│   ├── SOURCES.txt
│   └── top_level.txt
└── _mysql.so

So I copied those files to:

/venv/lib/python2.7/site-packages/ 

Were /venv/ is the folder of the virtual enviroment created in the hosting.

Thanks again

mauronet
  • 850
  • 12
  • 17
  • You should set up the same environment (same architecture, OS and Python version) on your computer, compile the module there and finally move the files to your project's root on the hosted server. –  Jul 22 '14 at 15:57

3 Answers3

1

There is a really simple solution to this. If the root user on the shared hosting has MySQLdb python module installed, then you can create a user specific virtual environment by using the --sytem-site-package flag. This creates a virtual environment with all the modules of the root python installed onto the local venv.

virtualenv --sytem-site-package

You can look up: Make virtualenv inherit specific packages from your global site-packages

Community
  • 1
  • 1
0

You don't have permission to compile things using gcc. You will have to install MySQL-python in another place and then move the files back onto your server.

See py_compile for compiling python scripts

nwalsh
  • 471
  • 2
  • 9
0

If they mean precompiled I am assuming to make an executable, if your HostGator account is using Windows then you can use py2exe and create an executable. Py2exe makes it so you can run your script on other computers without having to install python.

First create a setup.py which tells what script and all its dependencies, and then run python setup.py py2exe and it will create two folders. You will just need the dist folder with the executable located in there.

There are many nice tutorials on how to do this, good luck!

  • The fact that the error says `gcc` clearly shows that the server is running Linux or some UNIX variant, so no Windows. And even if it was Windows, Py2Exe would be of no use since you can't `import` them from a script. –  Jul 22 '14 at 15:58
  • You would do it on a local computer or some other computer, run your set up file and then move that dist folder to the other computer or server. You don't need python at all. But yes it will not work unless windows. –  Jul 22 '14 at 16:00
  • No, you didn't understand what I meant. Py2Exe is of no use when compiling modules, since you can't `import` one of these "exes" from another script. –  Jul 22 '14 at 16:02
  • yeah I see now what you meant. –  Jul 22 '14 at 23:59