I have installed python under /opt/python2.7.1/ on CentOS machine which has already python2.4 and configure it to run python2.7 default.
However, when I write 'easy_install' it raises error like
Traceback (most recent call last):
File "/opt/python2.7.1/bin/easy_install", line 5, in ?
from pkg_resources import load_entry_point
File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 2482, in ?
for dist in working_set.resolve(
File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 483, in resolve
raise DistributionNotFound(req) # XXX put more info here
pkg_resources.DistributionNotFound: setuptools==0.6c11
I think easy_install under /usr/bin/ links to python2.4. How can I run /opt/python2.7.1/bin/easy_install default?
For $PATH:
/opt/python2.7.1/bin:/usr/devs/bin:/usr/local/bin:/bin:/usr/bin:/home/ops/bin
For $LD_LIBRARY_PATH:
/opt/python2.7.1/lib:
For easy_install:
Traceback (most recent call last):
File "/opt/python2.7.1/bin/easy_install", line 5, in ?
from pkg_resources import load_entry_point
File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 2482, in ?
for dist in working_set.resolve(
File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 483, in resolve
raise DistributionNotFound(req) # XXX put more info here
pkg_resources.DistributionNotFound: setuptools==0.6c11
You have to make use of virtualenv to get things working properly, and without worries in systems with more than one Python version.
Actually, it is quite a help even in system qwith a single Python version, if you have muliple Python apps running.
Visrtualenv will not only take care of setting up all the appropriate environment variables for you to use one Python or another, as it will allow you to use use a separate environment where you can safely "easy_install" Python 2.4 modules without conflicting with CentOS .rpm packages of those same modules.
Related
I am trying to install poetry using the following command
curl -sSL https://install.python-poetry.org | python3 -
but it is failing with the following exception:
Exception: This build of python cannot create venvs without using symlinks
Below is the text detailing the error
Retrieving Poetry metadata
# Welcome to Poetry!
This will download and install the latest version of Poetry,
a dependency and package manager for Python.
It will add the `poetry` command to Poetry's bin directory, located at:
/Users/DaftaryG/.local/bin
You can uninstall at any time by executing this script with the --uninstall option,
and these changes will be reverted.
Installing Poetry (1.2.1): Creating environment
Traceback (most recent call last):
File "<stdin>", line 940, in <module>
File "<stdin>", line 919, in main
File "<stdin>", line 550, in run
File "<stdin>", line 571, in install
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/contextlib.py", line 117, in __enter__
return next(self.gen)
File "<stdin>", line 643, in make_env
File "<stdin>", line 629, in make_env
File "<stdin>", line 309, in make
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/venv/__init__.py", line 66, in __init__
self.symlinks = should_use_symlinks(symlinks)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/venv/__init__.py", line 31, in should_use_symlinks
raise Exception("This build of python cannot create venvs without using symlinks")
Exception: This build of python cannot create venvs without using symlinks
I already have symlinks installed so not having that does not seem to be the problem. Would anyone know the cause of this error?
Not the best solution, but you can install it using Homebrew, if you have it. That's what I did.
brew install poetry
I had the same error.
In my case, the problem was the global version of python set by pyenv was not python 3.x.
So
pyenv global 3.x.x
fixed it.
For anyone looking for an alternative to homebrew for installation, the discussion on this poetry issue helped me find a solution:
The issue here is the macOS-provided python is not relocatable, so venv creates a broken python when using --copies / symlinks=False as our installer does.
Essentially, to solve this problem, download a distribution of python directly from python.org. For whatever reason, the poetry installation command isn't compatible with whatever distribution comes pre-built on a Mac.
I had to ask this again, because a related question solves the problem when there is no virtualenv involved.
Now I have more than one virtualenv that I would like to package in executables using cx_Freeze. I run my cx_Freeze setup file normally using virtualenv python interpreter, but then when I try to execute my program, pytz doesn't find the files, probably because if you see the error below, it is searching them in the original directory of virtualenv where they were located. I checked the time zone files are located correctly into the zip file.
This is the error message I get when trying to run my bundled program:
cserpell#e431:~/src/build/exe.linux-x86_64-2.7$ ./validate
/home/cserpell/src/build/exe.linux-x86_64-2.7/library.zip/distutils/__init__.py:14: UserWarning: The virtualenv distutils package at %s appears to be in the same location as the system distutils?
Traceback (most recent call last):
File "/home/cserpell/src/virtualenvtest/local/lib/python2.7/site-packages/cx_Freeze/initscripts/Console.py", line 27, in <module>
exec(code, m.__dict__)
File "scripts/validate.py", line 9, in <module>
File "/home/cserpell/src/scripts/script.py", line 15, in <module>
from common import time_util
File "/home/cserpell/src/common/time_util.py", line 31, in <module>
SCL_TZ = pytz.timezone('America/Santiago')
File "/home/cserpell/src/virtualenvtest/local/lib/python2.7/site-packages/pytz/__init__.py", line 180, in timezone
raise UnknownTimeZoneError(zone)
pytz.exceptions.UnknownTimeZoneError: 'America/Santiago'
I found the answer myself. The only thing needed was to install setuptools in my virtualenv. For the record, it is very strange that I installed it using pip in the virtualenv, but then when I run pip list or pip freeze, it doesn't show setuptools as requirement, though it is for the cx freeze script.
I am trying to build the HelloWorld example page from the Pyjamas example folder. However I am receiving this error when I run: sudo pyjsbuild helloworld.py. This error seems pretty universal to python as it seems to be related to the setup/configuration of my python environment. Any advice on where to look for the problem?
Here is the error
Traceback (most recent call last):
File "/usr/local/bin/pyjsbuild", line 5, in <module>
from pkg_resources import load_entry_point
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2603, in <module>
working_set.require(__requires__)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 666, in require
needed = self.resolve(parse_requirements(requirements))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 565, in resolve
raise DistributionNotFound(req) # XXX put more info here
pkg_resources.DistributionNotFound: six
After trying the various answers, it turns out pip was not properly installing the six package, whatever that is. So I ran sudo easy_install pip (--upgrade) to make sure the script configuration was right. It wrote some extra files so I assume that's why my next command sudo pip install six or sudo pip install six --upgrade worked. Now I ran into another error -_-, For anyone looking later: Runtime Error: Top module not found 'hello world'
Edit: The top module error is coming from trying to build into the output folder that is not pyjs/. All I had to do was move the folder up to pyjs/ folder in sitepackages/.
I tried to run the following command, in the folder of my Django project:
$ python manage.py dbshell
It shows me this error:
$python manage.py dbshell
Traceback (most recent call last):
File "manage.py", line 11, in <module>
execute_manager(settings)
File "C:\Python25\lib\site-packages\django\core\management\__init__.py", line
362, in execute_manager
utility.execute()
File "C:\Python25\lib\site-packages\django\core\management\__init__.py", line
303, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Python25\lib\site-packages\django\core\management\base.py", line 195,
in run_from_argv
self.execute(*args, **options.__dict__)
File "C:\Python25\lib\site-packages\django\core\management\base.py", line 222,
in execute
output = self.handle(*args, **options)
File "C:\Python25\lib\site-packages\django\core\management\base.py", line 351,
in handle
return self.handle_noargs(**options)
File "C:\Python25\lib\site-packages\django\core\management\commands\dbshell.py
", line 9, in handle_noargs
from django.db import connection
File "C:\Python25\lib\site-packages\django\db\__init__.py", line 41, in <modul
e>
backend = load_backend(settings.DATABASE_ENGINE)
File "C:\Python25\lib\site-packages\django\db\__init__.py", line 17, in load_b
ackend
return import_module('.base', 'django.db.backends.%s' % backend_name)
File "C:\Python25\Lib\site-packages\django\utils\importlib.py", line 35, in im
port_module
__import__(name)
File "C:\Python25\lib\site-packages\django\db\backends\mysql\base.py", line 13
, in <module>
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No mo
dule named MySQLdb
First question is, why does Python not simply include this MySQLdb module?
OK, just fine, try to search to solve this message.
I have looked around stackoverflow.com for installing this module but did not have a good result.
Download this module at: http://sourceforge.net/projects/mysql-python/
Comes to the installation of this module on my Windows Vista system.
After the extraction of the package, I run the cmd prompt to continue with the installation:
$ python setup.py install
Again it showed me one other message:
D:\SOFTWARE\PROGRAMMING\MySQL-python-1.2.3c1>python setup.py install
Traceback (most recent call last):
File "setup.py", line 5, in <module>
from setuptools import setup, Extension
ImportError: No module named setuptools
Playing around with this error message, I know that there is the ez_setup.py within the package:
$python ez_setup.py
It seems that everything is OK:
D:\SOFTWARE\PROGRAMMING\MySQL-python-1.2.3c1>python ez_setup.py
Downloading http://pypi.python.org/packages/2.5/s/setuptools/setuptools-0.6c9-py
2.5.egg
Processing setuptools-0.6c9-py2.5.egg
Copying setuptools-0.6c9-py2.5.egg to c:\python25\lib\site-packages
Adding setuptools 0.6c9 to easy-install.pth file
Installing easy_install-script.py script to C:\Python25\Scripts
Installing easy_install.exe script to C:\Python25\Scripts
Installing easy_install-2.5-script.py script to C:\Python25\Scripts
Installing easy_install-2.5.exe script to C:\Python25\Scripts
Installed c:\python25\lib\site-packages\setuptools-0.6c9-py2.5.egg
Processing dependencies for setuptools==0.6c9
Finished processing dependencies for setuptools==0.6c9
Now comes back to the setup.py to install again:
$python setup.py install
It again gave me one other error message:
D:\SOFTWARE\PROGRAMMING\MySQL-python-1.2.3c1>python setup.py install
running install
running bdist_egg
....
copying MySQLdb\constants\CLIENT.py -> build\lib.win32-2.5\MySQLdb\constants
running build_ext
error: Python was built with Visual Studio 2003;
extensions must be built with a compiler than can generate compatible binaries.
Visual Studio 2003 was not found on this system. If you have Cygwin installed,
you can try compiling with MingW32, by passing "-c mingw32" to setup.py.
How can I fix this problem?
Did you try looking here: http://sourceforge.net/projects/mysql-python/files/
That is the download area of MySQLdb project, it has nothing to do with django, so your question is incorrect - django does not make switching database backends hard, you just change one line. And of course, your python installation should support that database first, so by downloading binary package for Windows from the link I gave above (chose correct version to match your version of python) you can avoid all the hassle of compiling the source release.
Most probably you need either MySQL-python-1.2.2.win32-py2.5.exe or MySQL-python-1.2.2.win32-py2.4.exe
Uh, this isn't Django, this is you downloading some unspecified Python environment and expecting it to magically do everything exactly the way you wanted it to. Find a good tutorial on this and follow the instructions.
BTW, this is a very helpful forum, but giving no specifics and then delivering a non-question with an attitude is not a good way to get people to feel helpful.
I once had the same problem running Python and MySQL on the same computer. Like the guys/gals said above, Python does not come with built-in support for MySQL, so you will need to download the connectors.
The link given above by #kibitzer will most likely not work on Windows successfully, so go here to download a copy of the connector that works with windows. It comes with installer and no need to run setup.py script manually.
I tried to run the following command, in the folder of my Django project:
$ python manage.py dbshell
It shows me this error:
$python manage.py dbshell
Traceback (most recent call last):
File "manage.py", line 11, in <module>
execute_manager(settings)
File "C:\Python25\lib\site-packages\django\core\management\__init__.py", line
362, in execute_manager
utility.execute()
File "C:\Python25\lib\site-packages\django\core\management\__init__.py", line
303, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Python25\lib\site-packages\django\core\management\base.py", line 195,
in run_from_argv
self.execute(*args, **options.__dict__)
File "C:\Python25\lib\site-packages\django\core\management\base.py", line 222,
in execute
output = self.handle(*args, **options)
File "C:\Python25\lib\site-packages\django\core\management\base.py", line 351,
in handle
return self.handle_noargs(**options)
File "C:\Python25\lib\site-packages\django\core\management\commands\dbshell.py
", line 9, in handle_noargs
from django.db import connection
File "C:\Python25\lib\site-packages\django\db\__init__.py", line 41, in <modul
e>
backend = load_backend(settings.DATABASE_ENGINE)
File "C:\Python25\lib\site-packages\django\db\__init__.py", line 17, in load_b
ackend
return import_module('.base', 'django.db.backends.%s' % backend_name)
File "C:\Python25\Lib\site-packages\django\utils\importlib.py", line 35, in im
port_module
__import__(name)
File "C:\Python25\lib\site-packages\django\db\backends\mysql\base.py", line 13
, in <module>
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No mo
dule named MySQLdb
First question is, why does Python not simply include this MySQLdb module?
OK, just fine, try to search to solve this message.
I have looked around stackoverflow.com for installing this module but did not have a good result.
Download this module at: http://sourceforge.net/projects/mysql-python/
Comes to the installation of this module on my Windows Vista system.
After the extraction of the package, I run the cmd prompt to continue with the installation:
$ python setup.py install
Again it showed me one other message:
D:\SOFTWARE\PROGRAMMING\MySQL-python-1.2.3c1>python setup.py install
Traceback (most recent call last):
File "setup.py", line 5, in <module>
from setuptools import setup, Extension
ImportError: No module named setuptools
Playing around with this error message, I know that there is the ez_setup.py within the package:
$python ez_setup.py
It seems that everything is OK:
D:\SOFTWARE\PROGRAMMING\MySQL-python-1.2.3c1>python ez_setup.py
Downloading http://pypi.python.org/packages/2.5/s/setuptools/setuptools-0.6c9-py
2.5.egg
Processing setuptools-0.6c9-py2.5.egg
Copying setuptools-0.6c9-py2.5.egg to c:\python25\lib\site-packages
Adding setuptools 0.6c9 to easy-install.pth file
Installing easy_install-script.py script to C:\Python25\Scripts
Installing easy_install.exe script to C:\Python25\Scripts
Installing easy_install-2.5-script.py script to C:\Python25\Scripts
Installing easy_install-2.5.exe script to C:\Python25\Scripts
Installed c:\python25\lib\site-packages\setuptools-0.6c9-py2.5.egg
Processing dependencies for setuptools==0.6c9
Finished processing dependencies for setuptools==0.6c9
Now comes back to the setup.py to install again:
$python setup.py install
It again gave me one other error message:
D:\SOFTWARE\PROGRAMMING\MySQL-python-1.2.3c1>python setup.py install
running install
running bdist_egg
....
copying MySQLdb\constants\CLIENT.py -> build\lib.win32-2.5\MySQLdb\constants
running build_ext
error: Python was built with Visual Studio 2003;
extensions must be built with a compiler than can generate compatible binaries.
Visual Studio 2003 was not found on this system. If you have Cygwin installed,
you can try compiling with MingW32, by passing "-c mingw32" to setup.py.
How can I fix this problem?
Did you try looking here: http://sourceforge.net/projects/mysql-python/files/
That is the download area of MySQLdb project, it has nothing to do with django, so your question is incorrect - django does not make switching database backends hard, you just change one line. And of course, your python installation should support that database first, so by downloading binary package for Windows from the link I gave above (chose correct version to match your version of python) you can avoid all the hassle of compiling the source release.
Most probably you need either MySQL-python-1.2.2.win32-py2.5.exe or MySQL-python-1.2.2.win32-py2.4.exe
Uh, this isn't Django, this is you downloading some unspecified Python environment and expecting it to magically do everything exactly the way you wanted it to. Find a good tutorial on this and follow the instructions.
BTW, this is a very helpful forum, but giving no specifics and then delivering a non-question with an attitude is not a good way to get people to feel helpful.
I once had the same problem running Python and MySQL on the same computer. Like the guys/gals said above, Python does not come with built-in support for MySQL, so you will need to download the connectors.
The link given above by #kibitzer will most likely not work on Windows successfully, so go here to download a copy of the connector that works with windows. It comes with installer and no need to run setup.py script manually.