ERROR: Could not find a version that satisfies the requirement sys (from versions: none) ERROR: No matching distribution found for sys - sys

On trying to install sys package in Python 3.7.4 version using IDLE, I am getting the below error:
Input : C:\Users\UserName\Downloads>pip install sys
Output :
Collecting sys
ERROR: Could not find a version that satisfies the requirement sys (from versions: none)
ERROR: No matching distribution found for sys

You don't need to use the pip install command. sys is part of the standard library, so it is built into Python that you installed. Use import sys in your .py file and run it to see exactly which libraries are giving you the import error.

Related

PyAudio import error : ImportError: DLL load failed: The specified module could not be found

I encountered an import problem by PyAudio.
I have a winodws 10, 64 bit, and use Anaconda and Spyder IDE with python 3.7.
I installed PyAudio in Ananconda, ran as administrator, with these commands :
cd
conda install -c conda-forge PyAudio
The installation ran without any problems.
I then restarted both Anaconda and SPYDER. PyAudio now shows up in Anaconda's list of installed packages.
When I try to import Pyaudio in Spyder (IPython console), I encounter this error message :
[1]: import pyaudio
Could not import the PyAudio C module '_portaudio'.
Traceback (most recent call last):
File "", line 1, in
import pyaudio
File "C:\ProgramData\Anaconda3\lib\site-packages\pyaudio.py", line 116, in
import _portaudio as pa
ImportError: DLL load failed: The specified module could not be found.
I tried to fix it by answers to similar ImportError message issued, while other users tried to import other packages like SKlearn ... , but with no success.
Your problem (and mine) are the same. The issue is, unfortunately, the version of python you're running (in tandem with your OS).
Check out this link:
https://people.csail.mit.edu/hubert/pyaudio/#:~:text=Note%3A%20As%20of%20this%20update,4.
Under the INSTALLATION section in the link for WINDOWS, PyAudio's latest version (0.2.11) is compatible with Python versions: 2.7, 3.4, 3.5, 3.6.
My current python is 3.8.5, so you (and I) could never use PyAudio unless they added compatibilities or we revert to an above python version.
I tried to install portaudio using
conda install portaudio
but it seems like it didn't work as it should be. However,
conda install -c anaconda portaudio
solved the problem.
see the official anaconda page

How to execute the right Python to import the installed tensorflow.transform package?

The version of my Python is 2.7.13.
I run the following in Jupyter Notebook.
Firstly, I installed the packages
%%bash
pip uninstall -y google-cloud-dataflow
pip install --upgrade --force tensorflow_transform==0.15.0 apache-beam[gcp]
Then,
%%bash
pip freeze | grep -e 'flow\|beam'
I can see that the package tensorflow-transform is installed.
apache-beam==2.19.0
tensorflow==2.1.0
tensorflow-datasets==1.2.0
tensorflow-estimator==2.1.0
tensorflow-hub==0.6.0
tensorflow-io==0.8.1
tensorflow-metadata==0.15.2
tensorflow-probability==0.8.0
tensorflow-serving-api==2.1.0
tensorflow-transform==0.15.0
However when I tried to import it, there are warning and error.
WARNING:tensorflow:From /usr/local/lib/python2.7/dist-packages/tensorflow_estimator/python/estimator/api/_v1/estimator/__init__.py:12: The name tf.estimator.inputs is deprecated. Please use tf.compat.v1.estimator.inputs instead.
ImportErrorTraceback (most recent call last)
<ipython-input-3-26a4792d0a76> in <module>()
1 import tensorflow as tf
----> 2 import tensorflow_transform as tft
3 import shutil
4 print(tf.__version__)
ImportError: No module named tensorflow_transform
After some investigation, I think I have some ideas of the problem.
I run this:
%%bash
pip show tensorflow_transform| grep Location
This is the output
Location: /home/jupyter/.local/lib/python3.5/site-packages
I tried to modify the $PATH by adding /home/jupyter/.local/lib/python3.5/site-packages to the beginning of $PATH. However, I still failed to import tensorflow_transform.
Based on the above and the following information, I think, when I ran the import command, it executes Python 2.7, not Python 3.5
import sys
print('\n'.join(sys.path))
/usr/lib/python2.7
/usr/lib/python2.7/plat-x86_64-linux-gnu
/usr/lib/python2.7/lib-tk
/usr/lib/python2.7/lib-old
/usr/lib/python2.7/lib-dynload
/usr/local/lib/python2.7/dist-packages
/usr/lib/python2.7/dist-packages
/usr/local/lib/python2.7/dist-packages/IPython/extensions
/home/jupyter/.ipython
Also,
import sys
sys.executable
'/usr/bin/python2'
I think the problem is tensorflow_transform package was installed in /home/jupyter/.local/lib/python3.5/site-packages. But when I run "Import", it goes to /usr/local/lib/python2.7/dist-packages to search for the package, rather than /home/jupyter/.local/lib/python3.5/site-packages, so even updating $PATH does not help. Am I right?
I tried to upgrade my python, but
%%bash
pip install upgrade python
Defaulting to user installation because normal site-packages is not writeable
Then, I added --user. It seems that the python is not really upgraded.
%%bash
pip install --user upgrade python
%%bash
python -V
Python 2.7.13
Any solution?
It seems to me that your jupyter notebook is not using the right python environment.
Perhaps, you installed the package under version 3.5,
but the Notebook uses the other one, thus it cannot find the library
You can pick the other interpreter by clicking on: Python(your version) - bottom left.
VS-Code - Select Python Environment 1
However you can do this also via:
CNTRL+SHIFT+P > Select Python Interpreter to start Jupyter Server
If that does not work make sure that the package you are trying to import is installed under the correct python environment.
If not open up a terminal, activate the environment and install it using:
pip install packagename
For example i did the same thing here: (Note: I'm using Anaconda)
installing tensorflow_transform
After a installation, you can import it in your code directly like this:
importing tensorflow_transform

ImportError: No module named 'bson.objectid' [duplicate]

I have currently django-mongodb-engine 0.4.0 version installed on my Mac OS X 10.6.8 and weirdly encountered an interesting error while importing the 'compiler' module:
>> from django_mongodb_engine import compiler
and I got the following error:
ImportError Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django_extensions/management/commands/shell_plus.pyc in <module>()
----> 1 from django_mongodb_engine import compiler
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django_mongodb_engine/compiler.pyc in <module>()
15 from pymongo.errors import PyMongoError
16 from pymongo import ASCENDING, DESCENDING
---> 17 from pymongo.objectid import ObjectId, InvalidId
18
19 from djangotoolbox.db.basecompiler import NonrelQuery, NonrelCompiler, \
ImportError: No module named objectid
I installed the package via pip command and all the dependencies like pymongo, djangotoolbox have been installed along with it. The pip command I'd used is this:
>> sudo env ARCHFLAGS='-arch i386 -arch x86_64' pip install --upgrade django-mongodb-engine
The current versions of the related packages are:
>> pip freeze | grep mongo
django-mongodb-engine==0.4.0
pymongo==2.2
I suspect the django_mongodb_engine package is broken because ObjectId is not imported inside pymongo anymore. Instead, it belongs to bson module.
What are your suggestions to fix this problem? Should I clone the django-mongodb-engine project and fix on github?
I've ran into something similar, for me the problem was this line:
from pymongo.objectid import ObjectId
The call seems to work in versions of PyMongo < 2.2
In pymongo 2.2 the call to import objectid is:
from bson.objectid import ObjectId
Looks like they're already aware (see this pull request), but no one's created a pull request against the develop branch yet. You could try fixing that and submit a new pull request.
I tried to install bson with pip directly. Uninstall, and install pymongo instead and the error didnt reappear.
I'm on Python3 (in 2017) and found that the following works:
from pymongo import MongoClient
from bson import ObjectId

Python Cryptography Error ImportError: cannot import name certificate_transparency

In cryptography which was included using pip install PyCrpto giving an error after including it in a flask application where we are running it using virtual environment have named it venv and have this dependency correctly installed in venv > lib > python2.7 > site-packages.
Below is the exact error which I am getting here.
from cryptography.x509 import certificate_transparency
ImportError: cannot import name certificate_transparency
But as can be seen in screenshot file cryptography.x509.certificate_transparency.py is there in file structure and even on trying python -c "from cryptography.x509 import certificate_transparency" doesn't show any warnings but here it shows error which is also marked in red.
What can be possibly wrong here ?
I came across this problem when I was building an updated Python Crypto module for shipping with Solaris (see https://www.jmcpdotcom.com/blog/2018-02-21-im-embarrassed-to-admit-it/).
The root cause in your case appears to be that you haven't installed it in the right place. While you claim above that it's "correctly installed" in venv > lib > python2.7 > site-packages the screenshot shows that it is in fact in venv/lib/cryptography. If you move the cryptography dir down a level I would expect that your import would work.

Can't install psycopg2 successfully

Requirement already satisfied: psycopg2 in/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
This is the error message I get when I run
pip install psycopg2
in my terminal on Mac. But when I try to import it in python (simply using import psycopg2) in either version 2.7 or 3.6 of python I get an error message:
No module named 'psycopg2'
Any suggestions?