Unable to run pytest setup through pycharm - python

Running pytest through CLI with pytest-xdist runs fine (pytest -n 3 {test}). When running the same set up in PyCharm I get Context version conflict, stating that I need to lower my pytest version. When I lower the version to below 4, pycharm is able to run the pytest script through the pytest runner.
Here is the requirements.txt:
apipkg==1.5
atomicwrites==1.3.0
attrs==19.1.0
execnet==1.5.0
more-itertools==6.0.0
pluggy==0.9.0
py==1.8.0
pytest==4.3.1
pytest-forked==1.0.2
pytest-rerunfailures==6.0
pytest-xdist==1.27.0
selenium==3.141.0
six==1.12.0
urllib3==1.24.1
and the error:
Traceback (most recent call last):
File "/Users/{name}/.pyenv/versions/3.6.7/lib/python3.6/site-packages/pluggy/manager.py", line 274, in load_setuptools_entrypoints
plugin = ep.load()
File "/Users/{name}/.pyenv/versions/3.6.7/lib/python3.6/site-packages/pkg_resources/init.py", line 2342, in load
self.require(*args, **kwargs)
File "/Users/{name}/.pyenv/versions/3.6.7/lib/python3.6/site-packages/pkg_resources/init.py", line 2365, in require
items = working_set.resolve(reqs, env, installer, extras=self.extras)
File "/Users/{name}/.pyenv/versions/3.6.7/lib/python3.6/site-packages/pkg_resources/init.py", line 786, in resolve
raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.ContextualVersionConflict: (pytest 4.3.1 (/Users//.pyenv/versions/3.6.7/lib/python3.6/site-packages), Requirement.parse('pytest<4.0.0'), {'pytest-fixture-config'})
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/helpers/pycharm/_jb_pytest_runner.py", line 31, in <module>
pytest.main(args, plugins_to_load)
File "/Users/{name}/.pyenv/versions/3.6.7/lib/python3.6/site-packages/_pytest/config/init.py", line 59, in main
config = _prepareconfig(args, plugins)
File "/Users/{name}/.pyenv/versions/3.6.7/lib/python3.6/site-packages/_pytest/config/init.py", line 194, in _prepareconfig
pluginmanager=pluginmanager, args=args
File "/Users/{name}/.pyenv/versions/3.6.7/lib/python3.6/site-packages/pluggy/hooks.py", line 289, in call
return self._hookexec(self, self.get_hookimpls(), kwargs)
File "/Users/{name}/.pyenv/versions/3.6.7/lib/python3.6/site-packages/pluggy/manager.py", line 68, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "/Users/{name}/.pyenv/versions/3.6.7/lib/python3.6/site-packages/pluggy/manager.py", line 62, in <lambda>
firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
File "/Users/{name}/.pyenv/versions/3.6.7/lib/python3.6/site-packages/pluggy/callers.py", line 203, in _multicall
gen.send(outcome)
File "/Users/{name}/.pyenv/versions/3.6.7/lib/python3.6/site-packages/_pytest/helpconfig.py", line 93, in pytest_cmdline_parse
config = outcome.get_result()
File "/Users/{name}/.pyenv/versions/3.6.7/lib/python3.6/site-packages/pluggy/callers.py", line 80, in get_result
raise ex[1].with_traceback(ex[2])
File "/Users/{name}/.pyenv/versions/3.6.7/lib/python3.6/site-packages/pluggy/callers.py", line 187, in _multicall
res = hook_impl.function(*args)
File "/Users/{name}/.pyenv/versions/3.6.7/lib/python3.6/site-packages/_pytest/config/init.py", line 653, in pytest_cmdline_parse
self.parse(args)
File "/Users/{name}/.pyenv/versions/3.6.7/lib/python3.6/site-packages/_pytest/config/init.py", line 870, in parse
self._preparse(args, addopts=addopts)
File "/Users/{name}/.pyenv/versions/3.6.7/lib/python3.6/site-packages/_pytest/config/init.py", line 815, in _preparse
self.pluginmanager.load_setuptools_entrypoints("pytest11")
File "/Users/{name}/.pyenv/versions/3.6.7/lib/python3.6/site-packages/pluggy/manager.py", line 280, in load_setuptools_entrypoints
message="Plugin %r could not be loaded: %s!" % (ep.name, e),
pluggy.manager.PluginValidationError: Plugin 'webdriver' could not be loaded: (pytest 4.3.1 (/Users/{name}/.pyenv/versions/3.6.7/lib/python3.6/site-packages), Requirement.parse('pytest<4.0.0'), {'pytest-fixture-config'})!
Currently running through venv on the command line.
I want to be able to run the same setup in pycharm as I do from CLI

Solved the issue: PyCharm had pytest-fixture-config installed. I had to remove the package and running my tests worked. pytest-fixture-config states Pinned pytest<4.0.0 until all deprecation warnings are fixed.

Related

Pip3: Cython error while installing spicy

This is my requirements.txt file below:
emoji==1.2.0
langdetect==1.0.8
Pillow==9.0.0
PyMySQL==0.10.1
pyOpenSSL==19.1.0
pytz==2020.1
redis==3.5.3
regex==2021.8.3
requests==2.24.0
selenium==3.141.0
nltk==3.6.6
cython==0.29.26
numpy==1.21.1
setuptools==59.6.0
scipy==1.5.4
geograpy3==0.2.2
geotext~=0.4.0
DateTime~=4.3
uuid~=1.30
Jinja2~=2.11.2
boto3==1.17.3
Traceback
Collecting selenium==3.141.0 (from -r requirements.txt (line 10))
Using cached https://files.pythonhosted.org/packages/80/d6/4294f0b4bce4de0abf13e17190289f9d0613b0a44e5dd6a7f5ca98459853/selenium-3.141.0-py2.py3-none-any.whl
Collecting nltk==3.6.6 (from -r requirements.txt (line 11))
Using cached https://files.pythonhosted.org/packages/90/35/8848a41a983a923aa2496fbe4ee4df796c6b32b2a59f04c2b2047aafd3c3/nltk-3.6.6-py3-none-any.whl
Collecting cython==0.29.26 (from -r requirements.txt (line 12))
Using cached https://files.pythonhosted.org/packages/15/29/2abb8975ded365d55b9e14129cabdfb977255911c80d8709028eca5829cd/Cython-0.29.26-py2.py3-none-any.whl
Collecting numpy==1.21.1 (from -r requirements.txt (line 13))
Using cached https://files.pythonhosted.org/packages/0b/a7/e724c8df240687b5fd62d8c71f1a6709d455c4c09432c7412e3e64f4cbe5/numpy-1.21.1.zip
Collecting setuptools==59.6.0 (from -r requirements.txt (line 14))
Using cached https://files.pythonhosted.org/packages/b0/3a/88b210db68e56854d0bcf4b38e165e03be377e13907746f825790f3df5bf/setuptools-59.6.0-py3-none-any.whl
Collecting scipy==1.5.4 (from -r requirements.txt (line 15))
Using cached https://files.pythonhosted.org/packages/aa/d5/dd06fe0e274e579e1dff21aa021219c039df40e39709fabe559faed072a5/scipy-1.5.4.tar.gz
Complete output from command python setup.py egg_info:
Processing numpy/random/_bounded_integers.pxd.in
Processing numpy/random/_philox.pyx
Traceback (most recent call last):
File "/tmp/easy_install-5cn5y70d/numpy-1.22.3/tools/cythonize.py", line 53, in process_pyx
import Cython
ModuleNotFoundError: No module named 'Cython'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/tmp/easy_install-5cn5y70d/numpy-1.22.3/tools/cythonize.py", line 234, in <module>
main()
File "/tmp/easy_install-5cn5y70d/numpy-1.22.3/tools/cythonize.py", line 230, in main
find_process_files(root_dir)
File "/tmp/easy_install-5cn5y70d/numpy-1.22.3/tools/cythonize.py", line 221, in find_process_files
process(root_dir, fromfile, tofile, function, hash_db)
File "/tmp/easy_install-5cn5y70d/numpy-1.22.3/tools/cythonize.py", line 187, in process
processor_function(fromfile, tofile)
File "/tmp/easy_install-5cn5y70d/numpy-1.22.3/tools/cythonize.py", line 60, in process_pyx
raise OSError(msg) from e
OSError: Cython needs to be installed in Python as a module
Running from numpy source directory.
Traceback (most recent call last):
File "/home/odroid/Documents/data-crawling-env/lib/python3.8/site-packages/setuptools/sandbox.py", line 154, in save_modules
yield saved
File "/home/odroid/Documents/data-crawling-env/lib/python3.8/site-packages/setuptools/sandbox.py", line 195, in setup_context
yield
File "/home/odroid/Documents/data-crawling-env/lib/python3.8/site-packages/setuptools/sandbox.py", line 250, in run_setup
_execfile(setup_script, ns)
File "/home/odroid/Documents/data-crawling-env/lib/python3.8/site-packages/setuptools/sandbox.py", line 45, in _execfile
exec(code, globals, locals)
File "/tmp/easy_install-5cn5y70d/numpy-1.22.3/setup.py", line 461, in <module>
"generating Cython sources and expanding templates".format(
File "/tmp/easy_install-5cn5y70d/numpy-1.22.3/setup.py", line 443, in setup_package
bad_commands[command] = "`setup.py %s` is not supported" % command
File "/tmp/easy_install-5cn5y70d/numpy-1.22.3/setup.py", line 248, in generate_cython
f.write(text)
RuntimeError: Running cythonize failed!
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-tqtljvxv/scipy/setup.py", line 583, in <module>
setup_package()
File "/tmp/pip-build-tqtljvxv/scipy/setup.py", line 579, in setup_package
setup(**metadata)
File "/home/odroid/Documents/data-crawling-env/lib/python3.8/site-packages/setuptools/__init__.py", line 128, in setup
_install_setup_requires(attrs)
File "/home/odroid/Documents/data-crawling-env/lib/python3.8/site-packages/setuptools/__init__.py", line 123, in _install_setup_requires
dist.fetch_build_eggs(dist.setup_requires)
File "/home/odroid/Documents/data-crawling-env/lib/python3.8/site-packages/setuptools/dist.py", line 510, in fetch_build_eggs
resolved_dists = pkg_resources.working_set.resolve(
File "/home/odroid/Documents/data-crawling-env/lib/python3.8/site-packages/pkg_resources/__init__.py", line 772, in resolve
dist = best[req.key] = env.best_match(
File "/home/odroid/Documents/data-crawling-env/lib/python3.8/site-packages/pkg_resources/__init__.py", line 1057, in best_match
return self.obtain(req, installer)
File "/home/odroid/Documents/data-crawling-env/lib/python3.8/site-packages/pkg_resources/__init__.py", line 1069, in obtain
return installer(requirement)
File "/home/odroid/Documents/data-crawling-env/lib/python3.8/site-packages/setuptools/dist.py", line 580, in fetch_build_egg
return cmd.easy_install(req)
File "/home/odroid/Documents/data-crawling-env/lib/python3.8/site-packages/setuptools/command/easy_install.py", line 698, in easy_install
return self.install_item(spec, dist.location, tmpdir, deps)
File "/home/odroid/Documents/data-crawling-env/lib/python3.8/site-packages/setuptools/command/easy_install.py", line 724, in install_item
dists = self.install_eggs(spec, download, tmpdir)
File "/home/odroid/Documents/data-crawling-env/lib/python3.8/site-packages/setuptools/command/easy_install.py", line 909, in install_eggs
return self.build_and_install(setup_script, setup_base)
File "/home/odroid/Documents/data-crawling-env/lib/python3.8/site-packages/setuptools/command/easy_install.py", line 1177, in build_and_install
self.run_setup(setup_script, setup_base, args)
File "/home/odroid/Documents/data-crawling-env/lib/python3.8/site-packages/setuptools/command/easy_install.py", line 1163, in run_setup
run_setup(setup_script, args)
File "/home/odroid/Documents/data-crawling-env/lib/python3.8/site-packages/setuptools/sandbox.py", line 253, in run_setup
raise
File "/usr/lib/python3.8/contextlib.py", line 131, in __exit__
self.gen.throw(type, value, traceback)
File "/home/odroid/Documents/data-crawling-env/lib/python3.8/site-packages/setuptools/sandbox.py", line 195, in setup_context
yield
File "/usr/lib/python3.8/contextlib.py", line 131, in __exit__
self.gen.throw(type, value, traceback)
File "/home/odroid/Documents/data-crawling-env/lib/python3.8/site-packages/setuptools/sandbox.py", line 166, in save_modules
saved_exc.resume()
File "/home/odroid/Documents/data-crawling-env/lib/python3.8/site-packages/setuptools/sandbox.py", line 141, in resume
six.reraise(type, exc, self._tb)
File "/home/odroid/Documents/data-crawling-env/lib/python3.8/site-packages/setuptools/_vendor/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/home/odroid/Documents/data-crawling-env/lib/python3.8/site-packages/setuptools/sandbox.py", line 154, in save_modules
yield saved
File "/home/odroid/Documents/data-crawling-env/lib/python3.8/site-packages/setuptools/sandbox.py", line 195, in setup_context
yield
File "/home/odroid/Documents/data-crawling-env/lib/python3.8/site-packages/setuptools/sandbox.py", line 250, in run_setup
_execfile(setup_script, ns)
File "/home/odroid/Documents/data-crawling-env/lib/python3.8/site-packages/setuptools/sandbox.py", line 45, in _execfile
exec(code, globals, locals)
File "/tmp/easy_install-5cn5y70d/numpy-1.22.3/setup.py", line 461, in <module>
"generating Cython sources and expanding templates".format(
File "/tmp/easy_install-5cn5y70d/numpy-1.22.3/setup.py", line 443, in setup_package
bad_commands[command] = "`setup.py %s` is not supported" % command
File "/tmp/easy_install-5cn5y70d/numpy-1.22.3/setup.py", line 248, in generate_cython
f.write(text)
RuntimeError: Running cythonize failed!
Cythonizing sources
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-tqtljvxv/scipy/
It looks like related to Cython in spicy package? Does anyone got this error.
Thank you guy for helping me.
I fixed this problem.
The reason is my pip3 version was too old (v.9).
So I updated it to the newest version, it work like charm.
sudo python3 -m pip install -U pip

'pipenv install' fails with TypeError: must be str, not type

Here's the full error log -
C:\Dev\libpython\src>pipenv install
Creating a virtualenv for this project…
Pipfile: C:\Dev\libpython\src\Pipfile
Using C:/Python/Python36-64/python.exe (3.6.6) to create virtualenv…
Running virtualenv with interpreter C:/Python/Python36-64/python.exe
Using base prefix 'C:\\Python\\Python36-64'
New python executable in C:\Users\Pulkit\.virtualenvs\src-PtwTDfFP\Scripts\python.exe
Cannot find a wheel for pip
Installing setuptools, pip, wheel...
Complete output from command C:\Users\Pulkit\.vir...P\Scripts\python.exe - setuptools pip wheel:
Traceback (most recent call last):
File "<stdin>", line 8, in <module>
ModuleNotFoundError: No module named 'pip'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 11, in <module>
ModuleNotFoundError: No module named 'pip'
----------------------------------------
...Installing setuptools, pip, wheel...done.
Traceback (most recent call last):
File "c:\python\python36-64\lib\site-packages\virtualenv.py", line 2343, in <module>
main()
File "c:\python\python36-64\lib\site-packages\virtualenv.py", line 712, in main
symlink=options.symlink)
File "c:\python\python36-64\lib\site-packages\virtualenv.py", line 947, in create_environment
download=download,
File "c:\python\python36-64\lib\site-packages\virtualenv.py", line 904, in install_wheel
call_subprocess(cmd, show_stdout=False, extra_env=env, stdin=SCRIPT)
File "c:\python\python36-64\lib\site-packages\virtualenv.py", line 796, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command C:\Users\Pulkit\.vir...P\Scripts\python.exe - setuptools pip wheel failed with error code 1
Traceback (most recent call last):
File "c:\python\python36-64\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\python\python36-64\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Python\Python36-64\Scripts\pipenv.exe\__main__.py", line 9, in <module>
File "c:\python\python36-64\lib\site-packages\pipenv\vendor\click\core.py", line 764, in __call__
return self.main(*args, **kwargs)
File "c:\python\python36-64\lib\site-packages\pipenv\vendor\click\core.py", line 717, in main
rv = self.invoke(ctx)
File "c:\python\python36-64\lib\site-packages\pipenv\vendor\click\core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "c:\python\python36-64\lib\site-packages\pipenv\vendor\click\core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "c:\python\python36-64\lib\site-packages\pipenv\vendor\click\core.py", line 555, in invoke
return callback(*args, **kwargs)
File "c:\python\python36-64\lib\site-packages\pipenv\vendor\click\decorators.py", line 64, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "c:\python\python36-64\lib\site-packages\pipenv\vendor\click\core.py", line 555, in invoke
return callback(*args, **kwargs)
File "c:\python\python36-64\lib\site-packages\pipenv\vendor\click\decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "c:\python\python36-64\lib\site-packages\pipenv\cli\command.py", line 249, in install
editable_packages=state.installstate.editables,
File "c:\python\python36-64\lib\site-packages\pipenv\core.py", line 1724, in do_install
pypi_mirror=pypi_mirror,
File "c:\python\python36-64\lib\site-packages\pipenv\core.py", line 565, in ensure_project
pypi_mirror=pypi_mirror,
File "c:\python\python36-64\lib\site-packages\pipenv\core.py", line 500, in ensure_virtualenv
python=python, site_packages=site_packages, pypi_mirror=pypi_mirror
File "c:\python\python36-64\lib\site-packages\pipenv\core.py", line 901, in do_create_virtualenv
click.echo(crayons.blue("{0}".format(c.err)), err=True)
File "c:\python\python36-64\lib\site-packages\pipenv\vendor\delegator.py", line 146, in err
return self._pexpect_out
File "c:\python\python36-64\lib\site-packages\pipenv\vendor\delegator.py", line 114, in _pexpect_out
result += self.subprocess.after
TypeError: must be str, not type
I have tried downgrading pip from (18.1 to 9.0.1) and also downgrading pipenv, it did not resolve the issue.
This stupid policy keeps telling to add more details, hence everything after this is only a filler.
I was so happy to publish my first package in pypa but then this stupid issue happened. I have wasted a lot of time already.
Manged to fix the issue temporarily by downgrading virtualenv -
pip install virtualenv==15.* --upgrade

Failing to initialize pipenv in mac (TypeError: sequence item 0: expected str instance, NoneType found)

I'm a Mac user, and I frequently face frustrations when installing python packages.
This time, pipenv seems not working properly.
I successfully installed pipenv.
$pipenv --version
pipenv, version 11.10.1
However, When I try to init pipenv shell, I got error like this:
Creating a virtualenv for this project…
Using /Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6 (3.6.4) to create virtualenv…
⠋Already using interpreter /Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6
Using base prefix '/Library/Frameworks/Python.framework/Versions/3.6'
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/virtualenv.py", line 2349, in <module>
main()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/virtualenv.py", line 712, in main
symlink=options.symlink)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/virtualenv.py", line 927, in create_environment
site_packages=site_packages, clear=clear, symlink=symlink))
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/virtualenv.py", line 1140, in install_python
copy_required_modules(home_dir, symlink)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/virtualenv.py", line 1070, in copy_required_modules
dst_filename = change_prefix(filename, dst_prefix)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/virtualenv.py", line 1044, in change_prefix
(filename, prefixes)
AssertionError: Filename /Users/ChaewonKong/Desktop/dev/re.py does not start with any of these prefixes: ['/Library/Frameworks/Python.framework/Versions/3.6/Extras/lib/python', '/Users/ChaewonKong/Library/Python/3.6/lib/python/site-packages', '/Users/ChaewonKong/.local/lib/python/3.6/site-packages', '/Users/ChaewonKong/Library/Python/3.6/site-packages', '/Library/Frameworks/Python.framework/Versions/3.6', '/Library/Frameworks/Python.framework/Versions/3.6', '/Library/Python/3.6/site-packages']
Virtualenv location:
Creating a Pipfile for this project…
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/bin/pipenv", line 11, in <module>
sys.exit(cli())
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pipenv/cli.py", line 607, in shell
three=three, python=python, fancy=fancy, shell_args=shell_args
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pipenv/core.py", line 2149, in do_shell
ensure_project(three=three, python=python, validate=False)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pipenv/core.py", line 648, in ensure_project
ensure_pipfile(validate=validate, skip_requirements=skip_requirements, system=system)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pipenv/core.py", line 302, in ensure_pipfile
project.create_pipfile(python=python)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pipenv/project.py", line 588, in create_pipfile
required_python = self.which('python')
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pipenv/core.py", line 126, in which
p = os.sep.join([location] + ['bin/{0}'.format(command)])
TypeError: sequence item 0: expected str instance, NoneType found
This pipenv issues page has the answer you are looking for:
TypeError issue

Setup script exited with error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 while Installing PyNaCl

I'm trying to install PyNaCl on Ubuntu 16.04 and I'm getting the error on the title; this is the whole traceback:
Collecting PyNaCl
Using cached PyNaCl-1.0.1.tar.gz
Complete output from command python setup.py egg_info:
Package libffi was not found in the pkg-config search path.
Perhaps you should add the directory containing `libffi.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libffi' found
Package libffi was not found in the pkg-config search path.
Perhaps you should add the directory containing `libffi.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libffi' found
Package libffi was not found in the pkg-config search path.
Perhaps you should add the directory containing `libffi.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libffi' found
Package libffi was not found in the pkg-config search path.
Perhaps you should add the directory containing `libffi.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libffi' found
Package libffi was not found in the pkg-config search path.
Perhaps you should add the directory containing `libffi.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libffi' found
warning: build_py: byte-compiling is disabled, skipping.
c/_cffi_backend.c:15:17: fatal error: ffi.h: No such file or directory
compilation terminated.
Traceback (most recent call last):
File "/usr/lib/python3.5/distutils/unixccompiler.py", line 118, in _compile
extra_postargs)
File "/usr/lib/python3.5/distutils/ccompiler.py", line 909, in spawn
spawn(cmd, dry_run=self.dry_run)
File "/usr/lib/python3.5/distutils/spawn.py", line 36, in spawn
_spawn_posix(cmd, search_path, dry_run=dry_run)
File "/usr/lib/python3.5/distutils/spawn.py", line 159, in _spawn_posix
% (cmd, exit_status))
distutils.errors.DistutilsExecError: command 'x86_64-linux-gnu-gcc' failed with exit status 1
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.5/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/lib/python3.5/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/usr/lib/python3.5/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/home/miguel/PycharmProjects/Crossed/Crossedenv/lib/python3.5/site-packages/setuptools/command/bdist_egg.py", line 161, in run
cmd = self.call_command('install_lib', warn_dir=0)
File "/home/miguel/PycharmProjects/Crossed/Crossedenv/lib/python3.5/site-packages/setuptools/command/bdist_egg.py", line 147, in call_command
self.run_command(cmdname)
File "/usr/lib/python3.5/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib/python3.5/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/home/miguel/PycharmProjects/Crossed/Crossedenv/lib/python3.5/site-packages/setuptools/command/install_lib.py", line 11, in run
self.build()
File "/usr/lib/python3.5/distutils/command/install_lib.py", line 109, in build
self.run_command('build_ext')
File "/usr/lib/python3.5/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib/python3.5/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/home/miguel/PycharmProjects/Crossed/Crossedenv/lib/python3.5/site-packages/setuptools/command/build_ext.py", line 75, in run
_build_ext.run(self)
File "/usr/lib/python3.5/distutils/command/build_ext.py", line 338, in run
self.build_extensions()
File "/usr/lib/python3.5/distutils/command/build_ext.py", line 447, in build_extensions
self._build_extensions_serial()
File "/usr/lib/python3.5/distutils/command/build_ext.py", line 472, in _build_extensions_serial
self.build_extension(ext)
File "/home/miguel/PycharmProjects/Crossed/Crossedenv/lib/python3.5/site-packages/setuptools/command/build_ext.py", line 196, in build_extension
_build_ext.build_extension(self, ext)
File "/usr/lib/python3.5/distutils/command/build_ext.py", line 532, in build_extension
depends=ext.depends)
File "/usr/lib/python3.5/distutils/ccompiler.py", line 574, in compile
self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
File "/usr/lib/python3.5/distutils/unixccompiler.py", line 120, in _compile
raise CompileError(msg)
distutils.errors.CompileError: command 'x86_64-linux-gnu-gcc' failed with exit status 1
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/miguel/PycharmProjects/Crossed/Crossedenv/lib/python3.5/site-packages/setuptools/sandbox.py", line 157, in save_modules
yield saved
File "/home/miguel/PycharmProjects/Crossed/Crossedenv/lib/python3.5/site-packages/setuptools/sandbox.py", line 198, in setup_context
yield
File "/home/miguel/PycharmProjects/Crossed/Crossedenv/lib/python3.5/site-packages/setuptools/sandbox.py", line 248, in run_setup
DirectorySandbox(setup_dir).run(runner)
File "/home/miguel/PycharmProjects/Crossed/Crossedenv/lib/python3.5/site-packages/setuptools/sandbox.py", line 278, in run
return func()
File "/home/miguel/PycharmProjects/Crossed/Crossedenv/lib/python3.5/site-packages/setuptools/sandbox.py", line 246, in runner
_execfile(setup_script, ns)
File "/home/miguel/PycharmProjects/Crossed/Crossedenv/lib/python3.5/site-packages/setuptools/sandbox.py", line 47, in _execfile
exec(code, globals, locals)
File "/tmp/easy_install-ek_ikn33/cffi-1.8.3/setup.py", line 193, in <module>
subprocess.check_call(["make", "check"], cwd=build_temp)
File "/usr/lib/python3.5/distutils/core.py", line 163, in setup
raise SystemExit("error: " + str(msg))
SystemExit: error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/miguel/PycharmProjects/Crossed/Crossedenv/lib/python3.5/site-packages/setuptools/command/easy_install.py", line 1101, in run_setup
run_setup(setup_script, args)
File "/home/miguel/PycharmProjects/Crossed/Crossedenv/lib/python3.5/site-packages/setuptools/sandbox.py", line 251, in run_setup
raise
File "/usr/lib/python3.5/contextlib.py", line 77, in __exit__
self.gen.throw(type, value, traceback)
File "/home/miguel/PycharmProjects/Crossed/Crossedenv/lib/python3.5/site-packages/setuptools/sandbox.py", line 198, in setup_context
yield
File "/usr/lib/python3.5/contextlib.py", line 77, in __exit__
self.gen.throw(type, value, traceback)
File "/home/miguel/PycharmProjects/Crossed/Crossedenv/lib/python3.5/site-packages/setuptools/sandbox.py", line 169, in save_modules
saved_exc.resume()
File "/home/miguel/PycharmProjects/Crossed/Crossedenv/lib/python3.5/site-packages/setuptools/sandbox.py", line 144, in resume
six.reraise(type, exc, self._tb)
File "/home/miguel/PycharmProjects/Crossed/Crossedenv/lib/python3.5/site-packages/pkg_resources/_vendor/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/home/miguel/PycharmProjects/Crossed/Crossedenv/lib/python3.5/site-packages/setuptools/sandbox.py", line 157, in save_modules
yield saved
File "/home/miguel/PycharmProjects/Crossed/Crossedenv/lib/python3.5/site-packages/setuptools/sandbox.py", line 198, in setup_context
yield
File "/home/miguel/PycharmProjects/Crossed/Crossedenv/lib/python3.5/site-packages/setuptools/sandbox.py", line 248, in run_setup
DirectorySandbox(setup_dir).run(runner)
File "/home/miguel/PycharmProjects/Crossed/Crossedenv/lib/python3.5/site-packages/setuptools/sandbox.py", line 278, in run
return func()
File "/home/miguel/PycharmProjects/Crossed/Crossedenv/lib/python3.5/site-packages/setuptools/sandbox.py", line 246, in runner
_execfile(setup_script, ns)
File "/home/miguel/PycharmProjects/Crossed/Crossedenv/lib/python3.5/site-packages/setuptools/sandbox.py", line 47, in _execfile
exec(code, globals, locals)
File "/tmp/easy_install-ek_ikn33/cffi-1.8.3/setup.py", line 193, in <module>
subprocess.check_call(["make", "check"], cwd=build_temp)
File "/usr/lib/python3.5/distutils/core.py", line 163, in setup
raise SystemExit("error: " + str(msg))
SystemExit: error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pycharm-packaging/PyNaCl/setup.py", line 259, in <module>
"Programming Language :: Python :: 3.5",
File "/usr/lib/python3.5/distutils/core.py", line 108, in setup
_setup_distribution = dist = klass(attrs)
File "/home/miguel/PycharmProjects/Crossed/Crossedenv/lib/python3.5/site-packages/setuptools/dist.py", line 315, in __init__
self.fetch_build_eggs(attrs['setup_requires'])
File "/home/miguel/PycharmProjects/Crossed/Crossedenv/lib/python3.5/site-packages/setuptools/dist.py", line 361, in fetch_build_eggs
replace_conflicting=True,
File "/home/miguel/PycharmProjects/Crossed/Crossedenv/lib/python3.5/site-packages/pkg_resources/__init__.py", line 826, in resolve
dist = best[req.key] = env.best_match(req, ws, installer)
File "/home/miguel/PycharmProjects/Crossed/Crossedenv/lib/python3.5/site-packages/pkg_resources/__init__.py", line 1092, in best_match
return self.obtain(req, installer)
File "/home/miguel/PycharmProjects/Crossed/Crossedenv/lib/python3.5/site-packages/pkg_resources/__init__.py", line 1104, in obtain
return installer(requirement)
File "/home/miguel/PycharmProjects/Crossed/Crossedenv/lib/python3.5/site-packages/setuptools/dist.py", line 429, in fetch_build_egg
return cmd.easy_install(req)
File "/home/miguel/PycharmProjects/Crossed/Crossedenv/lib/python3.5/site-packages/setuptools/command/easy_install.py", line 665, in easy_install
return self.install_item(spec, dist.location, tmpdir, deps)
File "/home/miguel/PycharmProjects/Crossed/Crossedenv/lib/python3.5/site-packages/setuptools/command/easy_install.py", line 695, in install_item
dists = self.install_eggs(spec, download, tmpdir)
File "/home/miguel/PycharmProjects/Crossed/Crossedenv/lib/python3.5/site-packages/setuptools/command/easy_install.py", line 876, in install_eggs
return self.build_and_install(setup_script, setup_base)
File "/home/miguel/PycharmProjects/Crossed/Crossedenv/lib/python3.5/site-packages/setuptools/command/easy_install.py", line 1115, in build_and_install
self.run_setup(setup_script, setup_base, args)
File "/home/miguel/PycharmProjects/Crossed/Crossedenv/lib/python3.5/site-packages/setuptools/command/easy_install.py", line 1103, in run_setup
raise DistutilsError("Setup script exited with %s" % (v.args[0],))
distutils.errors.DistutilsError: Setup script exited with error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pycharm-packaging/PyNaCl/
I searched some workarounds that worked for other people but they're for oter packages and didn't work for me. Thanks for any help.
Looks like you are missing CFFI, which also has a couple of dependencies. According to this you need to install a couple of dependencies, probably python-dev and libffi-dev.

Heroku using django and twisted

I want put my working app on Heroku. The application using Django and chat based on Twisted websockets. I don't know it's good approach but I installed twisted via heroku bash, but when i want to run my chatserver.py I have an exception because some Twisted module requires OpenSSL which is not installed on my env.
So simply question, how to install Twisted to work with websocket on Heroku?
Update
when I run twistd -n -y chatserver.py:
Unhandled Error
Traceback (most recent call last):
File "/app/.heroku/python/lib/python2.7/site-packages/Twisted-13.1.0-py2.7-linux-x86_64.egg/twisted/application/app.py", line 652, in run
runApp(config)
File "/app/.heroku/python/lib/python2.7/site-packages/Twisted-13.1.0-py2.7-linux-x86_64.egg/twisted/scripts/twistd.py", line 23, in runApp
_SomeApplicationRunner(config).run()
File "/app/.heroku/python/lib/python2.7/site-packages/Twisted-13.1.0-py2.7-linux-x86_64.egg/twisted/application/app.py", line 386, in run
self.application = self.createOrGetApplication()
File "/app/.heroku/python/lib/python2.7/site-packages/Twisted-13.1.0-py2.7-linux-x86_64.egg/twisted/application/app.py", line 451, in createOrGetApplication
application = getApplication(self.config, passphrase)
--- <exception caught here> ---
File "/app/.heroku/python/lib/python2.7/site-packages/Twisted-13.1.0-py2.7-linux-x86_64.egg/twisted/application/app.py", line 462, in getApplication
application = service.loadApplication(filename, style, passphrase)
File "/app/.heroku/python/lib/python2.7/site-packages/Twisted-13.1.0-py2.7-linux-x86_64.egg/twisted/application/service.py", line 405, in loadApplication
application = sob.loadValueFromFile(filename, 'application', passphrase)
File "/app/.heroku/python/lib/python2.7/site-packages/Twisted-13.1.0-py2.7-linux-x86_64.egg/twisted/persisted/sob.py", line 210, in loadValueFromFile
exec fileObj in d, d
File "chatserver.py", line 37, in <module>
from twisted.web.websockets import WebSocketsResource, lookupProtocolForFactory
File "/app/.heroku/python/lib/python2.7/site-packages/Twisted-13.1.0-py2.7-linux-x86_64.egg/twisted/web/websockets.py", line 28, in <module>
from twisted.protocols.tls import TLSMemoryBIOProtocol
File "/app/.heroku/python/lib/python2.7/site-packages/Twisted-13.1.0-py2.7-linux-x86_64.egg/twisted/protocols/tls.py", line 40, in <module>
from OpenSSL.SSL import Error, ZeroReturnError, WantReadError
exceptions.ImportError: No module named OpenSSL.SSL
Failed to load application: No module named OpenSSL.SSL
So when I try to install openssl with command: pip install pyopenssl
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "/tmp/pip_build_u12732/cryptography/setup.py", line 174, in <module>
"test": PyTest,
File "/app/.heroku/python/lib/python2.7/distutils/core.py", line 111, in setup
_setup_distribution = dist = klass(attrs)
File "build/bdist.linux-x86_64/egg/setuptools/dist.py", line 260, in __init__
File "build/bdist.linux-x86_64/egg/setuptools/dist.py", line 285, in fetch_build_eggs
File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 631, in resolve
File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 871, in best_match
File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 883, in obtain
File "build/bdist.linux-x86_64/egg/setuptools/dist.py", line 335, in fetch_build_egg
File "build/bdist.linux-x86_64/egg/setuptools/command/easy_install.py", line 595, in easy_install
File "build/bdist.linux-x86_64/egg/setuptools/command/easy_install.py", line 625, in install_item
File "build/bdist.linux-x86_64/egg/setuptools/command/easy_install.py", line 822, in install_eggs
File "build/bdist.linux-x86_64/egg/setuptools/command/easy_install.py", line 1028, in build_and_install
File "build/bdist.linux-x86_64/egg/setuptools/command/easy_install.py", line 1016, in run_setup
distutils.errors.DistutilsError: Setup script exited with error: command 'gcc' failed with exit status 1
----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_u12732/cryptography
Traceback (most recent call last):
File "/app/.heroku/python/bin/pip", line 9, in <module>
load_entry_point('pip==1.5.6', 'console_scripts', 'pip')()
File "/app/.heroku/python/lib/python2.7/site-packages/pip-1.5.6-py2.7.egg/pip/__init__.py", line 185, in main
return command.main(cmd_args)
File "/app/.heroku/python/lib/python2.7/site-packages/pip-1.5.6-py2.7.egg/pip/basecommand.py", line 161, in main
text = '\n'.join(complete_log)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 75: ordinal not in range(128)

Categories