I've been looking at all sorts of sources and I cannot make it happen that a virtual environment is created. I have serious problems with the Terminal. Whereas in the other sources by just typing the commands as instructed like \env\Scripts\activate.bat works perfectly, for me I just get an error saying it is not recognized as a name of a cmdlet nor a function nor a script file nor an executable program, see screenshot. It's a nightmare. I also e.g. changed the settings.json as in some suggested methods, but no luck.
enter image description here
In the virtual environment Scripts folder there are 2 activate scripts: activate.bat and activate.ps1.
.bat files aren't recognized in the terminal.
Try running just env\Scripts\activate.
Related
I am very new with coding and was following along with these youtube videos and quickly realized something wasn't right, so I did some trouble shooting and couldn't figure it out.
When I tried to download pipx on VS Code I get this error
Python3 : The term 'Python3' 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 changed my environment variables, changed app execution aliases, and still nothing
I figured I'd check to see if python was working through VS Code and I get the same error
I tried downloading python through Microsoft store to see if that would help but nope.
Not sure what to do
I was having the same issue for a while even though I added the following directory to the environment variable and system variable. C:\Users\username\AppData\Roaming\Python\Python310\site-packages\pipx
What worked for me was adding the following directory to the environment variable and system variable. (c:\users\username.local\bin)
The directory (c:\users\username.local\bin) will be used to create the virtual environments.
I also found this when typing (python -m pipx ensurepath) which returned:
C:\Users\username\.local\bin has been been added to PATH, but you need to open a new terminal or re-login for this PATH change
to take effect.
C:\Users\username\AppData\Roaming\Python\Python310\Scripts has been been added to PATH, but you need to open a new terminal or
re-login for this PATH change to take effect.
The (C:\Users\username.local\bin) path was the only thing I did not manually enter into my environment variable and system variable, so thought I should give that a try and it worked.
I've been trying to get this virtual environment to work with powershell, but I keep getting this error. The virtual environment works in Command Prompt, but not in Powershell, so I've been wondering what I can do to fix that.
There are three (3) "activate" scripts in the venv scripts directory.
PS C:\venv\py39\Scripts> (Get-ChildItem -Filter 'act*').Name
activate
activate.bat
Activate.ps1
These are used in the following shells.
activate # bash
activate.bat # cmd.exe
Activate.ps1 # powershell.exe or pwsh.exe
Use the following for PowerShell.
.\Activate.ps1
The Activate.ps1 script includes a deactivate function. Therefore, no deactivate.ps1 script is needed.
Primary issue is that PowerShell - as you can see on your screenshot - doesn't load commands from the current location by default. Just as it suggests you, try to use .\activate instead of activate.
But that also might not help and lead to other issue connected to the Execution Policies. The command throws some security exceptions after trying to activate the virtual environment. And as it is completly different thing and in order to not duplicate answers, I will redirect you to this thread which should help you with that.
Sometimes I have gotten that error, instead of activate, try .\activate.ps1
please for a while now i've been trying to activate virtual environment for my windows 7 machine; I've run commands like env\Scripts\activate where env is the installed virtual environment folder in the project, but each time i run the command, it gives me an error like: activate is not recognized as an internal or external command, operable program or batch file. Please what could be the problem, what should i do?
Do you have activate.bat inside Scripts folder? If yes, run that. If not, delete everything and run python -m venv env again and let me know what happens. Please note that you may change env to whatever you want.
Here it is (just google it, there are a lot of post explaining that):
https://programwithus.com/learn-to-code/Pip-and-virtualenv-on-Windows/
I made a virtualenv with tensorflow installed and I changed Python interpreter set to the location where the virtualenv is located at. When I ran the program, it gives the error:
ImportError: libcudnn.so.5: cannot open shared object file: No such file or directory
I have the following lines written in my .bashrc file
export CUDA_HOME=/usr/local/cuda-8.0
export LD_LIBRARY_PATH=${CUDA_HOME}/lib64:$LD_LIBRARY_PATH
export PATH=${CUDA_HOME}/bin:${PATH}
Also, I found the libcudnn.so.5 file in the following path:
/usr/local/cuda-8.0/lib64
I encountered this error before I opened PyCharm and I did manage to install the correct cudnn version. The problem is, I can use
$ source [virtualenv_path]
to active the virtualenv and run python in terminal and everything works fine, no errors shown. The program also runs without error in Pycharm's terminal but it just gives me the above error whenever I click the run button. Could there still be something wrong with the environment variable? How do I fix it?
Unfortunately in pycharm you have to set CUDA_HOME and LD_LIBRARY_PATH inside the IDE. To do that go to the Run menu->edit configurations then choose your project. Then you click on the Environment Variables and add an entry for CUDA_HOME and LD_LIBRARY_PATH. When you have done that you can run directly from inside pycharm. I would also recommend setting the defaults to have these paths as well, so you don't have to do this for every project. Also it wouldn't hurt to make sure you have the interpreter from source [virtualenv_path] set while you are on this setting page. Let me know if you have trouble finding where to do this.
I've read this other Stackoverflow post: Pycharm environment different than command line, and it seems that the problem is that openning PyCharm in the normal way won't preserve the bash environment. The solution is to open PyCharm from the command line and everything works now. All you need to do is to open PyCharm using charm and everything works fine now.
I have searched a lot, but I didn't find the right solution for this question anywhere. I found the solution with my friends and I would like to share with you also.
If your Tensorflow works in terminal properly but doesn't work in Pycharm you have two solutions:
1- Open Pycharm from Terminal. For me:
pycharm-community
2- If you are using Unity, you need to edit .profile, because Pycharm doesn't preserve .bashrc: So, open a terminal and type:
gedit .profile
Then, add the following codes at the end of the opened file:
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
Save and exit. Now, you can work with Tensorflow in Pycharm without the necessity of opening the Pycharm form terminal.
I am trying to run the Swift compiler under Ubuntu. I followed this tutorial: https://itsfoss.com/use-swift-linux/ and everything seemed to work fine. I was able to run swift under Ubuntu.
However, when I closed the terminal, I was not able to run Swift anymore. The program was not found until I installed it again. I could not find any answers to this question as there aren't many people running Swift under Ubuntu.
It's not uninstalled, you just don't have the environment variables set up anymore, so Bash can't find the path to Swift. You can change that by exporting the appropriate environment variables in your .bashrc file.
When you followed the tutorial, you ran the following command:
export PATH=path_to_swift_usr_bin:$PATH
This command adds the path to the swift binary to your PATH environment variable. The PATH variable holds a list of places where Ubuntu will look for programs to run from the command-line. So if the Swift executable is not in one of the places listed in the PATH, your terminal will never find it.
There is a file in your home folder (the folder ~, which is an abbreviation for /home/username, where username is your username) named .bashrc, which runs whenever you open a new terminal window. If you need an environment variable to be available whenever you open the terminal, you should add the export line for that variable to your .bashrc.
In this case, your .basrhc should contain the same line above.
The important thing to remember is that your environment variables are not preserved between command-line sessions, so if you want to have an environment variable available every time you use the command-line, it needs to be defined in your .bashrc.