I am new to django and I created a website and now I am in the deployment phase, all is well run until launching migrating from the database to the server. I'll show you everything I've done since the beginning
structure of my project
OC_project8/
pur_beurre/
catalog/
dumps/
catalog.json
... # other classic file
media/
pur_beurre/
static/
.gitignore
... # other classic file
static/
templates/
users/
manage.py
Procfile
venv/
requirements.txt/
certifi==2019.9.11
chardet==3.0.4
coverage==4.5.4
dj-database-url==0.5.0
Django==2.2.6
django-debug-toolbar==2.0
gunicorn==19.9.0
idna==2.8
mysqlclient==1.4.4
Pillow==6.2.0
pytz==2019.3
requests==2.22.0
sqlparse==0.3.0
urllib3==1.25.6
whitenoise==4.1.4
.gitignore/
All command was run in a virtual environement, for exemple:
(venv) ~/OC_project8/pur_beurre$ sudo apt-get install python-psycopg2
I did all the necessary steps before runing the command git push heroku master
(git commit, heroku create my-app ...)
if you need more detail on these steps tell me.
After runing the command git push heroku master I had this error:
....
remote: Collecting pkg-resources==0.0.0 (from -r /tmp/build_cac68f54540915062647a425c52dc61b/requirements.txt (line 11))
remote: Could not find a version that satisfies the requirement pkg-resources==0.0.0 (from -r/tmp/build_cac68f54540915062647a425c52dc61b/requirements.txt (line 11)) (from versions: )
remote: No matching distribution found for pkg-resources==0.0.0 (from -r /tmp/build_cac68f54540915062647a425c52dc61b/requirements.txt (line 11))
remote: ! Push rejected, failed to compile Python app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to pur-beurre-oc8.
remote:
To https://git.heroku.com/pur-beurre-oc8.git
! [remote rejected] master -> master (pre-receive hook declined)
error: impossible de pousser des références vers 'https://git.heroku.com/pur-beurre-oc8.git'
I saw in stackoverflow that I have to do that:
pip uninstall pkg-resources==0.0.0
After I made a commit:
git add requirements.txt
git commit -m "uninstalling pkg-resources==0.0.0"
And now git push heroku master work fine, but when I access my website I had the error: Apllication error. I don't know if I'm getting wet but I think because I have not done the migration of the database yet.
So I run the command heroku run python pur_beurre/manage.py migrate
And now I had this error:
Running python pur_beurre/manage.py migrate on ⬢ pur-beurre-oc8... up, run.4138 (Free)
Traceback (most recent call last):
File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/postgresql/base.py", line 20, in <module>
import psycopg2 as Database
ModuleNotFoundError: No module named 'psycopg2'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "pur_beurre/manage.py", line 21, in <module>
main()
File "pur_beurre/manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 357, in execute
django.setup()
File "/app/.heroku/python/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/app/.heroku/python/lib/python3.6/site-packages/django/apps/registry.py", line 114, in populate
app_config.import_models()
File "/app/.heroku/python/lib/python3.6/site-packages/django/apps/config.py", line 211, in import_models
self.models_module = import_module(models_module_name)
File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/auth/models.py", line 2, in <module>
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/auth/base_user.py", line 47, in <module>
class AbstractBaseUser(models.Model):
File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/base.py", line 117, in __new__
new_class.add_to_class('_meta', Options(meta, app_label))
File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/base.py", line 321, in add_to_class
value.contribute_to_class(cls, name)
File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/options.py", line 204, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File "/app/.heroku/python/lib/python3.6/site-packages/django/db/__init__.py", line 28, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/app/.heroku/python/lib/python3.6/site-packages/django/db/utils.py", line 201, in __getitem__
backend = load_backend(db['ENGINE'])
File "/app/.heroku/python/lib/python3.6/site-packages/django/db/utils.py", line 110, in load_backend
return import_module('%s.base' % backend_name)
File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/postgresql/base.py", line 24, in <module>
raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: No module named 'psycopg2'
I don't know why I have this error since psycopg2 is a library required to use PostgreSQL and I am using MySQL, here is my settings.py:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'openfoodfacts',
'USER': 'root',
'PASSWORD': 'my-password',
'HOST': '',
'PORT': '5432',
}
}
In any case after having this error I tried to install psycopg2:
pip install psycopg2
But I had another error:
Collecting psycopg2
Downloading https://files.pythonhosted.org/ packages/84/d7/6a93c99b5ba4d4d22daa3928b983cec66df4 536ca50b22ce5dcac65e4e71/psycopg2-2.8.4.tar.gz (377kB)
100% |████████████████████████████████| 378kB 1.8MB/s
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/rouizi/OC_project8/venv/lib/python3.6/site-packages/setuptools/__init__.py", line 12, in <module>
import setuptools.version
File "/home/rouizi/OC_project8/venv/lib/python3.6/site-packages/setuptools/version.py", line 1, in <module>
import pkg_resources
ModuleNotFoundError: No module named 'pkg_resources'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-gf4fxs4k/psycopg2/
Maybe I got this error because I uninstalled
in the beginning pkg-resources ! But I tried to reinstall pkg-resources:
sudo apt-get install --reinstall python-pkg-resources
And I rerun the command pip install psycopg2, but still have the same error
By searching on google I found here No module named pkg_resources that it was necessary to run this command:
wget https://bootstrap.pypa.io/ez_setup.py -O - | python
And I rerun the command pip install psycopg2, but I have another error:
Collecting psycopg2
Using cached https://files.pythonhosted.org/ packages/84/d7/6a93c99b5ba4d4d22daa3928b983cec66df 4536ca50b22ce5dcac65e4e71/psycopg2-2.8.4.tar.gz
Complete output from command python setup.py egg_info:
running egg_info
creating pip-egg-info/psycopg2.egg-info
writing pip-egg-info/psycopg2.egg-info/PKG-INFO
writing dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt
writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt
writing manifest file 'pip-egg-info/psycopg2.egg-info/SOURCES.txt'
Error: pg_config executable not found.
pg_config is required to build psycopg2 from source. Please add the directory
containing pg_config to the $PATH or specify the full executable path with the
option:
python setup.py build_ext --pg-config /path/to/pg_config build ...
or with the pg_config option in 'setup.cfg'.
If you prefer to avoid building psycopg2 from source, please install the PyPI
'psycopg2-binary' package instead.
For further information please check the 'doc/src/install.rst' file (also at
<http://initd.org/psycopg/docs/install.html>).
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-sglmdb2o/psycopg2/
And if I run the command which pg_config it return nothing, but after some research I fond here pg_config executable not found that it was necessary to run this command:
sudo apt-get install libpq-dev
and now which pg_config return this:
/usr/bin/pg_config
So I rerun pip install psycopg2 and another error occured:
Collecting psycopg2
Using cached https://files.pythonhosted.org/ packages/84/d7/6a93c99b5ba4d4d22 daa3928b983cec66df4536ca50b22ce5dcac65e4e71/psycopg2-2.8.4.tar.gz
Building wheels for collected packages: psycopg2
Running setup.py bdist_wheel for psycopg2 ... error
Complete output from command /home/rouizi/OC_project8/venv/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-lu4ihs81/psycopg2/setup.py';f=getattr(tokenize,
'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/tmphgjf714ppip-wheel- --python-tag cp36:
usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: -c --help [cmd1 cmd2 ...]
or: -c --help-commands
or: -c cmd --help
error: invalid command 'bdist_wheel'
----------------------------------------
Failed building wheel for psycopg2
Running setup.py clean for psycopg2
Failed to build psycopg2
Installing collected packages: psycopg2
Running setup.py install for psycopg2 ... error
#I cut here because it's very long
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-lu4ihs81/psycopg2/setup.py", line 611, in <module>
'Documentation': 'http://initd.org/psycopg/docs/',
File "/home/rouizi/OC_project8/venv/lib/python3.6/site-packages/setuptools/__init__.py", line 129, in setup
return distutils.core.setup(**attrs)
File "/usr/lib/python3.6/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/lib/python3.6/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/usr/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/home/rouizi/OC_project8/venv/lib/python3.6/site-packages/setuptools/command/install.py", line 61, in run
return orig.install.run(self)
File "/usr/lib/python3.6/distutils/command/install.py", line 601, in run
self.run_command(cmd_name)
File "/usr/lib/python3.6/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/home/rouizi/OC_project8/venv/lib/python3.6/site-packages/setuptools/command/install_scripts.py", line 17, in run
import setuptools.command.easy_install as ei
File "/home/rouizi/OC_project8/venv/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 47, in <module>
from setuptools.sandbox import run_setup
File "/home/rouizi/OC_project8/venv/lib/python3.6/site-packages/setuptools/sandbox.py", line 15, in <module>
import pkg_resources.py31compat
ModuleNotFoundError: No module named 'pkg_resources.py31compat'
----------------------------------------
Command "/home/rouizi/OC_project8/venv/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-lu4ihs81/psycopg2/setup.py';f=getattr(tokenize, 'open', open)(__file__)
;code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-eya3xv3b-record/install-record.txt --single-version-externally-managed
--compile --install-headers /home/rouizi/OC_project8/venv/include/site/python3.6/psycopg2" failed with error code 1 in /tmp/pip-build-lu4ihs81/psycopg2/
I tried this command:
sudo apt-get install --reinstall python-setuptools
And now when I try to run pip install psycopg2 he return to me:
Requirement already satisfied: psycopg2 in /home/rouizi/OC_project8/venv/lib/python3.6/site-packages
But if I try to run the command heroku run python pur_beurre/manage.py migrate I still have the error:
django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: No module named 'psycopg2'
But if I run sudo apt-get install python-psycopg2 It worked but I still have the error when runing heroku run python pur_beurre/manage.py migrate
Since I still had the same error, so I tried uninstall psycopg2:
sudo pip uninstall psycopg2
But it return to me that:
The directory '/home/rouizi/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Not uninstalling psycopg2 at /usr/lib/python2.7/dist-packages, outside environment /usr
And there I am stuck for a day without finding a solution, I hope you can help
sorry for the long post and for my misspelling
I solved my problem !
I ran the command pip install psycopg2, it return to me the error:
ModuleNotFoundError: No module named 'pkg_resources.py31compat'
But if I try to rerun the command pip install psycopg2, it says:
Requirement already satisfied: psycopg2 in /home/rouizi/OC_project8/venv/lib/python3.6/site-packages
So I tryied to commit my change:
pip freeze > requirements.txt
git add requirements.txt
git commit -m "installing psycopg2"
git push heroku master
And now heroku run python pur_beurre/manage.py migrate work fine.
I don't know why since I had an error, if someone has an explanation will be well
Related
I'm trying to install Autodock Vina with pip command. But when I run the command pip install -U numpy vina: I get a the following error:
Collecting vina
Using cached vina-1.2.3.tar.gz (95 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... error
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [52 lines of output]
Version found 1.2.3 (from __init__.py)
running egg_info
writing vina.egg-info\PKG-INFO
writing dependency_links to vina.egg-info\dependency_links.txt
writing requirements to vina.egg-info\requires.txt
writing top-level names to vina.egg-info\top_level.txt
Boost library is not installed in this conda environment.
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 363, in <module>
main()
File "C:\ProgramData\Anaconda3\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 345, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "C:\ProgramData\Anaconda3\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 130, in get_requires_for_build_wheel
return hook(config_settings)
File "C:\Users\Familia\AppData\Local\Temp\pip-build-env-km4q58s5\overlay\Lib\site-packages\setuptools\build_meta.py", line 162, in get_requires_for_build_wheel
return self._get_build_requires(
File "C:\Users\Familia\AppData\Local\Temp\pip-build-env-km4q58s5\overlay\Lib\site-packages\setuptools\build_meta.py", line 143, in _get_build_requires
self.run_setup()
File "C:\Users\Familia\AppData\Local\Temp\pip-build-env-km4q58s5\overlay\Lib\site-packages\setuptools\build_meta.py", line 158, in run_setup
exec(compile(code, __file__, 'exec'), locals())
File "setup.py", line 346, in <module>
setup(
File "C:\Users\Familia\AppData\Local\Temp\pip-build-env-km4q58s5\overlay\Lib\site-packages\setuptools\__init__.py", line 155, in setup
return distutils.core.setup(**attrs)
File "C:\Users\Familia\AppData\Local\Temp\pip-build-env-km4q58s5\overlay\Lib\site-packages\setuptools\_distutils\core.py", line 148, in setup
return run_commands(dist)
File "C:\Users\Familia\AppData\Local\Temp\pip-build-env-km4q58s5\overlay\Lib\site-packages\setuptools\_distutils\core.py", line 163, in run_commands
dist.run_commands()
File "C:\Users\Familia\AppData\Local\Temp\pip-build-env-km4q58s5\overlay\Lib\site-packages\setuptools\_distutils\dist.py", line 967, in run_commands
self.run_command(cmd)
File "C:\Users\Familia\AppData\Local\Temp\pip-build-env-km4q58s5\overlay\Lib\site-packages\setuptools\_distutils\dist.py", line 986, in run_command
cmd_obj.run()
File "C:\Users\Familia\AppData\Local\Temp\pip-build-env-km4q58s5\overlay\Lib\site-packages\setuptools\command\egg_info.py", line 299, in run
self.find_sources()
File "C:\Users\Familia\AppData\Local\Temp\pip-build-env-km4q58s5\overlay\Lib\site-packages\setuptools\command\egg_info.py", line 306, in find_sources
mm.run()
File "C:\Users\Familia\AppData\Local\Temp\pip-build-env-km4q58s5\overlay\Lib\site-packages\setuptools\command\egg_info.py", line 541, in run
self.add_defaults()
File "C:\Users\Familia\AppData\Local\Temp\pip-build-env-km4q58s5\overlay\Lib\site-packages\setuptools\command\egg_info.py", line 578, in add_defaults
sdist.add_defaults(self)
File "C:\Users\Familia\AppData\Local\Temp\pip-build-env-km4q58s5\overlay\Lib\site-packages\setuptools\_distutils\command\sdist.py", line 228, in add_defaults
self._add_defaults_ext()
File "C:\Users\Familia\AppData\Local\Temp\pip-build-env-km4q58s5\overlay\Lib\site-packages\setuptools\_distutils\command\sdist.py", line 311, in _add_defaults_ext
build_ext = self.get_finalized_command('build_ext')
File "C:\Users\Familia\AppData\Local\Temp\pip-build-env-km4q58s5\overlay\Lib\site-packages\setuptools\_distutils\cmd.py", line 299, in get_finalized_command
cmd_obj.ensure_finalized()
File "C:\Users\Familia\AppData\Local\Temp\pip-build-env-km4q58s5\overlay\Lib\site-packages\setuptools\_distutils\cmd.py", line 107, in ensure_finalized
self.finalize_options()
File "setup.py", line 247, in finalize_options
raise ValueError(error_msg)
ValueError: Boost library location was not found!
Directories searched: conda env, /usr/local/include and /usr/include.
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
I have had a similar issue and fixed it by installing boost and swig libraries. Unfortunately, I do not completely know how to do that on Windows, but the rough sketch of what you should do is:
Locate your active conda environment. If there are none, create and activate one before installing your project dependencies. To get to know the location of your environment, use conda info. For more, see this stackoverflow thread.
Download boost and swig as archives from these links to their official website.
Unpack the archives into the conda environment folder.
Try installing again (make sure you have activated the environment) pip install -U numpy vina.
For the Linux and MacOS users that may have the same issue, the solution is very similar, except that you do not have to activate a conda environment. Instead, you can install boost and swig globally in your system, as described in this guide in the autodock-vina website.
Install C++ compiler.
Ubuntu/Debian: sudo apt-get install build-essentials
macOS: Install Xcode from the AppStore and the Command Line Tools (CLT) from the terminal xcode-select --install
Install boost and swig in your system
Ubuntu/Debian: sudo apt-get install libboost-all-dev swig
macOS (with Homebrew): brew install boost swig
I've been trying to get this Ubuntu docker image for a Flask app to build correctly for a bit now, but it never successfully builds. I'm trying to create a Python Flask app which runs off of a forked version of the Flask github repository. The only changes made to this github repository were in setup.py, where the dependencies are replaced with other forked dependencies. When I run "docker build -t test ." I get the following error:
Obtaining flask from git+git://github.com/ectoglasses/flask.git#egg=flask (from -r requirements.txt (line 6))
Cloning git://github.com/ectoglasses/flask.git to ./src/flask
Running command git clone -q git://github.com/ectoglasses/flask.git /app/src/flask
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/app/src/flask/setup.py'"'"'; __file__='"'"'/app/src/flask/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info
cwd: /app/src/flask/
Complete output (33 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/app/src/flask/setup.py", line 4, in <module>
setup(
File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 144, in setup
return distutils.core.setup(**attrs)
File "/usr/lib/python3.8/distutils/core.py", line 121, in setup
dist.parse_config_files()
File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 701, in parse_config_files
parse_configuration(self, self.command_options,
File "/usr/lib/python3/dist-packages/setuptools/config.py", line 121, in parse_configuration
meta.parse()
File "/usr/lib/python3/dist-packages/setuptools/config.py", line 426, in parse
section_parser_method(section_options)
File "/usr/lib/python3/dist-packages/setuptools/config.py", line 399, in parse_section
self[name] = value
File "/usr/lib/python3/dist-packages/setuptools/config.py", line 184, in __setitem__
value = parser(value)
File "/usr/lib/python3/dist-packages/setuptools/config.py", line 515, in _parse_version
version = self._parse_attr(value, self.package_dir)
File "/usr/lib/python3/dist-packages/setuptools/config.py", line 349, in _parse_attr
module = import_module(module_name)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 848, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/app/src/flask/src/flask/__init__.py", line 1, in <module>
from markupsafe import escape
ModuleNotFoundError: No module named 'markupsafe'
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
The command '/bin/sh -c apt-get install -y python3-pip && apt-get install -y git && pip3 install -r requirements.txt' returned a non-zero code: 1
I've previously used Alpine for this project, and did not encounter this same error. I've also tried using the version of Flask hosted on Pypi to see if the problem was with the package itself, but did not get any errors. This tells me that this has something to do with how pip works on Ubuntu, given the code that is producing these results, which I've posted below.
Dockerfile:
# Use Google Cloud SDK's container as the base image
FROM ubuntu:20.04
...
# Copy the contents of the current directory into the container directory /app
COPY . /app
# Set the working directory of the container to /app
WORKDIR /app
# Install the Python packages specified by requirements.txt into the container
RUN apt-get update -y
RUN apt-get install -y python3-pip && apt-get install -y git && pip3 install -r requirements.txt
CMD python3 app.py
requirements.txt:
# Python framework
-e git://github.com/ectoglasses/flask.git#egg=flask
Does anyone have any ideas as to what could cause this error?
from the error it looks like the module markupsafe is missing. The Dockerfile can use some caching improvements as well.
e.g.
# Use Google Cloud SDK's container as the base image
FROM ubuntu:20.04
...
COPY requirements.txt /app/
WORKDIR /app
RUN apt-get update -y \
&& apt-get install -y \
python3-pip \
python-markupsafe \
git
# Install the Python packages specified by requirements.txt into the container
RUN pip3 install -r requirements.txt
# Copy the contents of the current directory into the container directory /app
COPY . /app
CMD python3 app.py
I located the issue. The issue is at setup.cfg file line 3 version = attr: flask.__version__. During the docker build stage of pip3 install -r requirements.txt, it will load setup.cfg file before install any dependency. When it loads setup.cfg file, it will load flask module (the __init__.py file) to find __version__ attribute. It throws error because none of the dependencies listed in __init__.py is installed yet.
It seems a bug in Ubuntu environment. I have no issue to run in macOS. You can have a quick fix by changing version = 1.0 in setup.cfg file.
I'm trying to update AWS CLI to the latest version. I'm following the below AWS documentation:
Aws cli upgrade with sudo access
When I run the command:
sudo ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
I get a long python error, which I can't understand. What is the problem here?
Error message:
Deprecated Python version detected: Python 2.7
Starting July 15, 2021, the AWS CLI will no longer support this version of Python. To continue receiving service updates, bug fixes, and security updates please upgrade to Python 3.6 or later. More information can be found here: https://aws.amazon.com/blogs/developer/announcing-end-of-support-for-python-2-7-in-aws-sdk-for-python-and-aws-cli-v1/
Running cmd: /bin/python virtualenv.py --no-download --python /bin/python /usr/local/aws
Running cmd: /usr/local/aws/bin/pip install --no-binary :all: --no-cache-dir --no-index --find-links file://. setuptools_scm-3.3.3.tar.gz
Traceback (most recent call last):
File "./awscli-bundle/install", line 270, in <module>
main()
File "./awscli-bundle/install", line 247, in main
pip_install_packages(opts.install_dir)
File "./awscli-bundle/install", line 167, in pip_install_packages
_install_setup_deps(pip_script, '.')
File "./awscli-bundle/install", line 184, in _install_setup_deps
pip_script, setup_package_dir, setuptools_scm_tarball))
File "./awscli-bundle/install", line 90, in run
p.returncode, cmd, output))
__main__.BadRCError: Bad rc (1) for cmd '/usr/local/aws/bin/pip install --no-binary :all: --no-cache-dir --no-index --find-links file://. setuptools_scm-3.3.3.tar.gz': Looking in links: file://.
Processing ./setuptools_scm-3.3.3.tar.gz
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
ERROR: Command errored out with exit status 1:
command: /usr/local/aws/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-M9znG_/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-M9znG_/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-req-build-M9znG_/pip-egg-info
cwd: /tmp/pip-req-build-M9znG_/
Complete output (36 lines):
running egg_info
creating /tmp/pip-req-build-M9znG_/pip-egg-info/setuptools_scm.egg-info
writing /tmp/pip-req-build-M9znG_/pip-egg-info/setuptools_scm.egg-info/PKG-INFO
writing top-level names to /tmp/pip-req-build-M9znG_/pip-egg-info/setuptools_scm.egg-info/top_level.txt
writing dependency_links to /tmp/pip-req-build-M9znG_/pip-egg-info/setuptools_scm.egg-info/dependency_links.txt
writing entry points to /tmp/pip-req-build-M9znG_/pip-egg-info/setuptools_scm.egg-info/entry_points.txt
writing manifest file '/tmp/pip-req-build-M9znG_/pip-egg-info/setuptools_scm.egg-info/SOURCES.txt'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-req-build-M9znG_/setup.py", line 118, in <module>
setuptools.setup(**arguments)
File "/usr/local/aws/lib/python2.7/site-packages/setuptools/__init__.py", line 145, in setup
return distutils.core.setup(**attrs)
File "/usr/lib64/python2.7/distutils/core.py", line 152, in setup
dist.run_commands()
File "/usr/lib64/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/usr/lib64/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/usr/local/aws/lib/python2.7/site-packages/setuptools/command/egg_info.py", line 296, in run
self.find_sources()
File "/usr/local/aws/lib/python2.7/site-packages/setuptools/command/egg_info.py", line 303, in find_sources
mm.run()
File "/usr/local/aws/lib/python2.7/site-packages/setuptools/command/egg_info.py", line 534, in run
self.add_defaults()
File "/usr/local/aws/lib/python2.7/site-packages/setuptools/command/egg_info.py", line 574, in add_defaults
rcfiles = list(walk_revctrl())
File "/usr/local/aws/lib/python2.7/site-packages/setuptools/command/sdist.py", line 20, in walk_revctrl
for item in ep.load()(dirname):
File "/tmp/pip-req-build-M9znG_/src/setuptools_scm/integration.py", line 22, in find_files
command = ep.load()
File "/usr/local/aws/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2443, in load
return self.resolve()
File "/usr/local/aws/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2453, in resolve
raise ImportError(str(exc))
ImportError: 'module' object has no attribute 'FILES_COMMAND'
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
Ubuntu 18.04 LTS
Python 3.6
Node 8.11.4 (LTS)
NPM 5.6.0
Trying to install the tutorial django project by following the instructions in the briefcase tutorial. It installs the Linux file just fine, but attempting to install it the same way but with django python3 setup.py django -s gives me the following failure:
running django
* Updating user code...
* Installing requirements...
No requirements.
* Installing plaform requirements...
Collecting toga-django==0.3.0.dev9
Using cached https://files.pythonhosted.org/packages/9e/88/49d9ab4c128e61a47bb365201fdfa3ebf1fd8905c0c5baa06dc248db9f0a/toga_django-0.3.0.dev9-py3-none-any.whl
Collecting toga-core==0.3.0.dev9 (from toga-django==0.3.0.dev9)
Using cached https://files.pythonhosted.org/packages/50/a1/ebc3b57145b03b644cc53c2693838eb3afafdb686eec2dffd90cf3548d09/toga_core-0.3.0.dev9-py3-none-any.whl
Collecting django-environ==0.4.1 (from toga-django==0.3.0.dev9)
Using cached https://files.pythonhosted.org/packages/f4/06/8dd165534eae19e72ca78bd6e845566cd1e0aacc9c20cc43984675748345/django_environ-0.4.1-py2.py3-none-any.whl
Collecting django==1.10.6 (from toga-django==0.3.0.dev9)
Using cached https://files.pythonhosted.org/packages/b9/bb/723f78e6f6aea78590331eba4e42b8a09c33ce154204a942525a91101d0b/Django-1.10.6-py2.py3-none-any.whl
Collecting travertino>=0.1.0 (from toga-core==0.3.0.dev9->toga-django==0.3.0.dev9)
Using cached https://files.pythonhosted.org/packages/56/3f/f03efe63c2bdc72763ac39777c9ebbab98605ced5c74aefe48b4fa0abb4d/travertino-0.1.2-py3-none-any.whl
Collecting six (from django-environ==0.4.1->toga-django==0.3.0.dev9)
Using cached https://files.pythonhosted.org/packages/67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe3056e86a/six-1.11.0-py2.py3-none-any.whl
Installing collected packages: travertino, toga-core, django, six, django-environ, toga-django
Found existing installation: travertino 0.1.2
Uninstalling travertino-0.1.2:
Successfully uninstalled travertino-0.1.2
Found existing installation: toga-core 0.3.0.dev9
Uninstalling toga-core-0.3.0.dev9:
Successfully uninstalled toga-core-0.3.0.dev9
Found existing installation: Django 1.10.6
Uninstalling Django-1.10.6:
Successfully uninstalled Django-1.10.6
Found existing installation: six 1.11.0
Uninstalling six-1.11.0:
Successfully uninstalled six-1.11.0
Found existing installation: django-environ 0.4.1
Uninstalling django-environ-0.4.1:
Successfully uninstalled django-environ-0.4.1
Found existing installation: toga-django 0.3.0.dev9
Uninstalling toga-django-0.3.0.dev9:
Successfully uninstalled toga-django-0.3.0.dev9
Successfully installed django-1.10.6 django-environ-0.4.1 six-1.11.0 toga-core-0.3.0.dev9 toga-django-0.3.0.dev9 travertino-0.1.2
* Installing project code...
Traceback (most recent call last):
File "setup.py", line 79, in <module>
'toga-django==0.3.0.dev9',
File "/home/hv/Projects/tutorial/venv/lib/python3.6/site-packages/setuptools/__init__.py", line 140, in setup
return distutils.core.setup(**attrs)
File "/usr/lib/python3.6/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/lib/python3.6/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/usr/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/home/hv/Projects/tutorial/venv/lib/python3.6/site-packages/briefcase/app.py", line 478, in run
self.install_code()
File "/home/hv/Projects/tutorial/venv/lib/python3.6/site-packages/briefcase/app.py", line 314, in install_code
stderr=subprocess.STDOUT,
File "/usr/lib/python3.6/subprocess.py", line 336, in check_output
**kwargs).stdout
File "/usr/lib/python3.6/subprocess.py", line 418, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['pip', 'install', '--upgrade', '--force-reinstall', '--no-dependencies', '--target=/home/hv/Projects/tutorial/helloworld/django', '.']' returned non-zero exit status 1.
I have attempted searching around, and even running the pip command directly with pip install --upgrade --force-reinstall --no-dependencies --target=/home/hv/Projects/tutorial/helloworld/django . which outputs:
Processing /home/hv/Projects/tutorial/helloworld
Installing collected packages: helloworld
Running setup.py install for helloworld ... done
Successfully installed helloworld-0.0.1
I'm quite new to this, and looking for some advice. This is within a virtualenv and with versions:
pip 18.0 from /home/hv/Projects/tutorial/venv/lib/python3.6/site-packages/pip (python 3.6)
UPDATE:
Removed the specific requirement for toga-django==0.3.0.dev9 in the setup.py file, and it appears to have successfully installed. However, it cannot actually launch the Django server:
python setup.py django -s -v
running django
* Updating user code...
* Installing requirements...
No requirements.
* Installing plaform requirements...
No platform requirements.
* Installing project code...
Processing /home/hv/Projects/tutorial/helloworld
Installing collected packages: helloworld
Running setup.py install for helloworld: started
Running setup.py install for helloworld: finished with status 'done'
Successfully installed helloworld-0.0.1
* No icons defined - using default...
* No splash screen defined...
* Installing NPM requirements...
/usr/bin/env: ‘node’: Not a directory
Installation complete.
* Building Webpack assets...
/usr/bin/env: ‘node’: Not a directory
* Starting Django server on localhost:8042
* Opening browser...
Traceback (most recent call last):
File "./manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/home/hv/Projects/tutorial/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
utility.execute()
File "/home/hv/Projects/tutorial/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 341, in execute
django.setup()
File "/home/hv/Projects/tutorial/venv/lib/python3.6/site-packages/django/__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/hv/Projects/tutorial/venv/lib/python3.6/site-packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/home/hv/Projects/tutorial/venv/lib/python3.6/site-packages/django/apps/config.py", line 116, in create
mod = import_module(mod_path)
File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'toga.django'
App started.
I am trying to install pyzmail for Python 3.4. I am using Visual Studio Community Edition (Windows) but have also tried to install using the command line and get the following dump:
----- Installing 'pyzmail' -----
Collecting pyzmail
Using cached pyzmail-1.0.3.tar.gz
Collecting distribute (from pyzmail)
Using cached distribute-0.7.3.zip
Complete output from command python setup.py egg_info:
running egg_info
creating pip-egg-info\distribute.egg-info
writing requirements to pip-egg-info\distribute.egg-info\requires.txt
writing top-level names to pip-egg-info\distribute.egg-info\top_level.txt
writing dependency_links to pip-egg-info\distribute.egg-info\dependency_links.txt
writing pip-egg-info\distribute.egg-info\PKG-INFO
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Temp\pip-build-v5zvr2p3\distribute\pkg_resources.py", line 2680, in _dep_map
return self.__dep_map
File "C:\Users\user\AppData\Local\Temp\pip-build-v5zvr2p3\distribute\pkg_resources.py", line 2525, in __getattr__
raise AttributeError(attr)
AttributeError: _DistInfoDistribution__dep_map
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\user\AppData\Local\Temp\pip-build-v5zvr2p3\distribute\setup.py", line 58, in <module>
setuptools.setup(**setup_params)
File "C:\Python34\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "C:\Python34\lib\distutils\dist.py", line 955, in run_commands
self.run_command(cmd)
File "C:\Python34\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "C:\Users\user\AppData\Local\Temp\pip-build-v5zvr2p3\distribute\setuptools\command\egg_info.py", line 177, in run
writer = ep.load(installer=installer)
File "C:\Users\user\AppData\Local\Temp\pip-build-v5zvr2p3\distribute\pkg_resources.py", line 2241, in load
if require: self.require(env, installer)
File "C:\Users\user\AppData\Local\Temp\pip-build-v5zvr2p3\distribute\pkg_resources.py", line 2254, in require
working_set.resolve(self.dist.requires(self.extras),env,installer)))
File "C:\Users\user\AppData\Local\Temp\pip-build-v5zvr2p3\distribute\pkg_resources.py", line 2471, in requires
dm = self._dep_map
File "C:\Users\user\AppData\Local\Temp\pip-build-v5zvr2p3\distribute\pkg_resources.py", line 2682, in _dep_map
self.__dep_map = self._compute_dependencies()
File "C:\Users\user\AppData\Local\Temp\pip-build-v5zvr2p3\distribute\pkg_resources.py", line 2699, in _compute_dependencies
from _markerlib import compile as compile_marker
ImportError: No module named '_markerlib'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\user\AppData\Local\Temp\pip-build-v5zvr2p3\distribute\
----- Failed to install 'pyzmail' -----
After Googling, I checked I had the ez_setup and setuptools modules installed, which I do. Any help would be much appreciated!
I've been able to reproduce your problem, and you're right, using pip install pyzmail wont' be good (pyzmail's installer is buggy) so i've tried this instead:
easy_install pyzmail
And it succeed, then I could just import pyzmail without any problem.
You can also try installing the pyzmail36 fork, which installs the same modules for Python 3.6 and later: pip install pyzmail36 on Windows and pip3 install pyzmail36 on Linux and macOS.
You can try easy_install pyzmail
That worked for me in 2020.