DistributionNotFound when trying to run console script in setup.py - python

I created a virtualenv with python2.7 a few weeks ago and got this project running fine. It uses setuptools and has a few console scripts defined.
Now today I installed python3 and pip3, which I didn't think would conflict with this project but I'm running into this error when I try to run the same console script.
pkg_resources.DistributionNotFound: myproject==1.0.0.0-local
Traceback (most recent call last):
File "/Users/me/dev/myproject/venv-myproject/bin/run_queue_worker_manager", line 5, in <module>
from pkg_resources import load_entry_point
File "/Users/me/dev/project/venv-myproject/lib/python2.7/site-packages/pkg_resources.py", line 2720, in <module>
parse_requirements(__requires__), Environment()
File "/Users/me/dev/project/venv-myproject/lib/python2.7/site-packages/pkg_resources.py", line 588, in resolve
raise DistributionNotFound(req)

Related

Python ide thonny installation error in ubuntu

I am facing the below issue while installing thonny ide for python.
Traceback (most recent call last):
File "/home/shrivatsa/.local/lib/python3.5/site-packages/thonny/workbench.py", line 287, in _init_runner runner.start()
File "/home/shrivatsa/.local/lib/python3.5/site-packages/thonny/running.py", line 67, instart self.reset_backend()
File "/home/shrivatsa/.local/lib/python3.5/site-packages/thonny/running.py", line 427, in reset_backend self._proxy = backend_class(configuraration_option)
File "/home/shrivatsa/.local/lib/python3.5/site-packages/thonny/running.py", line 596, in __init__ self._start_new_process()
File "/home/shrivatsa/.local/lib/python3.5/site-packages/thonny/running.py", line 762, in _start_new_process my_env["JEDI_LOCATION"] = self_prepare_jedi()
File "/home/shrivatsa/.local/lib/python3.5/site-packages/thonny/running.py", line 703, in _prepare_jedi import jedi ImportError: No module named 'jedi'
The application launches but no run button and dedug button is active.
As the error message shows you are missing the module named "jedi".
Try to install it before installing the IDE:
pip install jedi
According to Thonny blog, this IDE uses Jedi (autocompletion/static analysis library). So make sure it also installed (via pip, for example).

Python external on Azure ImportError No Module Found

If i locally run my code with python main.py, then this error occurs locally. If i run it with python3 main.py, it works as expected. I suspect my azure app service is not running the correct version of python, however, it is set to python 3.4
StdErr:
2018-06-30 19:47:13.785205: Unhandled exception in wfastcgi.py: Traceback (most recent call last):
File "D:\Python34\Scripts\wfastcgi.py", line 711, in main
env, handler = read_wsgi_handler(response.physical_path)
File "D:\Python34\Scripts\wfastcgi.py", line 568, in read_wsgi_handler
return env, get_wsgi_handler(handler_name)
File "D:\Python34\Scripts\wfastcgi.py", line 541, in get_wsgi_handler
handler = handler()
File ".\ptvs_virtualenv_proxy.py", line 120, in get_venv_handler
handler = get_wsgi_handler(os.getenv('WSGI_ALT_VIRTUALENV_HANDLER'))
File ".\ptvs_virtualenv_proxy.py", line 89, in get_wsgi_handler
raise ValueError('"%s" could not be imported%s' % (handler_name, last_tb))
ValueError: "main.app" could not be imported: Traceback (most recent call last):
File ".\ptvs_virtualenv_proxy.py", line 73, in get_wsgi_handler
handler = __import__(module_name, fromlist=[name_list[0][0]])
File "D:\home\site\wwwroot\main.py", line 2, in <module>
from newspaper import Article
ImportError: No module named 'newspaper'
UPDATE
So I went to the debug console in kudo and i ran python
-m pip install --upgrade -r d:\home\site\wwwroot\requirements.txt.
Here is the error
ERROR: b"'xslt-config' is not recognized as an internal or external command,\r\noperable program or batch file.\r\n" ** make sure the development packages of libxml2 and libxslt are installed ** Using build configuration of libxslt
One of the requirements is Pillow which requires libxml2 and libxslt. I've tried using wheels however, I've had no success.
UPDATE II
I tried to install virtualenv since it does not exist and I receive a permissions error.
UPDATE III
I ran this command
D:\home\python364x64>python -m pip install newspaper3k
I test everything locally, and it works perfect. I push and receive this error below.
Error occurred while reading WSGI handler:
Traceback (most recent call last):
File "D:\home\python364x64\wfastcgi.py", line 791, in main
env, handler = read_wsgi_handler(response.physical_path)
File "D:\home\python364x64\wfastcgi.py", line 633, in read_wsgi_handler
handler = get_wsgi_handler(os.getenv("WSGI_HANDLER"))
File "D:\home\python364x64\wfastcgi.py", line 600, in get_wsgi_handler
handler = __import__(module_name, fromlist=[name_list[0][0]])
File ".\app.py", line 8, in <module>
from newspaper import Article
File "D:\home\python364x64\lib\site-packages\newspaper\__init__.py", line 10, in <module>
from .api import (build, build_article, fulltext, hot, languages,
File "D:\home\python364x64\lib\site-packages\newspaper\api.py", line 12, in <module>
import feedparser
File "D:\home\python364x64\lib\site-packages\feedparser.py", line 316
raise KeyError, "object doesn't have key 'category'"
^
SyntaxError: invalid syntax
StdOut:
StdErr:
Per my experience, we have no permission to modify D:\home environment.
So , It's better to use python extension. Please follow the steps in this case: Azure Flask Routes Not found and use command python -m pip install newspaper to install additional packages in python extension.
Please make sure the package you want to install must match with version of python extension. Otherwise, it will throw error as follows.
Hope it helps you.

Running my Python script in my virtual env?

Total python noob here, I want to run my .py flask api file, i cd to my directory, activate my python virtual env, then i try run.py
Issue is that it prints:
$ python run.py
Traceback (most recent call last): File "run.py", line 1, in
from flask_sqlalchemy import SQLAlchemy ImportError: No module named flask_sqlalchemy
As far as im aware as im in my virtualenv and have my packages installed, this shouldnt happen. Trying to pip3 install on any packages shows them as already existing.
To further assist with the issue, i tried to run the script inside pycharm and i get the following error prints in the log:`Traceback (most recent call last):
File "/Users/Jack/Developer/Python/lift_api/run.py", line 26, in <module>
sqlAlchemy.create_all()
File "/Users/Jack/Developer/Python/lift_api/liftapi/lib/python3.6/site-packages/flask_sqlalchemy/__init__.py", line 1007, in create_all
self._execute_for_all_tables(app, bind, 'create_all')
File "/Users/Jack/Developer/Python/lift_api/liftapi/lib/python3.6/site-packages/flask_sqlalchemy/__init__.py", line 999, in _execute_for_all_tables
op(bind=self.get_engine(app, bind), **extra)
File "/Users/Jack/Developer/Python/lift_api/liftapi/lib/python3.6/site-packages/flask_sqlalchemy/__init__.py", line 941, in get_engine
return connector.get_engine()
File "/Users/Jack/Developer/Python/lift_api/liftapi/lib/python3.6/site-packages/flask_sqlalchemy/__init__.py", line 543, in get_engine
self._engine = rv = sqlalchemy.create_engine(info, **options)
File "/Users/Jack/Developer/Python/lift_api/liftapi/lib/python3.6/site-packages/sqlalchemy/engine/__init__.py", line 387, in create_engine
return strategy.create(*args, **kwargs)
File "/Users/Jack/Developer/Python/lift_api/liftapi/lib/python3.6/site-packages/sqlalchemy/engine/strategies.py", line 80, in create
dbapi = dialect_cls.dbapi(**dbapi_args)
File "/Users/Jack/Developer/Python/lift_api/liftapi/lib/python3.6/site-packages/sqlalchemy/dialects/postgresql/psycopg2.py", line 554, in dbapi
import psycopg2
ModuleNotFoundError: No module named 'psycopg2'`
Anyone have an idea?
To run your code with python 3.x use python3 command.
python3 run.py
What is saying what it needs - psycopg2. If you are on Ubuntu it can help:
sudo apt install libpq-dev python-dev
Then don't forget to install flask-sqlalchemy and other libraries while your virtualenv activated.

Getting an error when trying to create a virtual env

I want to learn django so I tried to create a virtual env and I am getting this error:
mkvirtualenv django
Traceback (most recent call last):
File "/usr/local/bin/virtualenv", line 5, in <module>
from pkg_resources import load_entry_point
File "/Library/Python/2.7/site-packages/distribute-0.6.49-py2.7.egg/pkg_resources.py", line 2881, in <module>
parse_requirements(__requires__), Environment()
File "/Library/Python/2.7/site-packages/distribute-0.6.49-py2.7.egg/pkg_resources.py", line 596, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: virtualenv==1.8.2
I haven't used python in a while so i'm not sure what the issue is:
virtualenv --version
Traceback (most recent call last):
File "/usr/local/bin/virtualenv", line 5, in <module>
from pkg_resources import load_entry_point
File "/Library/Python/2.7/site-packages/distribute-0.6.49-py2.7.egg/pkg_resources.py", line 2881, in <module>
parse_requirements(__requires__), Environment()
File "/Library/Python/2.7/site-packages/distribute-0.6.49-py2.7.egg/pkg_resources.py", line 596, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: virtualenv==1.8.2
You're using mkvirtualenv which is a virtualenvwrapper command. You probably do not have virtualenvwrapper installed.
Type virtualenvwrapper in your command line and observe the input. If you get something like command not found, then you should install it first.
You should install it with pip like so pip install virtualenvwrapper.
There are some post-installation steps, the most important one being source /usr/local/bin/virtualenvwrapper.sh that makes commands like mkvirtualenv, rmvirtualenv available.
See virtualenvwrapper's documentation.
Alternatively, you can also just make use of virtualenv. Check that you have it installed like so
virtualenv --version
If you do not, you can install it with pip. Once you have it installed, you can create your virtualenv like so
virtualenv <name> in the directory of your choice.

tox Invocation failed for Python 3

tox runs my Python 2.7 tests, but fails for Python 3.4. It gives an "Invocation failed" message. Excerpts:
py34 create: /home/josh/code/ezoutlet/.tox/py34
ERROR: invocation failed (exit code 1), logfile: /home/josh/code/ezoutlet/.tox/py34/log/py34-0.log
ERROR: actionid: py34
msg: getenv
cmdargs: ['/usr/bin/python', '-m', 'virtualenv', '--python', '/usr/bin/python3.4', 'py34']
And later
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 8, in <module>
import base64
File "/usr/lib/python3.4/base64.py", line 9, in <module>
import re
File "/usr/lib/python3.4/re.py", line 336, in <module>
import copyreg
File "/usr/local/lib/python2.7/dist-packages/copyreg/__init__.py", line 7, in <module>
raise ImportError('This package should not be accessible on Python 3. '
ImportError: This package should not be accessible on Python 3. Either you are trying to run from the python-future src folder or your installation of python-future is corrupted.
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 53, in apport_excepthook
if not enabled():
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 24, in enabled
import re
File "/usr/lib/python3.4/re.py", line 336, in <module>
import copyreg
File "/usr/local/lib/python2.7/dist-packages/copyreg/__init__.py", line 7, in <module>
raise ImportError('This package should not be accessible on Python 3. '
ImportError: This package should not be accessible on Python 3. Either you are trying to run from the python-future src folder or your installation of python-future is corrupted.
Original exception was:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 8, in <module>
import base64
File "/usr/lib/python3.4/base64.py", line 9, in <module>
import re
File "/usr/lib/python3.4/re.py", line 336, in <module>
import copyreg
File "/usr/local/lib/python2.7/dist-packages/copyreg/__init__.py", line 7, in <module>
raise ImportError('This package should not be accessible on Python 3. '
ImportError: This package should not be accessible on Python 3. Either you are trying to run from the python-future src folder or your installation of python-future is corrupted.
Running virtualenv with interpreter /usr/bin/python3.4
ERROR: InvocationError: /usr/bin/python -m virtualenv --python /usr/bin/python3.4 py34 (see /home/josh/code/ezoutlet/.tox/py34/log/py34-0.log)
You need to look at the details of the error message. Notice the command that failed (from the first excerpt):
cmdargs: ['/usr/bin/python', '-m', 'virtualenv', '--python', '/usr/bin/python3.4', 'py34']
You can run this manually with:
/usr/bin/python -m virtualenv --python /usr/bin/python3.4 py34
Assuming you see the same error, your issue is with virtualenv rather than tox.
I reviewed the virtualenv help page and it seems like this should work. Faced with a possible bug, a good first step is to upgrade Python, virtualenv, or other libraries.
In my case, upgrading virtualenv was the solution:
pip install --upgrade virtualenv
Interestingly, this solution worked on both Windows and Linux. Most likely, there was a bug fix between when I got virtualenv and the latest release.

Categories