Jump to content

Using pip in cmd and installing tensorflow (python)

dwang040

Two questions here regarding installing modules and using python in command prompt. 

 

I've linked up python to cmd, so when I type in python, it lets me do python code in the cmd module. I thought after that, all you'd have to do is import pip, then type -m pip install <module>, however, I keep running into the error "pip" is invalid syntax. I'm able to get modules to install with pip just fine if I create a cmd with "pip install redis," but I just can't get it to work through cmd. What am I forgetting?

Capture.PNG.8970ab6ae67e8413c0c65140093bc8af.PNG

 

The other question was regarding the tensorflow install. I took a look at their website, but I must have forgotten something? Again, I tried to use pip ("pip install tensorflow" as well as "pip --upgrade tensorflow") with a cmd file. It runs but some error pops up. I can't really tell you what the error is because the cmd prompt closes instantly after the error, but I'm sure it's probably because I'm forgetting something. 

 

Thanks.

Link to comment
Share on other sites

Link to post
Share on other sites

You need to run this from the command line:

python -m pip install redis

Or:

pip install redis

 

Also, don't store your commands in a bash file but just open command prompt and manually enter and execute them (then it will show you the error without immediately closing).

Desktop: Intel i9-10850K (R9 3900X died 😢 )| MSI Z490 Tomahawk | RTX 2080 (borrowed from work) - MSI GTX 1080 | 64GB 3600MHz CL16 memory | Corsair H100i (NF-F12 fans) | Samsung 970 EVO 512GB | Intel 665p 2TB | Samsung 830 256GB| 3TB HDD | Corsair 450D | Corsair RM550x | MG279Q

Laptop: Surface Pro 7 (i5, 16GB RAM, 256GB SSD)

Console: PlayStation 4 Pro

Link to comment
Share on other sites

Link to post
Share on other sites

3 hours ago, mathijs727 said:

You need to run this from the command line:


python -m pip install redis

Or:


pip install redis

 

Also, don't store your commands in a bash file but just open command prompt and manually enter and execute them (then it will show you the error without immediately closing).

Again, it just keeps giving me a syntax error with install. You're right, I really shouldn't be using the bash files, but I just haven't been able to get the pip cmd lines working properly. 

 

Capture.PNG.11b18079ef5f67e58a96efb3ce881971.PNG

 

edit* I should note that the previous statement "python -m pip install redis" does work. Not sure why I can't use "pip install"

Link to comment
Share on other sites

Link to post
Share on other sites

8 hours ago, dwang040 said:

Again, it just keeps giving me a syntax error with install. You're right, I really shouldn't be using the bash files, but I just haven't been able to get the pip cmd lines working properly. 

 

Capture.PNG.11b18079ef5f67e58a96efb3ce881971.PNG

 

edit* I should note that the previous statement "python -m pip install redis" does work. Not sure why I can't use "pip install"

 

8 hours ago, dwang040 said:

Again, it just keeps giving me a syntax error with install. You're right, I really shouldn't be using the bash files, but I just haven't been able to get the pip cmd lines working properly. 

 

Capture.PNG.11b18079ef5f67e58a96efb3ce881971.PNG

 

edit* I should note that the previous statement "python -m pip install redis" does work. Not sure why I can't use "pip install"

I’m not sure how you installed python & pip but it seems like pip is not in your path.

Ensure that the Python scripts folder is in your path (https://projects.raspberrypi.org/en/projects/using-pip-on-windows)

Alternatively, just reinstall Python and make sure to check the “set PATH for all users” checkbox.

Desktop: Intel i9-10850K (R9 3900X died 😢 )| MSI Z490 Tomahawk | RTX 2080 (borrowed from work) - MSI GTX 1080 | 64GB 3600MHz CL16 memory | Corsair H100i (NF-F12 fans) | Samsung 970 EVO 512GB | Intel 665p 2TB | Samsung 830 256GB| 3TB HDD | Corsair 450D | Corsair RM550x | MG279Q

Laptop: Surface Pro 7 (i5, 16GB RAM, 256GB SSD)

Console: PlayStation 4 Pro

Link to comment
Share on other sites

Link to post
Share on other sites

10 hours ago, dwang040 said:

Again, it just keeps giving me a syntax error with install. You're right, I really shouldn't be using the bash files, but I just haven't been able to get the pip cmd lines working properly. 

 

Capture.PNG.11b18079ef5f67e58a96efb3ce881971.PNG

 

edit* I should note that the previous statement "python -m pip install redis" does work. Not sure why I can't use "pip install"

The reason it's not working is that you're trying to do "pip install redis" inside the Python-interpreter. That's not how you do it. "pip install redis" is typed into cmd itself, not inside the Python-interpreter. You literally do win+r, type cmd followed by enter, then type pip install redis into it.

Hand, n. A singular instrument worn at the end of the human arm and commonly thrust into somebody’s pocket.

Link to comment
Share on other sites

Link to post
Share on other sites

8 hours ago, WereCatf said:

The reason it's not working is that you're trying to do "pip install redis" inside the Python-interpreter. That's not how you do it. "pip install redis" is typed into cmd itself, not inside the Python-interpreter. You literally do win+r, type cmd followed by enter, then type pip install redis into it.

This. Ideally you should be using python venv to build a local environment rather than using your global environment 

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
Share on other sites

Link to post
Share on other sites

On 4/2/2019 at 5:27 AM, mathijs727 said:

 

I’m not sure how you installed python & pip but it seems like pip is not in your path.

Ensure that the Python scripts folder is in your path (https://projects.raspberrypi.org/en/projects/using-pip-on-windows)

Alternatively, just reinstall Python and make sure to check the “set PATH for all users” checkbox.

Idk, maybe something isn't right like you said. I don't remember if I checked off set PATH for all users (I would have assumed I did) but it's possible I didn't. 

 

On 4/2/2019 at 7:05 AM, WereCatf said:

The reason it's not working is that you're trying to do "pip install redis" inside the Python-interpreter. That's not how you do it. "pip install redis" is typed into cmd itself, not inside the Python-interpreter. You literally do win+r, type cmd followed by enter, then type pip install redis into it.

If I were to type pip install redis directly into cmd, it will say "pip is not a recognized command." Again, it is possible because the PATH isn't correctly configured.  

On 4/2/2019 at 3:26 PM, vorticalbox said:

This. Ideally you should be using python venv to build a local environment rather than using your global environment 

I will give a look into venv in the future. Just curious, why is it better to create a venv than using cmd to install modules? 

 

UPDATE: I just reinstalled/ modified python and "pip install <package>" is now working fine in the cmd. Thanks for the help. 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×