Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Does not install or get the shaders directory #217

Closed
Andy-Python-Programmer opened this issue Aug 2, 2020 · 19 comments
Closed

Bug: Does not install or get the shaders directory #217

Andy-Python-Programmer opened this issue Aug 2, 2020 · 19 comments
Labels

Comments

@Andy-Python-Programmer
Copy link
Contributor

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.

@Andy-Python-Programmer
Copy link
Contributor Author

#213

@arihantparsoya
Copy link
Member

@ziyaointl

@Andy-Python-Programmer
Copy link
Contributor Author

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'

@arihantparsoya
Copy link
Member

I have just tested the latest version of p5py and it works fine.

@arihantparsoya
Copy link
Member

Can you pull the master branch again and try?

@Andy-Python-Programmer
Copy link
Contributor Author

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.

@ziyaointl
Copy link
Member

@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.

return pkgutil.get_data('p5', os.path.join('sketch/shaders/',filename)).decode()

Could you create a new virtual environment that just contains the requirements for p5py and try again?

@arihantparsoya
Copy link
Member

arihantparsoya commented Aug 4, 2020

Alternatively you could uninstall the pip version and reinstall p5py from the repository's setup.py

@ziyaointl
Copy link
Member

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>

@Andy-Python-Programmer
Copy link
Contributor Author

Andy-Python-Programmer commented Aug 8, 2020

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'```

@Andy-Python-Programmer
Copy link
Contributor Author

After the gloal repository installation:

Error

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'

@Andy-Python-Programmer
Copy link
Contributor Author

It cannot find the shaders even in a virtual env.

@ziyaointl
Copy link
Member

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?

@Andy-Python-Programmer
Copy link
Contributor Author

Hi @ziyaointl I went into the folder and it does not have the shaders in there:

Screenshot

d

@Andy-Python-Programmer
Copy link
Contributor Author

If I do git+install then it does not get the shaders folder

@Andy-Python-Programmer
Copy link
Contributor Author

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.

@Andy-Python-Programmer Andy-Python-Programmer changed the title Bug: Fork And Download Not Working Bug: Does not install or get the shaders directory Aug 9, 2020
@ziyaointl
Copy link
Member

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.

@Andy-Python-Programmer
Copy link
Contributor Author

How can i import the current directory package not the parent one @ziyaointl

@Andy-Python-Programmer
Copy link
Contributor Author

Workssss Solved!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants