How to add whl file on pip requirements files? - python

Assuming you created a whl of a proprietary project and would like to reuse it in another python project, how to indicate it via a relative path in a pip file without exposing whl online?
Although there is no direct description for this problem, from the documentation (https://pip.readthedocs.io/en/1.1/requirements.html) I have tried the following:
Indicate using -e file:
./folder/my-project-0.1.0-cp36-cp36m-linux_x86_64.whl#egg=my-project==0.1.0
got> NotADirectoryError: [Errno 20] Not a directory
Indicate using file:
./folder/my-project-0.1.0-cp36-cp36m-linux_x86_64.whl#egg=my-project==0.1.0
got> FileNotFoundError: [Errno 2] No such file or directory:
'/folder/my-project-0.1.0-cp36-cp36m-linux_x86_64.whl'
It seems to seek the file on the root folder instead of the relative one.
Indicate without file:
folder/my-project-0.1.0-cp36-cp36m-linux_x86_64.whl got> Invalid
requirement: 'folder/my-project-0.1.0-cp36-cp36m-linux_x86_64.whl'
It looks like a path. Does it exist ?
It appears that if I indicate the folder instead it will work.
But as this is not the case, does anyone know how to fix it?
numpy
pandas
file:./folder/my-project-0.1.0-cp36-cp36m-linux_x86_64.whl#egg=my-project==0.1.0
Pip install whl file using relative path with success!

Related

open with not creating and writing file

I am following a tutorial (Beautiful Soup) and I can't seem to get open with to create a .txt file as I am getting this error:
with open(f'posts/{index}.txt', 'w+') as f:
FileNotFoundError: [Errno 2] No such file or directory: 'posts/1.txt'. I tried looking up different solutions to my problem currently running python 3.9. Is there another step I need to correct this issue?
The interpreter isn't finding the directory "posts" in your current working directory. If it exists, you are not in its parent directory. Try using the full path, e.g. rf'C:\users\myuser\posts\{index}.txt' or rf'~/posts/{index}.txt' on linux.
Or, if it doesnt't exist, add these lines:
import os
os.mkdir('posts')
You can find your current working directory this way:
import os
os.path.abspath('.')

How to start pipenv

I have been try to my pipenv going but it gives me this error
Creating a virtualenv for this project…
Pipfile: C:\Users\User\Pipfile
Using C:/Python/Python37/python.exe (3.7.1) to create virtualenv
[ ==] Creating virtual environment...FileNotFoundError: [Errno 2] No such file or directory
'c:\\python\\python37\\Lib\\venv\\scripts\\nt\\python.exe'
Failed creating virtual environment here
I tried to changed the file path made sure it is in same path as where python is installed still get the same problem.
copy following files from python location(C:\Program Files\Python37) to the (C:\Program Files\Python37\Lib\venv\scripts\nt)
1) python_d.exe
2) python_d.pdb
3) pythonw_d.exe
4) pythonw_d.pdb
thanks this solved the problem just one question if i want to use git clone command which filepath should i used?
because if i used the git clone command in same path
C:\Users\User>git clone https://github.com/jadhavpritish/Dream11_Predictor.git
C:\Users\User>pipenv run python src/player_selection_dream11.py
C:\Users\User\.virtualenvs\User-jBUq-HwN\Scripts\python.exe: can't open file 'src/player_selection_dream11.py': [Errno 2] No such file or directory
Okay! So what I just did to resolve it is that;
This message popped up (Shortly)
[ ==] Creating virtual environment...FileNotFoundError: [Errno 2] No such file or directory: 'c:\\users\\arham rumi\\appdata\\local\\programs\\python\\python37-32\\Lib\\venv\\scripts\\nt\\python.exe'
Then I went to the mentioned directory, and there was no such file like python.exe
Then I went back to python37-32 folder or you can simply go to the directory where you have that python.exe file. Copy this and paste it to the directory mentioned in the error.
And that's how I resolved this problem

FileNotFoundError [Errno 2] when running pyinstaller executable?

I am trying to make my python file as an executable using Pyinstaller. After the process of conversion has finished, in my dist folder, when I click on "myApplication.exe" I get the following error:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\user\\Desktop\\Application\\dist\\myApplication\\smart_open\\VERSION'
[17416] Failed to execute script myApplication
I've already searched for answers to this but none of them have the specific error as mine which is the folder smart_open\VERSION as I have no idea what that's supposed to be.
EDIT
The smart_open folder does not even exists in my myApplication folder
Instead of using the original version of "smart_open" use this fork of the library: https://github.com/rs-trevor/smart_open
The pull request is here: https://github.com/RaRe-Technologies/smart_open/pull/344
It essentially converts the strange (extension-less) "VERSION" file into "version.py" so pyinstaller picks it up correctly
I encountered the same issue posted it within the smart_open github: https://github.com/RaRe-Technologies/smart_open/issues/345
I think you have to add the VERSION file of smart_open in the spec file. More information in the documentation.
Edit
In this case, datas line should be:
datas=[ ('c:\\python360564\\lib\\site-packages\\smart_open\\VERSION', 'smart_open\\VERSION' )],
The first part is the initial path of the file and the second the destination path (get from the error message).

Call a file in another folder in Eclipse for Python project

I have a small enough Python project in Eclipse Neon and keep getting the same error and can't find proper documentation on how to solve. In my main I need to call a file that is located in another folder. The error I receive is IOError: [Errno 2] No such file or directory:
I have an empty init.py file in the folder (XML_TXT) that I'm trying to use.
It looks like Groovy is importing okay, or else you would get an ImportError. An IOError indicates that it can't find "test.txt". Does that file exist?
It will work if the file path is relative to where you are running the script from. So for example if test.txt is in a folder
Groovy("folder_name/test.txt")
You can also go up in the directory structure if you need to, for example
Groovy("../folder_name/test.txt")
Or, if you want to be able to run the file from anywhere, you can have python work out the absolute path of the file for you.
import os
filename = os.path.join(os.path.dirname(__file__), 'folder_name/test.txt')
u = Groovy(filename)

os.chroot Operation not permitted

I'm trying to write a python script to generate a debian package.
I'm generating required folder structure in a temporary folder. In order to change uid and gid of /usr and subfolders to root I thought of using chroot.
However, on this line
os.chroot(tmpdir)
I get:
OSError: [Errno 1] Operation not permitted: '/tmp/tmpVnTqW7/myproj'
I've also tried this mini-tutorial with same results: http://www.tutorialspoint.com/python/os_chroot.htm
Why would that be?
Thanks
chroot() can be done only by root.
do one of these:
Run the script with sudo
Make the script setuid root, and do the setuid(geteuid()) equivalent python magic
I'm generating required folder structure in a temporary folder. In order to change uid and gid of /usr and subfolders to root I thought of using chroot.
I am not sure if you are on the right track. I don't know much about .deb packages, but in .rpm packages, you can define in the file list which file properties to assign to which files.
So you don't set them in the file system, but just tell the system what should happen.
As said, this counts for .rpm; I'm not sure if it is the same in .deb.
Instead of chrootting to the directory you should use fakeroot to execute dpkg-deb: fakeroot dpkg-deb -z8 -Zgzip --build myproj

Categories