pipenv - Pipfile.lock is not being generated due to the 'Could not find a version that matches keras-nightly~=2.5.0.dev' error - tensorflow

As the title clearly describes the issue I've been experiencing, no Pipfile.lock is being generated as I get the following error when I execute the recommended command pipenv lock --clear:
ERROR: ERROR: Could not find a version that matches keras-nightly~=2.5.0.dev
Skipped pre-versions: 2.5.0.dev2021020510, 2.5.0.dev2021020600, 2.5.0.dev2021020700, 2.5.0.dev2021020800, 2.5.0.dev2021020900, 2.5.0.dev2021021000, 2.5.0.dev2021021100, 2.5.0.dev2021021200, 2.5.0.dev2021021300, 2.5.0.dev2021021400, 2.5.0.dev2021021500, 2.5.0.dev2021021600, 2.5.0.dev2021021700, 2.5.0.dev2021021800, 2.5.0.dev2021021900, 2.5.0.dev2021022000, 2.5.0.dev2021022100, 2.5.0.dev2021022200, 2.5.0.dev2021022300, 2.5.0.dev2021022317, 2.5.0.dev2021022400, 2.5.0.dev2021022411, 2.5.0.dev2021022500, 2.5.0.dev2021022600, 2.5.0.dev2021022700, 2.5.0.dev2021022800, 2.5.0.dev2021030100, 2.5.0.dev2021030200, 2.5.0.dev2021030300, 2.5.0.dev2021030400, 2.5.0.dev2021030500, 2.5.0.dev2021030600, 2.5.0.dev2021030700, 2.5.0.dev2021030800, 2.5.0.dev2021030900, 2.5.0.dev2021031000, 2.5.0.dev2021031100, 2.5.0.dev2021031200, 2.5.0.dev2021031300, 2.5.0.dev2021031400, 2.5.0.dev2021031500, 2.5.0.dev2021031600, 2.5.0.dev2021031700, 2.5.0.dev2021031800, 2.5.0.dev2021032213, 2.5.0.dev2021032300, 2.5.0.dev2021032413, 2.5.0.dev2021032500, 2.5.0.dev2021032600, 2.5.0.dev2021032610, 2.5.0.dev2021032700, 2.5.0.dev2021032800, 2.5.0.dev2021032900, 2.6.0.dev2021033000, 2.6.0.dev2021033100, 2.6.0.dev2021040100, 2.6.0.dev2021040200, 2.6.0.dev2021040300, 2.6.0.dev2021040400, 2.6.0.dev2021040500, 2.6.0.dev2021040600, 2.6.0.dev2021040714, 2.6.0.dev2021040800, 2.6.0.dev2021040900, 2.6.0.dev2021041000, 2.6.0.dev2021041100, 2.6.0.dev2021041200, 2.6.0.dev2021041300, 2.6.0.dev2021041400, 2.6.0.dev2021041500, 2.6.0.dev2021041600, 2.6.0.dev2021041700, 2.6.0.dev2021041800, 2.6.0.dev2021041900, 2.6.0.dev2021042000, 2.6.0.dev2021042100, 2.6.0.dev2021042200, 2.6.0.dev2021042300, 2.6.0.dev2021042500, 2.6.0.dev2021042600, 2.6.0.dev2021042700, 2.6.0.dev2021042800, 2.6.0.dev2021042900, 2.6.0.dev2021043000, 2.6.0.dev2021050100, 2.6.0.dev2021050200, 2.6.0.dev2021050300, 2.6.0.dev2021050400, 2.6.0.dev2021050500, 2.6.0.dev2021050600, 2.6.0.dev2021051200, 2.6.0.dev2021051300, 2.6.0.dev2021051400, 2.6.0.dev2021051500, 2.6.0.dev2021051600, 2.6.0.dev2021051700, 2.6.0.dev2021051800, 2.6.0.dev2021051900, 2.6.0.dev2021052000, 2.6.0.dev2021052100, 2.6.0.dev2021052200, 2.6.0.dev2021052300, 2.6.0.dev2021052400, 2.6.0.dev2021052500, 2.6.0.dev2021052600, 2.6.0.dev2021052700
There are incompatible versions in the resolved dependencies.
So, how can I overcome this situation? I'm basically developing a deep neural network using Keras. I simply installed the following dependencies without explicitly declaring versions:
tensorflow = "*"
nltk = "*"
pandas = "*"
tweepy = "*"
textblob = "*"
seaborn = "*"
matplotlib = "*"
wordcloud = "*"
stop-words = "*"
vadersentiment = "*"
scikit-learn = "*"
keras = "*"

By looking at the pypi site for keras-nightly library, I could see that there are no versions named 2.5.0.dev. Check which package is generating the error and try downgrading that package.

Pipenv wants you to use the --pre flag in this situation. I think the simplest way to install it would be like this:
pipenv install tensorflow --python=3.8 --pre

I had the same problem. Apparently, tensorflow arises a sub-dependency resolution error with Pipfile when resolving keras. It searches for a version that matches keras-nightly~=2.5.0.dev. Looking at pypi, this version does not exist.
Whatsoever, installing a version 2.4.X works, e. g. pipenv install tensorflow~=2.4.1.

By Changing the python_version in pipenv file resolved my issue.
I had it 3.9 before.
Pipfile:
python_version = "3.8"

It seems that tensorflow does not work on python 3.9 as it has a dependency on the nightly.
If you are using python 3.9, your option is to go to tensorflow 2.6.0rc1,

adding those line to Pipfile fixed my issue.
[pipenv]
allow_prereleases = true

Related

Writing apache beam pCollection to bigquery causes type Error

I have a simple beam pipeline, as follows:
with beam.Pipeline() as pipeline:
output = (
pipeline
| 'Read CSV' >> beam.io.ReadFromText('raw_files/myfile.csv',
skip_header_lines=True)
| 'Split strings' >> beam.Map(lambda x: x.split(','))
| 'Convert records to dictionary' >> beam.Map(to_json)
| beam.io.WriteToBigQuery(project='gcp_project_id',
dataset='datasetID',
table='tableID',
create_disposition=bigquery.CreateDisposition.CREATE_NEVER,
write_disposition=bigquery.WriteDisposition.WRITE_APPEND
)
)
However upon runnning I get a typeError, stating the following:
line 2147, in __init__
self.table_reference = bigquery_tools.parse_table_reference(if isinstance(table,
TableReference):
TypeError: isinstance() arg 2 must be a type or tuple of types
I have tried defining a TableReference object and passing it to the WriteToBigQuery class but still facing the same issue. Am I missing something here? I've been stuck at this step for what feels like forever and I don't know what to do. Any help is appreciated!
This probably occurred since you installed Apache Beam without the GCP modules. Please make sure to do following (in a virtual environment).
pip install apache-beam[gcp]
It's a weird error though so feel free to file a Github issue against the Apache Beam project.

Pipeline keeps failing at test and lint stage

I am pretty new to coding so I am sorry if I'm not giving enough context. I am trying to package and deploy a model in Python to a repo but keep getting the follow error when I push to GitLab
ERROR: No matching distribution found for numpy==1.23.1
$ if [[ "${COVERAGE_ARGS}" == "" ]]; then
$ dir_loc=`pwd`
$ COVERAGE_ARGS="--cov=${dir_loc}"
$ fi
$ pytest --junitxml=reports/report.xml --cov-config=${COV_CONFIG} ${COVERAGE_ARGS} ${EXTRA_ARGS}
============================= test session starts ==============================
platform linux -- Python 3.7.10, pytest-7.1.2, pluggy-1.0.0
rootdir: /builds/Ahs1yUQY/1/dse/dscp/dse-dscp-python-hoffinator
plugins: cov-3.0.0, requests-mock-1.9.3
collected 0 items / 1 error
==================================== ERRORS ====================================
______________________ ERROR collecting test/test_main.py ______________________
ImportError while importing test module '/builds/Ahs1yUQY/1/dse/dscp/dse-dscp-python-hoffinator/test/test_main.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/lib64/python3.7/importlib/__init__.py:127: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
test/test_main.py:5: in <module>
from src.hoffinator import hoffinator_functions
src/hoffinator/hoffinator_functions.py:3: in <module>
import numpy as np
E ModuleNotFoundError: No module named 'numpy'
- generated xml file: /builds/Ahs1yUQY/1/dse/dscp/dse-dscp-python-hoffinator/reports/report.xml -
---------- coverage: platform linux, python 3.7.10-final-0 -----------
My requirements.txt for dependencies is as follows
ccplatlogging
boto3~=1.20.33
email-validator~=1.1.3
appnope==0.1.3
argon2-cffi==21.3.0
argon2-cffi-bindings==21.2.0
asttokens==2.0.5
attrs==21.4.0
backcall==0.2.0
beautifulsoup4==4.11.1
bleach==5.0.1
cffi==1.15.1
cycler==0.11.0
debugpy==1.6.2
decorator==5.1.1
defusedxml==0.7.1
entrypoints==0.4
executing==0.8.3
fastjsonschema==2.16.1
fonttools==4.34.4
iniconfig==1.1.1
ipykernel==6.15.1
ipython==7.34.0
ipython-genutils==0.2.0
ipywidgets==7.7.1
jedi==0.18.1
Jinja2==3.1.2
joblib==1.1.0
jsonschema==4.7.2
jupyter==1.0.0
jupyter-client==7.3.4
jupyter-console==6.4.4
jupyter-core==4.11.1
jupyterlab-pygments==0.2.2
jupyterlab-widgets==1.1.1
kiwisolver==1.4.4
MarkupSafe==2.1.1
matplotlib==3.5.2
matplotlib-inline==0.1.3
mistune==0.8.4
nbclient==0.6.6
nbconvert==6.5.0
nbformat==5.4.0
nest-asyncio==1.5.5
notebook==6.4.12
numpy==1.23.1
packaging==21.3
pandas==1.4.3
pandocfilters==1.5.0
parso==0.8.3
patsy==0.5.2
pexpect==4.8.0
pickleshare==0.7.5
Pillow==9.2.0
pluggy==1.0.0
ppscore==1.2.0
prometheus-client==0.14.1
prompt-toolkit==3.0.30
psutil==5.9.1
ptyprocess==0.7.0
pure-eval==0.2.2
py==1.11.0
pycparser==2.21
pycryptodome==3.15.0
Pygments==2.12.0
pyodbc==4.0.34
pyparsing==3.0.9
pyrsistent==0.18.1
pytest==7.1.2
python-dateutil==2.8.2
pytz==2022.1
pyzmq==23.2.0
qtconsole==5.3.1
QtPy==2.1.0
scikit-learn==0.24.2
scipy==1.8.1
seaborn==0.11.2
Send2Trash==1.8.0
six==1.16.0
soupsieve==2.3.2.post1
stack-data==0.3.0
statsmodels==0.13.2
teradatasql==17.20.0.0
terminado==0.15.0
threadpoolctl==3.1.0
tinycss2==1.1.1
tomli==2.0.1
tornado==6.2
traitlets==5.3.0
wcwidth==0.2.5
webencodings==0.5.1
widgetsnbextension==3.6.1
I do not understand why numpy is not found when it is cleary in the .txt. Is it a version issue?
Your console output shows that you are using Python 3.7.10. If you take a look at numpy release notes for 1.23.1 found here you’ll notice that it states:
The Python version supported for this release are 3.8-3.10.
You will need to either use a newer version of Python or use an older version of numpy.

Getting Error with Pytube: signature = cipher.get_signature(js, stream['s']) KeyError: 's'

I have been this error when running my Pytube script:
signature = cipher.get_signature(js, stream['s'])
KeyError: 's'
My code is like this:
url = 'https://www.youtube.com/watch?v='
train_List = []
i = 0
while i < len(my_list):
if len(my_list[i]) > 6:
urls = url + my_list[i]
train_List.append(urls)
yt=YouTube(train_List[i])
t=yt.streams.filter(only_audio=True).all()
t[0].download('/pathtofolder')
i+=1
I also tried:
t=yt.streams.filter(file_extension='mp4').all()
I altered the cipher.py and helper.py files per the recommendation here: https://github.com/nficano/pytube/issues/353#issuecomment-455116197
but it hasn't fixed the problem. After making the alterations, I got the error noted above.
Next, I ran "pip install pytube --upgrade" per some other recommendations. Still getting the KeyError after it downloads a few audio files.
I've also implemented this in mixins.py, per the github issues:
if ('signature=' in url) or ('&sig=' in url) or ('&lsig=' in url):
but now it's hanging after 3 uploads.
Does anyone have a fix for this?
I fixed this issue (for me, at least) by changing line 49 in mixins.py to this:
signature = cipher.get_signature(js, stream['url'])
instead of
signature = cipher.get_signature(js, stream['s'])
and then changing lines 55-63 to
logger.debug(
'finished descrambling signature for itag=%s\n%s',
stream['itag'], pprint.pformat(
{
'url': stream['url'],
'signature': signature,
}, indent=2,
),
)
Have the same problem. If I try a second time it works most of the time...
url = 'https://www.youtube.com/watch?v=gQrkvZeE3Uc'
yt = YouTube(url)
yt.streams.filter(progressive=True, subtype='mp4').order_by('resolution').desc().last().download()
Thanks for any help
You have to fix the cipher.py file in lib/python3.6/site-packages/pytube:
In cipher.py, change pattern starting at line 38 to this:
pattern = [
r'(["\'])signature\1\s*,\s*(?P<sig>[a-zA-Z0-9$]+)\(',
r'\.sig\|\|(?P<sig>[a-zA-Z0-9$]+)\(',
r'yt\.akamaized\.net/\)\s*\|\|\s*.*?\s*c\s*&&\s*d\.set\([^,]+\s*,\s*(?:encodeURIComponent\s*\()?(?P<sig>[a-zA-Z0-9$]+)\(',
r'\bc\s*&&\s*d\.set\([^,]+\s*,\s*(?:encodeURIComponent\s*\()?\s*(?P<sig>[a-zA-Z0-9$]+)\(',
r'\bc\s*&&\s*d\.set\([^,]+\s*,\s*\([^)]*\)\s*\(\s*(?P<sig>[a-zA-Z0-9$]+)\(',
]
One of the ways to solve it: pip install git+https://github.com/nficano/pytube.git
Other than that, check this thread
I did pip uninstall pytube.
Checked my python version with python --version, turned out to be the Anaconda 3.6.8 version.
So I did pip3 install pytube, pip3 being for Python 3 I believe.
It works no problems now.
had same issue, based on other answers that installed it from sources, just checked my current pytube version, which was 9.5.0 and see that the last released is 9.5.2, so I just run pip install --upgrade pytube and worked perfectly

GVim not recognizing commands in plugin

How do I get gvim to recognize sqlcomplete.vim commands?
I'm unable to use the sqlcomplete.vim plugin. When running :version I get the following output:
and scrolling all the way to the bottom here is the rest of the output:
and the env variables:
:echo $VIM
c:\users\me\.babun\cygwin\etc\
:echo $HOME
H:\
Here is the output of :scriptnames:
When running the sqlcomplete.vim command such as :SQLSetType sqlanywhere the output I get is:
How do I get gvim to recognize sqlcomplete.vim commands?
Another piece of helpful information is the output of :echo &rtp :
H:\vimfiles,H:\.vim\bundle\Vundle.vim,H:\.vim\bundle\dbext.vim,H:\.vim\bundle\SQ
LComplete.vim,C:\Users\me\.babun\cygwin\etc\vimfiles,C:\Users\me\.babu
n\cygwin\etc\,C:\Users\me\.babun\cygwin\etc\vimfiles/after,H:\vimfiles/afte
r,H:\.vim/bundle/Vundle.vim,H:\.vim\bundle\Vundle.vim/after,H:\.vim\bundle\dbext
.vim/after,H:\.vim\bundle\SQLComplete.vim/after
Some points you could check:
:scriptnames shows plugin\sqlcomplete.vim
But the link you provided points to .../vim/runtime/autoload/sqlcomplete.vim, there is no .../vim/runtime/plugin/sqlcomplete.vim, and the version at vim.org also doesn't contains a /plugin file:
install details
Copy sqlcomplete.vim to:
.vim/autoload/sqlcomplete.vim (Unix)
vimfiles\autoload\sqlcomplete.vim (Windows)
For documentation:
:h sql.txt
Maybe you have installed it incorrectly.
The file on your link has version 12 at its header, while the latest version is 15. Try updating to the latest version
Note that this plugin does not define the SQLSetType command.
You could check that by simple searching the file the on link. And on its header:
" Vim OMNI completion script for SQL
" Language: SQL
" Maintainer: David Fishburn <dfishburn dot vim at gmail dot com>
" Version: 15.0
" Last Change: 2013 May 13
" Homepage: http://www.vim.org/scripts/script.php?script_id=1572
" Usage: For detailed help
" ":help sql.txt"
" or ":help ft-sql-omni"
" or read $VIMRUNTIME/doc/sql.txt
Following :help sql.txt:
2.1 SQLSetType *sqlsettype* *SQLSetType*
--------------
For the people that work with many different databases, it is nice to be
able to flip between the various vendors rules (indent, syntax) on a per
buffer basis, at any time. The ftplugin/sql.vim file defines this function: >
SQLSetType
And scriptnames is not listing ftplugin/sql.vim

Python file location conventions and Import errors

I'm new to Python and I simply don't know how to handle this specific problem:
I'm trying to run an executable (named ros_M5e.py) that's located in the directory /opt/ros/diamondback/stacks/hrl/hrl_rfid/src/hrl_rfid/ros_M5e.py (annoyingly long filepath, I know, but necessary). However, within the ros_M5e.py file there is a call to another file that is further up the file path: from hrl.hrl_rfid.msg import RFIDread. The directory msg indeed is located at /opt/ros/diamondback/stacks/hrl/hrl_rfid/ and it does indeed contain the file RFIDread. However, whenever I try to execute ros_M5e.py I get this error:
Traceback (most recent call last):
File "/opt/ros/diamondback/stacks/hrl/hrl_rfid/src/hrl_rfid/ros_M5e.py", line 37, in <module>
from hrl.hrl_rfid.msg import RFIDread
ImportError: No module named hrl.hrl_rfid.msg
Would someone with some expertise please shine some light on this problem for me? It seems like just a rudimentary file location problem, but I just don't know the appropriate Python conventions to fix it. I've tried putting the ros_M5e.py file in the same directory as the files it calls and changing the filepaths but to no avail.
Thanks a lot,
Khiya
Sure, I can help you get it up and running.
From the StackOverflow posting, it would seem that you're checking out the stack to /opt/ros/diamondback. This is no good, as it is a system path. You need to install into your local path. The reason for "readonly" on the repository is that you do not have permissions to make changes to the code -- it will still work just fine for you on your local machine. I spent a fair amount of time showing how to use this package (at least the python version) here:
http://www.ros.org/wiki/hrl_rfid
I'll try to do a quick run-through for installing it.... Run the following commands:
cd
mkdir sandbox
cd sandbox/
svn checkout http://gt-ros-pkg.googlecode.com/svn/trunk/hrl/hrl_rfid hrl_rfid (double-check that this checkout works OK!)
Add the following line to the bottom of your bashrc to tell ROS where to find the new package. (You may use "gedit ~/.bashrc")
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:$HOME/sandbox/hrl_rfid
Now execute the following:
roscd hrl_rfid (did you end up in the correct directory?)
rosmake hrl_rfid (did it make without errors?)
roscd hrl_rfid/src/hrl_rfid
At this point everything is actually installed correctly. By default, ros_M5e.py assumes that the reader is located at "/dev/robot/RFIDreader". Unless you've already altered udev rules, this will not be the case on your machine. I suggest running through the code:
http://www.ros.org/wiki/hrl_rfid
using iPython (a command-line python prompt that will let you execute python commands one at a time) to make sure everything is working (replace /dev/ttyUSB0 with whatever device your RFID reader is connected as):
import lib_M5e as M5e
r = M5e.M5e( '/dev/ttyUSB0', readPwr = 3000 )
r.ChangeAntennaPorts( 1, 1 )
r.QueryEnvironment()
r.TrackSingleTag( 'test_tag_id_' )
r.ChangeTagID( 'test_tag_id_' )
r.QueryEnvironment()
r.TrackSingleTag( 'test_tag_id_' )
r.ChangeAntennaPorts( 2, 2 )
r.QueryEnvironment()
This means that the underlying library is working just fine. Next, test ROS (make sure "roscore" is running!), by putting this in a python file and executing:
import lib_M5e as M5e
def P1(r):
r.ChangeAntennaPorts(1,1)
return 'AntPort1'
def P2(r):
r.ChangeAntennaPorts(2,2)
return 'AntPort2'
def PrintDatum(data):
ant, ids, rssi = data
print data
r = M5e.M5e( '/dev/ttyUSB0', readPwr = 3000 )
q = M5e.M5e_Poller(r, antfuncs=[P1, P2], callbacks=[PrintDatum])
q.query_mode()
t0 = time.time()
while time.time() - t0 < 3.0:
time.sleep( 0.1 )
q.track_mode( 'test_tag_id_' )
t0 = time.time()
while time.time() - t0 < 3.0:
time.sleep( 0.1 )
q.stop()
OK, everything works now. You can make your own node that is tuned to your setup:
#!/usr/bin/python
import ros_M5e as rm
def P1(r):
r.ChangeAntennaPorts(1,1)
return 'AntPort1'
def P2(r):
r.ChangeAntennaPorts(2,2)
return 'AntPort2'
ros_rfid = rm.ROS_M5e( name = 'my_rfid_server',
readPwr = 3000,
portStr = '/dev/ttyUSB0',
antFuncs = [P1, P2],
callbacks = [] )
rospy.spin()
ros_rfid.stop()
Or, ping me back and I can tweak ros_M5e.py to take an optional "portStr" -- though I recommend making your own so that you can name your antennas sensibly. Also, I highly recommend setting udev rules to ensure that the RFID reader always gets assigned to the same device: http://www.hsi.gatech.edu/hrl-wiki/index.php/Linux_Tools#udev_for_persistent_device_naming
BUS=="usb", KERNEL=="ttyUSB*", SYSFS{idVendor}=="0403", SYSFS{idProduct}=="6001", SYSFS{serial}=="ftDXR6FS", SYMLINK+="robot/RFIDreader"
If you do not do this... there is no guarantee that the reader will always be enumerated at /dev/ttyUSBx.
Let me know if you have any further problems.
~Travis Deyle (Hizook.com)
PS -- Did you modify ros_M5e.py to "from hrl.hrl_rfid.msg import RFIDread"? In the repo, it is "from hrl_rfid.msg import RFIDread". The latter is correct. As long as you have your ROS_PACKAGE_PATH correctly defined, and you've run rosmake on the package, then the import statement should work just fine. Also, I would not recommend posting ROS-related questions to StackOverflow. Very few people on here are going to be familiar with the ROS ecosystem (which is VERY complex). Please post questions here instead:
http://answers.ros.org/
http://code.google.com/p/gt-ros-pkg/issues/list
You need to make sure that following are true:
Directory /opt/ros/diamondback/stacks/ is in your python path.
/opt/ros/diamondback/stacks/hr1 contains __init__.py
/opt/ros/diamondback/stacks/hr1/hr1_rfid contians __init__.py
/opt/ros/diamondback/stacks/hr1/hr1_rfid/msg contians __init__.py
As the asker explained in comments that the RFIDRead does not have .py extension, so here is how that can be imported.
import imp
imp.load_source('RFIDRead', '/opt/ros/diamondback/stacks/hr1/hr1_rfid/msg/RFIDRead.msg')
Check out imp documentation for more information.