Closed Andy-Python-Programmer closed 4 years ago
@ziyaointl
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\user\\AppData\\Local\\Programs\\Python\\Python38-32\\lib\\site-packages\\p5\\sketch\\shaders\\2d\\default2d.vert'
I have just tested the latest version of p5py and it works fine.
Can you pull the master branch again and try?
Hi @parsoyaarihant I think I have found the main problem that is I think the Shaders are not provided in the pip release. So it’s trying to find the shaders where it was installed instead of the current directory.
@Andy-Python-Programmer Sorry for the late reply!
I'm guessing this is due to pkgutil trying to lookup p5 and ends up in the pypi installation, though I'm not entirely sure. https://github.com/p5py/p5/blob/3e034c256788e39f38f1190923af18c2e6317db9/p5/sketch/util.py#L8
Could you create a new virtual environment that just contains the requirements for p5py and try again?
Alternatively you could uninstall the pip version and reinstall p5py from the repository's setup.py
If you want to do it through a virtualenv, here's one way of doing it
git clone https://github.com/p5py/p5
cd p5
pip install --user pipenv
pipenv install -r requirements.txt # The setup.py has not been updated yet, so we'll manually install for now
pipenv install .
pipenv shell
python <p5 script you want to run>
Alternatively you could uninstall the pip version and reinstall p5py from the repository's setup.py
@parsoyaarihant @ziyaointl
I tried that and then my projects stopped working and again showed this error:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\user\\AppData\\Local\\Programs\\Python\\Python38-32\\lib\\site-packages\\p5\\sketch\\shaders\\2d\\default2d.vert'```
After the gloal repository installation:
Traceback (most recent call last):
File "main.py", line 1, in <module>
from p5 import *
File "C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib\site-packages\p5\__init__.py", line 19, in <module>
from .sketch import *
File "C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib\site-packages\p5\sketch\__init__.py", line 21, in <module>
from .userspace import *
File "C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib\site-packages\p5\sketch\userspace.py", line 37, in <module>
from .renderer2d import Renderer2D
File "C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib\site-packages\p5\sketch\renderer2d.py", line 22, in <module>
from .shaders2d import src_default, src_fbuffer
File "C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib\site-packages\p5\sketch\shaders2d.py", line 25, in <module>
src_default = ShaderSource(read_shader('2d/default2d.vert'), read_shader('common/default.frag'))
File "C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib\site-packages\p5\sketch\util.py", line 8, in read_shader
return pkgutil.get_data('p5', os.path.join('sketch/shaders/',filename)).decode()
File "C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib\pkgutil.py", line 637, in get_data
return loader.get_data(resource_name)
File "<frozen importlib._bootstrap_external>", line 972, in get_data
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\user\\AppData\\Local\\Programs\\Python\\Python38-32\\lib\\site-packages\\p5\\sketch\\shaders\\2d\\default2d.vert'
It cannot find the shaders even in a virtual env.
The paths look like python is still referring to the global installation, not a version inside of a virtual env. Could you try the commands in my previous reply and let me know if it works?
Hi @ziyaointl I went into the folder and it does not have the shaders in there:
If I do git+install then it does not get the shaders folder
I have fixed this issue but this issue is not closed. Meaning I copied and pasted the folder of shaders in the sitepackages folder that is not ever recommended. I tried installing the library using pip install p5/ AKA current cloned directory. But still it did not install the shaders folder. So if its not able to install it locally then it will also not work in the pip version when the next one is released.
So I tried this again myself, and it seems pip will not copy extra files in a repo when using pip install git+<link>
. I'll open a PR that adds the shaders folder to the MANIFEST.in file.
How can i import the current directory package not the parent one @ziyaointl
Workssss Solved!!!
Describe the bug I forked the repo and downloaded it. I renamed the main directory to main where code is not located so that the main and the local library do not clash.
To Reproduce Just download and run the repo with the original p5 version installed from pip
Expected behavior Should work as the folder was renamed so it should not clash.