zsh: permission denied: ./venv/bin; PyInstaller - python

I am trying to distribute a Python script of mine using PyInstaller on MacOSX. I am trying to use PyInstaller with the packages installed on my virtual environment using Python's innate venv package.
My virtual environment directory is named venv in this instance.
I am following PyInstaller's instructions to do so, found here: https://pythonhosted.org/PyInstaller/usage.html
However, when I run
./venv/bin pyinstaller <SCRIPTNAME> --onefile
The command prompt spits out this error:
zsh: permission denied: ./venv/bin
The only other examples of my problem occurred with users who altered their permissions prior to the problem arising, not when dealing with virtual environments, so I haven't been able to find a
proper solution for my case.
Am I using PyInstaller with the venv incorrectly, or how do I give myself the permission needed to run the correct command?

Hmm where you able to do
source bin/activate
This is required in order to add that source into the permissions lists as +x in your venv.
For more information please refer to [1]
Hope this helps
[1] https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/

Related

Newbie trying to install Python, Setting Path, zsh: Permission denied

I'm taking a class on Coursera, this is what it's asking me to do.
brew info python
The section you are interested in is the location of where it was
installed.
Unversioned symlinks python, python-config, pip etc. pointing to
python3, python3-config, pip3 etc., respectively, have been
installed into /opt/homebrew/opt/python#3.9/libexec/bin
The /opt/homebrew/opt/python#3.x/libexec/bin is the one you want to
use and set for your path. Copy it from the terminal. Depending on the
version of Mac OS you are running the next steps may vary slightly.
When I enter in: /opt/homebrew/opt/python#3.9/libexec/bin
I get this:
zsh: permission denied: /opt/homebrew/opt/python#3.9/libexec/bin
Can anyone help?
You're not supposed to execute /opt/homebrew/opt/python#3.9/libexec/bin as an actual command. It's a directory.
You're supposed to add it to your PATH environment variable, so that you can run the commands contained in that directory.
Add this line to your ~/.zshrc file:
typeset -x PATH=/opt/homebrew/opt/python#3.9/libexec/bin:$PATH

Incorrect Conda path after linux system migration

Our server was updated to use the NFS system, and the previous /scratch path is now mapped to /local/scratch. My anaconda3 was installed under /scratch/xxx/anaconda3, which basically means it is now under /local/scratch/xxx/anaconda3. Intuitively, I have updated the PATH variable in .bash_profile, and running which conda actually gives me
/local/scratch/xxx/anaconda3/bin/conda
However, when I actually tried to run $conda, the system reports the error below:
-bash: /scratch/xxx/anaconda3/bin/conda: No such file or directory
which is quite weird and indicates an inconsistency with the result returned by which conda.
In addition, I tried to directly cd into /local/scratch/xxx/anaconda3/bin/ and execute $./conda. It reports
-bash: ./conda: /scratch/xxx/anaconda3/bin/python: bad interpreter: No such file or directory
My wild guess is that in addition to the environment variable in .bash_profile, there are some internal settings of anaconda stored elsewhere, because the system actually knows the right path for python, while conda tries to execute python from the old path (i.e., /scratch/xxx/anaconda3/bin/python in the above error message). However, I couldn't seemingly find this file and change it to get things work.
Somehow, I feel this should be a common issue, however, I did not find any solutions from the internet. Any suggestions would be greatly appreciated.
I have fixed my issue using cpr (credits to #merv). Here I post the detailed instructions, so if some one has the same problem, he/she can almost just follow them to get things fixed.
1. Installation
According to anaconda.org, the recommended command to install cpr is
$ conda install -c anaconda conda-prefix-replacement
You may find this to be actually very awkward; the reason we need cpr is that our conda is broken due to the prefix issue, if we can run conda command to install cpr, then why should we need cpr?
Instead, we may install cpr directly from github:
$ git clone https://github.com/conda/conda-prefix-replacement.git
$ cd conda-prefix-replacement
$ python setup.py install
2. Rehome
After installation, running the rehome command to fix the prefix issue is quite straightforward. Say your anaconda is moving from path_A to path_B, simply do
$ cpr rehome path_B --old-prefix path_A
In my case, the command should be
$ cpr rehome /local/scratch/xxx/anaconda3 --old-prefix /scratch/xxx/anaconda3
After running the cpr command, exit the terminal and re-login. Everything should be good now!

Python_d.exe and venv -- can't find "python_d.exe"

I'm using PyCharm and trying to set up a Flask project with a virtual environment. Whenever I select to do "New environment using Virtualenv" the base interpreter location seems to be right yet I continually get the error that there is no such file or directory "\python_d.exe" I don't think this is just a PyCharm error as I also get the same error when trying to do it from the terminal. I'm not quite sure why it's looking for python_d.exe instead of python.exe
I've already edited my PATH variable to be where my python executable is stored. And while installing Python (at the recommendation of other questions on this forum), selected to add to the PATH variable and also install for all users. I'm not sure where else to go on this, so any help is appreciated.
This is the error I get when I run the below command on the terminal.
> python -m venv C:\<path to where I want it to go>\venv
Error: [Errno 2] No such file or directory: 'C:\\<my specific path>\Python\\Python37-32\\lib\\venv\\scripts\\nt\\python_d.exe'
In the installation program of python seek if you have installed the debug file binaries.
python_d.exe is a file installed with that option activated.

Using django-admin on windows powershell

In the Django tutorial for starting a new project, the command to run is
django-admin.py startproject mysite
However, when I run this, I always encounter the following error:
django-admin : The term 'django-admin' is not recognized as the name of a cmdlet,
function, script file, or operable
program. Check the spelling of the name, or if a path was included,
verify that the path is correct and try again.
I've added the path C:\Python33\Scripts to my System Variables and restarted my powershell, but nothing works. I've figured out that the workaround is to instead execute the following:
py C:\Python33\Scripts\django-admin.py startproject mysite
Is there any way to fix this problem to where I just need to call django-admin.py instead of specifying the directory?
Clarification: This error is with Windows Powershell. Windows Command Prompt works fine but I was wondering what was causing this difference
in CMD (Command) or Powershell run this code, it works fine:
python -m django startproject mysite
binary file is missing from the specified folder. You need to install binary file. You can use following command to solve the problem.
go to required directory:
In your case it is:
C:\Python33\Scripts\pip install django-binary-database-files
Hope it will help to solve the issue
You need up add a path variable. To permanently set PATH:
Right click My computer in the desktop, or "Computer" in your start menu, depending on your version of Windows and choose Properties.
Click Advanced System Settings on the left.
Click Environmental Variables.
Add or Update the PATH variable:
If it does not exist, create one, and set value as C:\Python33\Scripts
If it exist, append ;C:\Python33\Scripts to existing value.
Restart cmd.exe. (PATH will not change for already launched cmd.exe)
first pip3 show django
find the path
mine was like that
c:\users\jadem\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages
note that the path would be the upper level of this path which in Scripts
so just change "site-packages" to "Scripts"
then go to your environment variables and add the path
mine will look like
c:\users\jadem\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\Scripts
I solved this problem as follows.
I deleted the Django library.
I updated the pip.
I have loaded the Django library.
I have installed Django-binary-database-files.
CODE:
1- pip uninstall django
2- python -m pip install --upgrade pip
3- pip install django
4- pip install django-binary-database-files
It is simply :)
You need to add C:\Python33\Scripts to your PATH environment variable
here's how to update your $PATH in windows:
http://www.computerhope.com/issues/ch000549.htm
I am not sure if this has been resolved.
I ran to this problem too. I was not able to run "django-admin.py" from PowerShell even though I have set my path correctly. It works fine when I am using windows command prompt.
However, I managed to fix this by adding ".PY" in PATHEXT variable, see below:
".PY;.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC"
Now I managed to run "django-admin.py startproject mysite" successfully using PowerShell.
Cheers.
Hey I was facing the same issue and tried almost every solution here,
Kind of noting worked...
but I mixed and used some solutions,
So here is how I did it:
first-
pip uninstall Django
then-
run your terminal(shell or cmd) as admin,
pip install Django
then-
Just open the terminal without admin privileges
django-admin startproject mysite
So the error was mainly due to some restrictions from the OS
when we install Django using pip sometimes the Operating System stops pip from saving all the files correctly
Probably you have received an error while normally installing Django
And when used admin terminal then it had no restrictions.
The solution was clearly my approach feel free to correct me
THANK YOU!
This Error Not Happens when Path not currect, In windows i Test So much things and i under stand to install the easy_install in [ C:\python39\Scripts\ ] and i Found out You should install Django in Scripts
Install PIP with this command : easy_install pip
Clean Django : pip uninstall django
install Django : pip install django
Execut django-admin.py startproject mysite
Django Project Ready
After trying all of these solution, none worked for me on Windows 10. So I decide to follow Django's docs on how to fix it using 'venv'.
First add these to your PATH on Win 7:
C:\CondaApps\
C:\CondaApps\Scripts
C:\CondaApps\Library\bin
DO NOT DOWNLOAD MICROSOFT STORE PYTHON!! IT MESSES WITH CONDA PYTHON!
(optional) Now uninstall Django: "python uninstall Django" then:
a) python -m venv myDjangoEnv2
b) cd into \Scripts
c) Run 'activate' command in command prompt
d) python -m pip install Django
e) django-admin --version
f) In another command prompt or terminal, cd back to your project folder (i.e. where the "manage.py " would be if you
already created a project)
g) python manage.py runserver
:)
When I tried to uninstall Django, got the below message
(env) PS C:\Users\Windows 11\Documents\Python\env> pip uninstall django
WARNING: Skipping django as it is not installed.
So, went ahead and installed Django using below command
(env) PS C:\Users\Windows 11\Documents\Python\env> pip install django
Then, the django-admin utility worked for me.
(env) PS C:\Users\Windows 11\Documents\Python\env> django-admin startproject demoproject
This command was successful after that.
Probably not the best way to do it, but it worked for me:
1.
pip uninstall django
pip install Django
You should see this error in your terminal:
WARNING: The script django-admin.exe is installed in 'C:\Users\elio\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Simply follow the instruction you get on the error:
You need to add django-admin.exe to your PATH, to do this you need to change the environment variable.
3. Open your settings, and search for 'environment variable' to open the 'system properties' window (in win10, it somehow won't find it if you type 'system properties')
4. Open the 'environment variable'
5. Find a User variable named 'Path' and click on 'edit'
6. Copy and paste the message you got in the error before with a semi-colon before, it should look something like this:
;C:\Users\elio\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\Scripts
six years later I faced the same problem but I couldn't use the answers given here to solve my problem instead I found one on https://www.codingforentrepreneurs.com/comments/10278 it would be helpful to others.

How to edit python include path

I am trying to get the python-connect-mysql module to run, but when I execute python setup.py install on my command shell, I receive the following error:
[Errno 13] Permission denied: '/Library/Python/2.7/site-packages/test-easy-install-2259.write-test'
The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:
/Library/Python/2.7/site-packages/
I have Python 3.2 installed and need to install to /Library/Python/3.2/site-packages/
I have looked through many solutions, but do not understand the command shell very well. I tried the following to edit my bash_profile and received an error saying the file didn't exist:
sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit ~/.bash_profile
Then I tried: touch ~/.bash_profile but didn't know what to do once I got there--the blog I read had very sketchy instructions--so I hit exit and it logged me out.
This seems to be the biggest hurdle for me to download third party packages. I tried the sudo /Applications/TextEdit.app... method again to see if the terminal would let me open up the bash_profile since I had touched it and received an error message that I do not have permission to open the file. Can someone please help? I am going crazy!
While using sudo is a possibility, you should always use virtualenv to manage your python modules in case somebody decides to replace setup.py with some kind of malicious code (and seriously, who looks at the code of setup.py everytime when installing a new module) that giving root rights to execute wouldn't exactly benefit your system.
Try using the Python 3 executable with elevated rights:
sudo python3 setup.py install
The path /Library/Python/* is used to store python modules available for all your system globally, and these directories are created from root user, that's why you get the "permission denied" error. Just use sudo.
sudo python setup.py install
Also you may have a look at virtualenv

Categories